re PR tree-optimization/81373 (Graphite ICE in ssa_default_def at gcc/tree-dfa.c...
authorRichard Biener <rguenther@suse.de>
Wed, 20 Sep 2017 07:33:58 +0000 (07:33 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 20 Sep 2017 07:33:58 +0000 (07:33 +0000)
2017-09-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/81373
* graphite-scop-detection.c (build_cross_bb_scalars_def):
Force SESE live-out defs to be handled even if they are
scev_analyzable_p.

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

From-SVN: r253000

gcc/ChangeLog
gcc/graphite-scop-detection.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr81373.c [new file with mode: 0644]

index 8f3485b..a5522e9 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/81373
+       * graphite-scop-detection.c (build_cross_bb_scalars_def):
+       Force SESE live-out defs to be handled even if they are
+       scev_analyzable_p.
+
 2017-09-19  Jeff Law  <law@redhat.com>
 
        * combine-stack-adj.c (combine_stack_adjustments_for_block): Do
index 3ed6afd..6fe375e 100644 (file)
@@ -1717,17 +1717,20 @@ build_cross_bb_scalars_def (scop_p scop, tree def, basic_block def_bb,
   if (!def || !is_gimple_reg (def))
     return;
 
-  /* Do not gather scalar variables that can be analyzed by SCEV as they can be
-     generated out of the induction variables.  */
-  if (scev_analyzable_p (def, scop->scop_info->region))
-    return;
+  bool scev_analyzable = scev_analyzable_p (def, scop->scop_info->region);
 
   gimple *use_stmt;
   imm_use_iterator imm_iter;
   FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
-    if ((def_bb != gimple_bb (use_stmt) && !is_gimple_debug (use_stmt))
-       /* PHIs have their effect at "BBs" on the edges.  See PR79622.  */
-       || gimple_code (SSA_NAME_DEF_STMT (def)) == GIMPLE_PHI)
+    /* Do not gather scalar variables that can be analyzed by SCEV as they can
+       be generated out of the induction variables.  */
+    if ((! scev_analyzable
+        /* But gather SESE liveouts as we otherwise fail to rewrite their
+           exit PHIs.  */
+        || ! bb_in_sese_p (gimple_bb (use_stmt), scop->scop_info->region))
+       && ((def_bb != gimple_bb (use_stmt) && !is_gimple_debug (use_stmt))
+           /* PHIs have their effect at "BBs" on the edges.  See PR79622.  */
+           || gimple_code (SSA_NAME_DEF_STMT (def)) == GIMPLE_PHI))
       {
        writes->safe_push (def);
        DEBUG_PRINT (dp << "Adding scalar write: ";
index d2eec19..43d0ab3 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/81373
+       * gcc.dg/graphite/pr81373.c: New testcase.
+
 2017-09-19  Jeff Law  <law@redhat.com>
 
        * gcc.target/i386/stack-check-11.c: New test.
diff --git a/gcc/testsuite/gcc.dg/graphite/pr81373.c b/gcc/testsuite/gcc.dg/graphite/pr81373.c
new file mode 100644 (file)
index 0000000..588b9d0
--- /dev/null
@@ -0,0 +1,40 @@
+/* { dg-options "-fno-tree-scev-cprop -fgraphite-identity -O -fdump-tree-graphite-all" } */
+
+void bar (void);
+
+int toto()
+{
+  int i, j, k;
+  int a[101][100];
+  int b[100];
+
+  for (i = 1; i < 100; i++)
+    {
+      for (j = 1; j < 100; j++)
+       for (k = 1; k < 100; k++)
+         a[j][k] = a[j+1][i-1] + 2;
+
+      b[i] = b[i-1] + 2;
+
+      bar ();
+
+      for (j = 1; j < 100; j++)
+       a[j][i] = a[j+1][i-1] + 2;
+
+      b[i] = b[i-1] + 2;
+
+      bar ();
+
+      for (j = 1; j < 100; j++)
+       a[j][i] = a[j+1][i-1] + 2;
+
+      b[i] = a[i-1][i] + 2;
+
+      for (j = 1; j < 100; j++)
+       a[j][i] = a[j+1][i-1] + 2;
+    }
+
+  return a[3][5] + b[1];
+}
+
+/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */