re PR tree-optimization/79977 ([graphite] ICE in outermost_loop_in_sese, at sese...
authorRichard Biener <rguenther@suse.de>
Thu, 9 Mar 2017 16:19:37 +0000 (16:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 9 Mar 2017 16:19:37 +0000 (16:19 +0000)
2017-03-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79977
* graphite-scop-detection.c (scop_detection::merge_sese):
Handle the case of extra exits to blocks dominating the entry.

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

From-SVN: r246006

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

index 901d0a45033211f612d16190b00318d70b5fd4a3..2c1b515b9107cda0803be312fd2c58c229fb7b1a 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79977
+       * graphite-scop-detection.c (scop_detection::merge_sese):
+       Handle the case of extra exits to blocks dominating the entry.
+
 2017-03-09  Toma Tabacu  <toma.tabacu@imgtec.com>
 
        * doc/sourcebuild.texi (Effective-Target Keywords, Other attributes):
index c372141addf5968902a5297a6acd42c3c678ac92..6b722b47965e92364e5e73206988fb08cc40a779 100644 (file)
@@ -817,6 +817,25 @@ scop_detection::merge_sese (sese_l first, sese_l second) const
         != loop_depth (exit->dest->loop_father))
     return invalid_sese;
 
+  /* For now we just bail out when there is a loop exit in the region
+     that is not also the exit of the region.  We could enlarge the
+     region to cover the loop that region exits to.  See PR79977.  */
+  if (loop_outer (entry->src->loop_father))
+    {
+      vec<edge> exits = get_loop_exit_edges (entry->src->loop_father);
+      for (unsigned i = 0; i < exits.length (); ++i)
+       {
+         if (exits[i] != exit
+             && bb_in_region (exits[i]->src, entry->dest, exit->src))
+           {
+             DEBUG_PRINT (dp << "[scop-detection-fail] cannot merge seses.\n");
+             exits.release ();
+             return invalid_sese;
+           }
+       }
+      exits.release ();
+    }
+
   /* For now we just want to bail out when exit does not post-dominate entry.
      TODO: We might just add a basic_block at the exit to make exit
      post-dominate entry (the entire region).  */
index deb6f6392592bd34338714dd996be6fc189e99f3..5050929f1a88504b997c2ca8e8cff48fa20605a1 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-09  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79977
+       * gcc.dg/graphite/pr79977.c: New testcase.
+
 2017-03-09  Toma Tabacu  <toma.tabacu@imgtec.com>
 
        * g++.dg/lto/pr69589_0.C: Add dg-require-effective-target for
diff --git a/gcc/testsuite/gcc.dg/graphite/pr79977.c b/gcc/testsuite/gcc.dg/graphite/pr79977.c
new file mode 100644 (file)
index 0000000..09606b0
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int uo[3];
+int di;
+
+void
+i7 (int mp)
+{
+  int l4;
+
+wh:
+  while (l4 > 1)
+    {
+      for (di = 0; di < 2; ++di)
+       uo[di] = 0;
+
+      for (di = 0; di < 3; ++di)
+       {
+         uo[di] = 0;
+         if (mp != 0)
+           goto wh;
+       }
+
+      --l4;
+    }
+}