Bootstrapped and tested on x86_64-unknown-linux-gnu, re-doing together
with the fix for the fallout.

Richard.

2018-08-29  Richard Biener  <rguent...@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.

Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c        (revision 263944)
+++ gcc/tree-ssa-alias.c        (working copy)
@@ -2722,7 +2722,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;
     }
 
Index: gcc/testsuite/gcc.dg/torture/pr87132.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr87132.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr87132.c      (working copy)
@@ -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;
+}

Reply via email to