On Thu, 5 Sep 2019, Richard Biener wrote: > > I've made an error with the gcse-after-reload patch in disabling > record_last_mem_set_info, but only for the first function so > testing didn't reveal it. > > The following fixes this, avoding a few more allocations when > not needing transp computation and checking a variable which > is actually initialized at the point it is queried. > > Bootstrap & regtest running on x86_64-unknown-linux-gnu > both with transp compute forced to be off and not. > > Will apply once testing succeeds.
Going with the following simpler change, the previous showed some other issues. Bootstrapped on x86_64-unknown-linux-gnu with -fgcse-after-reload enabled and transp forced off sofar. More testing in progress. (I realized -O2 doesn't enable -fgcse-after-reload) Richard. 2019-09-05 Richard Biener <rguent...@suse.de> PR rtl-optimization/91656 * postreload-gcse.c (record_last_mem_set_info): Revert addition of early out. * gcc.dg/torture/pr91656-1.c: New testcase. * gcc.dg/torture/pr91656-2.c: Likewise. * gcc.dg/torture/pr91656-3.c: Likewise. Index: gcc/testsuite/gcc.dg/torture/pr91656-1.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr91656-1.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr91656-1.c (working copy) @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fgcse-after-reload" } */ + +int a, b, c, d, e; + +static __attribute__ ((__noipa__)) +int foo (int i) +{ + __builtin_memmove (&i, &e, 1); + if (a > 0) + i /= e; + e /= 5; + b = 0; + return i + c + d + 5; +} + +int +main (void) +{ + int x = foo (4); + if (x != 5) + __builtin_abort (); + return 0; +} Index: gcc/testsuite/gcc.dg/torture/pr91656-2.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr91656-2.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr91656-2.c (working copy) @@ -0,0 +1,27 @@ +/* { dg-do run { target int128 } } */ +/* { dg-additional-options "-fgcse-after-reload" } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +int a, b, c; +__int128 e; +int +d (u16 g) +{ + u64 f = __builtin_bswap64 (c); + f = g == a; + __builtin_memmove (&f, &e, 1); + e >>= b; + return a + f; +} + +int +main (void) +{ + __int128 x = d (0); + if (x != 0) + __builtin_abort (); + return 0; +} Index: gcc/testsuite/gcc.dg/torture/pr91656-3.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr91656-3.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr91656-3.c (working copy) @@ -0,0 +1,25 @@ +/* { dg-do run { target int128 } } */ +/* { dg-additional-options "-fgcse-after-reload" } */ + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +int a, b, c; +int +d (u16 e, u64 f) +{ + b |= e; + __builtin_memset (&f, e, 2); + a = (u16) - e >= 2 ? : __builtin_popcountll (f); + return a + c; +} + +int +main (void) +{ + __int128 x = d (~0, 0); + if (x != 16) + __builtin_abort (); + return 0; +} Index: gcc/postreload-gcse.c =================================================================== --- gcc/postreload-gcse.c (revision 275399) +++ gcc/postreload-gcse.c (working copy) @@ -696,9 +696,6 @@ record_last_reg_set_info_regno (rtx_insn static void record_last_mem_set_info (rtx_insn *insn) { - if (!transp) - return; - struct modifies_mem *list_entry; list_entry = (struct modifies_mem *) obstack_alloc (&modifies_mem_obstack,