On Fri, Apr 15, 2016 at 01:41:25PM +0200, Jakub Jelinek wrote: > On Fri, Apr 15, 2016 at 01:37:07PM +0200, Bernd Schmidt wrote: > > On 04/15/2016 02:35 AM, Segher Boessenkool wrote: > > >This now also shows up on GCC 5, see PR70672. It there happens in > > >the jump1 pass already. > > > > > >Is this okay to backport to 5 and 4.9? > > > > Ok. > > Can you please also create a runtime testcase from PR70672 (unless it is > roughly the same as the other PR) and commit to all branches?
I came up with this. I'll commit it in an hour or so unless someone complains; it should work on all targets, BE and LE (tested on powerpc64-linux and powerpc64le-linux). So I now need to commit it to one more branch, yay :-) Segher gcc/testsuite/ PR rtl-optimization/70672 PR rtl-optimization/68814 * gcc.dg/pr70672.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/pr70672.c b/gcc/testsuite/gcc.dg/pr70672.c new file mode 100644 index 0000000..d785124 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr70672.c @@ -0,0 +1,64 @@ +/* PR rtl-optimization/70672 */ +/* PR rtl-optimization/68814 */ +/* { dg-do run { target { stdint_types } } } */ +/* { dg-options "-O2" } */ + +#include <stdint.h> +#include <stdlib.h> + +struct pair { + uint32_t one; + uint32_t two; +}; + +union u { + struct pair pair; + uint64_t num; +}; + +uint64_t __attribute__ ((noinline)) +f(uint64_t a) +{ + union u x; + + x.num = a; + + x.pair.one = x.pair.two; + x.pair.two = 0; + + return x.num; +} + +uint64_t __attribute__ ((noinline)) +g(uint64_t a) +{ + union u x; + + x.num = a; + + x.pair.two = x.pair.one; + x.pair.one = 0; + + return x.num; +} + +int +main (void) +{ + uint64_t x = 0x123456789abcdef0ULL; + uint64_t fx = f(x); + uint64_t gx = g(x); + uint64_t fgx = f(gx); + uint64_t gfx = g(fx); + + if ((fx & gx)) + abort (); + + if ((fgx & gfx)) + abort (); + + if ((fgx | gfx) != x) + abort (); + + return 0; +}