re PR tree-optimization/71824 (ICE when compiling libiberty with Graphite loop optimi...
authorRichard Biener <rguenther@suse.de>
Wed, 8 Feb 2017 08:30:48 +0000 (08:30 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 8 Feb 2017 08:30:48 +0000 (08:30 +0000)
2017-02-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71824
* graphite-scop-detection.c (scop_detection::build_scop_breadth):
Check all loops contained in the merged region.

* gcc.dg/graphite/pr71824-2.c: New testcase.

From-SVN: r245270

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

index 527143ac944834cb65f9941b249a9c9054d02338..1b518e68aed7bc99aadaf8a4cdc7ab9c2ecaf776 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71824
+       * graphite-scop-detection.c (scop_detection::build_scop_breadth):
+       Check all loops contained in the merged region.
+
 2017-02-07  Andrew Pinski  <apinski@cavium.com>
 
        * config/aarch64/aarch64.md (popcount<mode>2): New pattern.
index 2f9641235e23e5c634303488febfacde47b7f5b7..ee1f705b4902dd2e696273aa66d0f3b59c5757be 100644 (file)
@@ -905,9 +905,19 @@ scop_detection::build_scop_breadth (sese_l s1, loop_p loop)
 
   sese_l combined = merge_sese (s1, s2);
 
-  if (combined
-      && loop_is_valid_in_scop (loop, combined)
-      && loop_is_valid_in_scop (loop->next, combined))
+  /* Combining adjacent loops may add unrelated loops into the
+     region so we have to check all sub-loops of the outer loop
+     that are in the combined region.  */
+  if (combined)
+    for (l = loop_outer (loop)->inner; l; l = l->next)
+      if (bb_in_sese_p (l->header, combined)
+         && ! loop_is_valid_in_scop (l, combined))
+       {
+         combined = invalid_sese;
+         break;
+       }
+
+  if (combined)
     s1 = combined;
   else
     add_scop (s2);
index 81b25807dd0bfa53638eaa42ae299a4d4f102ee1..260a3a57b60d8895a5bdb68976e0bbd006d4c90f 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71824
+       * gcc.dg/graphite/pr71824-2.c: New testcase.
+
 2017-02-07  Andrew Pinski  <apinski@cavium.com>
 
        * gcc.target/aarch64/popcount.c : New Testcase.
diff --git a/gcc/testsuite/gcc.dg/graphite/pr71824-2.c b/gcc/testsuite/gcc.dg/graphite/pr71824-2.c
new file mode 100644 (file)
index 0000000..1817656
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+typedef struct { float x1; } bx;
+typedef struct {
+    int w;
+    short o;
+} T2P;
+T2P a;
+int b;
+void fn2();
+void fn3(bx*,short);
+void fn1() {
+    unsigned i = 0;
+    int c;
+    bx *d;
+    bx **h;
+    if (b == 0) {
+       fn2();
+       return;
+    }
+    for (; c; c++)
+      for (; i < 100; i++) {
+         d = h[i];
+         d->x1 = a.w;
+      }
+    for (; i < 100; i++) {
+       d = h[i];
+       d->x1 = a.w;
+    }
+    if (a.o)
+      for (; b;)
+       fn3(d, a.o);
+}