This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix incorrect byte swap detection (PR tree-optimization/60454)


Hi!

On Fri, Mar 07, 2014 at 05:35:01PM +0800, Thomas Preud'homme wrote:
> --- a/gcc/tree-ssa-math-opts.c
> +++ b/gcc/tree-ssa-math-opts.c
> @@ -1801,7 +1801,9 @@ find_bswap_1 (gimple stmt, struct symbolic_number *n, int limit)
>  
>    if (rhs_class == GIMPLE_BINARY_RHS)
>      {
> +      int i;
>        struct symbolic_number n1, n2;
> +      unsigned HOST_WIDEST_INT mask;
>        tree source_expr2;
>  
>        if (code != BIT_IOR_EXPR)
> @@ -1827,6 +1829,15 @@ find_bswap_1 (gimple stmt, struct symbolic_number *n, int limit)
>  	    return NULL_TREE;
>  
>  	  n->size = n1.size;
> +	  for (i = 0, mask = 0xff; i < n->size; i++, mask <<= 8)

This should be mask <<= BITS_PER_UNIT for consistency.

And, as has been said earlier, the testcase should be a runtime testcase
(in gcc.c-torture/execute/), probably with
__attribute__((noinline, noclone)) on the function, where main calls the
function with a couple of different values, verifies the result and aborts
if it is incorrect.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]