re PR rtl-optimization/91656 (wrong code with -fgcse-after-reload)
authorRichard Biener <rguenther@suse.de>
Thu, 5 Sep 2019 13:23:28 +0000 (13:23 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 5 Sep 2019 13:23:28 +0000 (13:23 +0000)
2019-09-05  Richard Biener  <rguenther@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.

From-SVN: r275406

gcc/ChangeLog
gcc/postreload-gcse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr91656-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91656-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91656-3.c [new file with mode: 0644]

index 4f3d288a8801c8c26150123aa40042119ae61b8f..1de96224c2011766ed0dc8f54d38a556f307dd09 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-05  Richard Biener  <rguenther@suse.de>
+
+       PR rtl-optimization/91656
+       * postreload-gcse.c (record_last_mem_set_info): Revert addition
+       of early out.
+
 2019-09-05  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/90501
index 786678c66c8949cbe17c1f53af3a4e8403698106..c62aee9dcf447dd902410ede95e17b004b61e5d8 100644 (file)
@@ -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,
index cdaa2705287984beee4f36ea305f580798b50134..1d48a80c580daccc188f764477e099ae8281440e 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-05  Richard Biener  <rguenther@suse.de>
+
+       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  <nathan@acm.org>
 
        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 (file)
index 0000000..6c1e73c
--- /dev/null
@@ -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 (file)
index 0000000..90374be
--- /dev/null
@@ -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 (file)
index 0000000..8e65d24
--- /dev/null
@@ -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;
+}