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

PR tree-optimization/71824
* graphite-scop-detection.c (scop_detection::build_scop_breadth):
Verify the loops are valid in the merged SESE region.
(scop_detection::can_represent_loop_1): Check analyzing the
evolution of the number of iterations in the region succeeds.

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

From-SVN: r245081

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

index 02f635ea8f300612b82723127f7fe73582ea290b..1b62c0b7badfbd86422362135b06797079d613ef 100644 (file)
@@ -1,3 +1,11 @@
+2017-02-01  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71824
+       * graphite-scop-detection.c (scop_detection::build_scop_breadth):
+       Verify the loops are valid in the merged SESE region.
+       (scop_detection::can_represent_loop_1): Check analyzing the
+       evolution of the number of iterations in the region succeeds.
+
 2017-01-31  Ian Lance Taylor  <iant@golang.org>
 
        * config/i386/i386.c (ix86_expand_split_stack_prologue): Add
index 3860693d65c64f15a6e556ea9ecd0b152f9f082e..2f9641235e23e5c634303488febfacde47b7f5b7 100644 (file)
@@ -905,7 +905,9 @@ scop_detection::build_scop_breadth (sese_l s1, loop_p loop)
 
   sese_l combined = merge_sese (s1, s2);
 
-  if (combined)
+  if (combined
+      && loop_is_valid_in_scop (loop, combined)
+      && loop_is_valid_in_scop (loop->next, combined))
     s1 = combined;
   else
     add_scop (s2);
@@ -931,6 +933,8 @@ scop_detection::can_represent_loop_1 (loop_p loop, sese_l scop)
     && niter_desc.control.no_overflow
     && (niter = number_of_latch_executions (loop))
     && !chrec_contains_undetermined (niter)
+    && !chrec_contains_undetermined (scalar_evolution_in_region (scop,
+                                                                loop, niter))
     && graphite_can_represent_expr (scop, loop, niter);
 }
 
index c313baa643799db06cbc09fe98335497198e676f..dbbd485e11822953c1980a25b8db06761d477158 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-01  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71824
+       * gcc.dg/graphite/pr71824.c: New testcase.
+
 2017-01-31  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79304
diff --git a/gcc/testsuite/gcc.dg/graphite/pr71824.c b/gcc/testsuite/gcc.dg/graphite/pr71824.c
new file mode 100644 (file)
index 0000000..2a90e30
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int a, b, d;
+int **c;
+int fn1() {
+    while (a)
+      if (d) {
+         int e = -d;
+         for (; b < e; b++)
+           c[b] = &a;
+      } else {
+         for (; b; b++)
+           c[b] = &b;
+         d = 0;
+      }
+}