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

2014-03-12 Thread Jakub Jelinek
On Wed, Mar 12, 2014 at 11:45:03AM +0800, Thomas Preud'homme wrote: > > From: Jakub Jelinek [mailto:ja...@redhat.com] > > > > In theory you could have __CHAR_BIT__ different from 8 and what you care > > about is that uint32_t has exactly 32 bits, so the check would need to be > > if (sizeof (uin

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

2014-03-12 Thread Jakub Jelinek
On Wed, Mar 12, 2014 at 11:43:00AM +0800, Joey Ye wrote: > 4.8 also has this bug. OK to backport? Yes. Jakub

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

2014-03-11 Thread Thomas Preud'homme
> From: Jakub Jelinek [mailto:ja...@redhat.com] > > In theory you could have __CHAR_BIT__ different from 8 and what you care > about is that uint32_t has exactly 32 bits, so the check would need to be > if (sizeof (uint32_t) * __CHAR_BIT__ != 32) > return 0; I could go with: In = (0x12 <<

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

2014-03-11 Thread Joey Ye
4.8 also has this bug. OK to backport? On Tue, Mar 11, 2014 at 6:59 PM, Jakub Jelinek wrote: > On Tue, Mar 11, 2014 at 06:48:37PM +0800, Thomas Preud'homme wrote: >> I also added a typedef unsigned uint32_t for when sizeof(unsigned) == 4. I >> hope it's right. > > In theory you could have __CHAR

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

2014-03-11 Thread Michael Eager
On 03/11/14 03:48, Thomas Preud'homme wrote: diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 748805e..b6d7d93 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-03-07 Thomas Preud'homme + + PR tree-optimization/60454 + * tree-ssa-math-opts.c (find_bswap_1): Fix

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

2014-03-11 Thread Jakub Jelinek
On Tue, Mar 11, 2014 at 06:48:37PM +0800, Thomas Preud'homme wrote: > I also added a typedef unsigned uint32_t for when sizeof(unsigned) == 4. I > hope it's right. In theory you could have __CHAR_BIT__ different from 8 and what you care about is that uint32_t has exactly 32 bits, so the check wou

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

2014-03-11 Thread Thomas Preud'homme
> From: Jakub Jelinek [mailto:ja...@redhat.com] > > The ChangeLog entry is wrong, the file is new, so you should just say: > * gcc.c-torture/execute/pr60454.c: New test. Done. > > But more importantly: > > > --- /dev/null > > +++ b/gcc/testsuite/gcc.c-torture/execute/pr60454.c > > @@ -0,

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

2014-03-11 Thread Jakub Jelinek
On Tue, Mar 11, 2014 at 02:53:39PM +0800, Thomas Preud'homme wrote: > +2014-03-10 Thomas Preud'homme > + > + PR tree-optimization/60454 > + * gcc.c-torture/execute/pr60454.c (fake_swap32): Testcase to track > + regression of PR60454. The ChangeLog entry is wrong, the file is new, so

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

2014-03-10 Thread Thomas Preud'homme
> From: Jakub Jelinek [mailto:ja...@redhat.com] > > n->size = n1.size; > > + for (i = 0, mask = 0xff; i < n->size; i++, mask <<= 8) > > This should be mask <<= BITS_PER_UNIT for consistency. Indeed. > > And, as has been said earlier, the testcase should be a runtime testcase > (in gcc

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

2014-03-07 Thread Jakub Jelinek
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

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

2014-03-07 Thread Richard Biener
On Fri, Mar 7, 2014 at 12:45 PM, Marcus Shawcroft wrote: > On 7 March 2014 09:35, Thomas Preud'homme wrote: > >> +++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-2.c >> @@ -0,0 +1,26 @@ >> +/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* >> rs6000-*-* x86_64-*-* s390*-*-* } } */

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

2014-03-07 Thread Marcus Shawcroft
On 7 March 2014 09:35, Thomas Preud'homme wrote: > +++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-2.c > @@ -0,0 +1,26 @@ > +/* { dg-do compile { target arm*-*-* alpha*-*-* i?86-*-* powerpc*-*-* > rs6000-*-* x86_64-*-* s390*-*-* } } */ I'm fairly sure the target list here should include aarch64*-*-

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

2014-03-07 Thread Thomas Preud'homme
The bswap optimization has a bug where a code can be incorrectly detected as doing a byte swap, therefore leading to change of behavior for the program compiled. This is tracked as PR60454. The patch below fixes the issue. Best regards, Thomas Preud'homme diff --git a/gcc/ChangeLog b/gcc/Chang