re PR tree-optimization/87132 (Gcc miscompiles at -O2 on valid code)
authorRichard Biener <rguenther@suse.de>
Wed, 29 Aug 2018 14:13:20 +0000 (14:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 29 Aug 2018 14:13:20 +0000 (14:13 +0000)
2018-08-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87132
* tree-ssa-alias.c (get_continuation_for_phi): Do not translate
when skipping defs reachable over backedges.

* gcc.dg/torture/pr87132.c: New testcase.

From-SVN: r263959

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr87132.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index 02a7b94d1f210847e1ea5229edbe5eca022ac0ec..91a06ed7a16b3373b5460649f051e9d8a1af3a56 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87132
+       * tree-ssa-alias.c (get_continuation_for_phi): Do not translate
+       when skipping defs reachable over backedges.
+
 2018-08-29  Richard Biener  <rguenther@suse.de>
 
        * tree-core.h: Document use of deprecated_flag in SSA_NAME.
index ebdfcf5904a4dc4cb1d60ab0f9cc93f4643a17c2..d785c903497dce13f746d327de2cee2e818dfb7d 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87132
+       * gcc.dg/torture/pr87132.c: New testcase.
+
 2018-08-29  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/85110
diff --git a/gcc/testsuite/gcc.dg/torture/pr87132.c b/gcc/testsuite/gcc.dg/torture/pr87132.c
new file mode 100644 (file)
index 0000000..48b8673
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do run } */
+
+extern void abort (void);
+int c, d;
+int main()
+{
+  int e[] = {4, 4, 4, 4, 4, 4, 4, 4, 4};
+  d = 8;
+  for (; d; d--)
+    for (int a = 0; a <= 8; a++)
+      {
+       c = e[1];
+       e[d] = 0;
+      }
+  if (c != 0)
+    abort ();
+  return 0;
+}
index 6efe4c3a4a799b127a3c54958c871b1334f25baf..032e79b8ba0a3efd624bc97f51b038b65f538ae3 100644 (file)
@@ -2740,7 +2740,14 @@ next:;
       if (arg1 == arg0)
        ;
       else if (! maybe_skip_until (phi, arg0, ref, arg1, cnt, visited,
-                                  abort_on_visited, translate, data))
+                                  abort_on_visited,
+                                  /* Do not translate when walking over
+                                     backedges.  */
+                                  dominated_by_p
+                                    (CDI_DOMINATORS,
+                                     gimple_bb (SSA_NAME_DEF_STMT (arg1)),
+                                     phi_bb)
+                                  ? NULL : translate, data))
        return NULL_TREE;
     }