re PR tree-optimization/84399 ([graphite] ICE in set_codegen_error, at graphite-isl...
authorRichard Biener <rguenther@suse.de>
Fri, 16 Feb 2018 08:16:17 +0000 (08:16 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 16 Feb 2018 08:16:17 +0000 (08:16 +0000)
2018-02-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/84399
* graphite-scop-detection.c (scop_detection::stmt_simple_for_scop_p):
For operands we can analyze at their definition make sure we can
analyze them at each use as well.

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

From-SVN: r257723

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

index 8ca7fba1714568428846c91fb655ce70636fc50a..f97986b0e9a0dd8dcc12706ee3d688f59354c59a 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84399
+       * graphite-scop-detection.c (scop_detection::stmt_simple_for_scop_p):
+       For operands we can analyze at their definition make sure we can
+       analyze them at each use as well.
+
 2018-02-16  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84190
index 43716f184485c5b9e0f855f5e0ed1bb30ebe8e05..70cb773186ac0014d3d2f3f381fd8c1a5b487595 100644 (file)
@@ -1027,7 +1027,23 @@ scop_detection::stmt_simple_for_scop_p (sese_l scop, gimple *stmt,
 
     case GIMPLE_ASSIGN:
     case GIMPLE_CALL:
-      return true;
+      {
+       tree op;
+       ssa_op_iter i;
+       /* Verify that if we can analyze operands at their def site we
+          also can represent them when analyzed at their uses.  */
+       FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_USE)
+         if (scev_analyzable_p (op, scop)
+             && !graphite_can_represent_expr (scop, bb->loop_father, op))
+           {
+             DEBUG_PRINT (dp << "[scop-detection-fail] "
+                          << "Graphite cannot represent stmt:\n";
+                          print_gimple_stmt (dump_file, stmt, 0,
+                                             TDF_VOPS | TDF_MEMSYMS));
+             return false;
+           }
+       return true;
+      }
 
     default:
       /* These nodes cut a new scope.  */
index 8c0e0f0d97dd624ee8d8fe058cd2828467279967..772879fd90aeb1cce20a0b2730f61d55e9f85d67 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/84399
+       * gcc.dg/graphite/pr84399.c: New testcase.
+
 2018-02-16  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84190
diff --git a/gcc/testsuite/gcc.dg/graphite/pr84399.c b/gcc/testsuite/gcc.dg/graphite/pr84399.c
new file mode 100644 (file)
index 0000000..4b142df
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize -fno-tree-loop-im --param scev-max-expr-size=1" } */
+
+void
+h8 (int cv, int od)
+{
+  for (;;)
+    {
+      int ih = (__UINTPTR_TYPE__)&od;
+      if (cv == 0)
+       while (od < 1)
+         {
+           int lq;
+
+           for (lq = 0; lq < 3; ++lq)
+             for (ih = 0; ih < 4; ++ih)
+               od += lq;
+         }
+      while (ih < 1)
+       {
+       }
+    }
+}