[PATCH] Fix PR71824

Richard Biener rguenther@suse.de
Tue Jan 31 13:53:00 GMT 2017


The following fixes an ICE that happens because instantiate_scev
doesn't really work as expected for SESE regions (a FIXME comment
hints at this already).  So instead of asserting all goes well
just bail out (add_loop_constraints seems to add constraints not
required for correctness?).

Bootstrap & regtest in progress (though the patch can at most turn
an ICE into wrong-code).

This fixes build of 445.gobmk with -floop-nest-optimize.

Ok?

Thanks,
Richard

2017-01-31  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/71824
	* graphite-sese-to-poly.c (add_loop_constraints): Bail out
	instead of asserting.

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

Index: gcc/graphite-sese-to-poly.c
===================================================================
--- gcc/graphite-sese-to-poly.c	(revision 245058)
+++ gcc/graphite-sese-to-poly.c	(working copy)
@@ -930,7 +931,11 @@ add_loop_constraints (scop_p scop, __isl
   /* loop_i <= expr_nb_iters */
   gcc_assert (!chrec_contains_undetermined (nb_iters));
   nb_iters = scalar_evolution_in_region (region, loop, nb_iters);
-  gcc_assert (!chrec_contains_undetermined (nb_iters));
+  if (chrec_contains_undetermined (nb_iters))
+    {
+      isl_space_free (space);
+      return domain;
+    }
 
   isl_pw_aff *aff_nb_iters = extract_affine (scop, nb_iters,
 					     isl_space_copy (space));
Index: gcc/testsuite/gcc.dg/graphite/pr71824.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/pr71824.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/graphite/pr71824.c	(working copy)
@@ -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;
+      }
+}



More information about the Gcc-patches mailing list