This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix incorrect byte swap detection (PR tree-optimization/60454)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Thomas Preud'homme" <thomas dot preudhomme at arm dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 7 Mar 2014 15:15:56 +0100
- Subject: Re: [PATCH] Fix incorrect byte swap detection (PR tree-optimization/60454)
- Authentication-results: sourceware.org; auth=none
- References: <000301cf39e8$84eb6910$8ec23b30$ at arm dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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