Latent, exposed by me removing the "redundant" 
rewrite-into-loop-closed-ssa.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-09-26  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/82321
        * graphite.c (canonicalize_loop_closed_ssa): Properly check
        for the def being inside the loop.

        * gcc.dg/graphite/pr82321.c: New testcase.

Index: gcc/graphite.c
===================================================================
--- gcc/graphite.c      (revision 253188)
+++ gcc/graphite.c      (working copy)
@@ -326,7 +327,9 @@ canonicalize_loop_closed_ssa (loop_p loo
 
          /* Only add close phi nodes for SSA_NAMEs defined in LOOP.  */
          if (TREE_CODE (arg) != SSA_NAME
-             || loop_containing_stmt (SSA_NAME_DEF_STMT (arg)) != loop)
+             || SSA_NAME_IS_DEFAULT_DEF (arg)
+             || ! flow_bb_inside_loop_p (loop,
+                                         gimple_bb (SSA_NAME_DEF_STMT (arg))))
            continue;
 
          tree res = copy_ssa_name (arg);
Index: gcc/testsuite/gcc.dg/graphite/pr82321.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/pr82321.c     (nonexistent)
+++ gcc/testsuite/gcc.dg/graphite/pr82321.c     (working copy)
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int y8;
+
+void
+dm (int io)
+{
+  if (y8 != 0)
+    {
+      int pu = 1;
+
+      while (io < 2)
+       {
+         int xo = (pu != 0) ? y8 : 0;
+
+         while (y8 != 0)
+           if (xo != 0)
+             {
+gi:
+               xo = (__INTPTR_TYPE__)&io;
+               pu = 0;
+             }
+       }
+    }
+
+  if (io != 0)
+    {
+      y8 = 1;
+      while (y8 != 0)
+       if (io / !y8 != 0)
+         y8 = 0;
+
+      goto gi;
+    }
+}

Reply via email to