From 5a4c9a493153f6f579cd81905d0ab743dd88a33d Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 5 Sep 2019 13:23:28 +0000 Subject: [PATCH] re PR rtl-optimization/91656 (wrong code with -fgcse-after-reload) 2019-09-05 Richard Biener 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. From-SVN: r275406 --- gcc/ChangeLog | 6 ++++++ gcc/postreload-gcse.c | 3 --- gcc/testsuite/ChangeLog | 7 ++++++ gcc/testsuite/gcc.dg/torture/pr91656-1.c | 24 +++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr91656-2.c | 27 ++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr91656-3.c | 25 ++++++++++++++++++++++ 6 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr91656-1.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr91656-2.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr91656-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4f3d288a880..1de96224c20 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-09-05 Richard Biener + + PR rtl-optimization/91656 + * postreload-gcse.c (record_last_mem_set_info): Revert addition + of early out. + 2019-09-05 Richard Biener PR middle-end/90501 diff --git a/gcc/postreload-gcse.c b/gcc/postreload-gcse.c index 786678c66c8..c62aee9dcf4 100644 --- a/gcc/postreload-gcse.c +++ b/gcc/postreload-gcse.c @@ -696,9 +696,6 @@ record_last_reg_set_info_regno (rtx_insn *insn, int regno) 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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cdaa2705287..1d48a80c580 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-09-05 Richard Biener + + PR rtl-optimization/91656 + * gcc.dg/torture/pr91656-1.c: New testcase. + * gcc.dg/torture/pr91656-2.c: Likewise. + * gcc.dg/torture/pr91656-3.c: Likewise. + 2019-09-05 Nathan Sidwell PR preprocessor/91639 diff --git a/gcc/testsuite/gcc.dg/torture/pr91656-1.c b/gcc/testsuite/gcc.dg/torture/pr91656-1.c new file mode 100644 index 00000000000..6c1e73c7f01 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91656-1.c @@ -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; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91656-2.c b/gcc/testsuite/gcc.dg/torture/pr91656-2.c new file mode 100644 index 00000000000..90374becae0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91656-2.c @@ -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; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91656-3.c b/gcc/testsuite/gcc.dg/torture/pr91656-3.c new file mode 100644 index 00000000000..8e65d24a21d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91656-3.c @@ -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; +} -- 2.30.2