re PR middle-end/80539 (gcc ICE at -O2 and above on valid code on x86_64-linux-gnu...
authorRichard Biener <rguenther@suse.de>
Thu, 27 Apr 2017 11:42:57 +0000 (11:42 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 27 Apr 2017 11:42:57 +0000 (11:42 +0000)
2017-04-27  Richard Biener  <rguenther@suse.de>

PR middle-end/80539
* tree-chrec.c (chrec_fold_plus_poly_poly): Deal with not
being in loop-closed SSA form conservatively.
(chrec_fold_multiply_poly_poly): Likewise.

* gcc.dg/torture/pr80539.c: New testcase.

From-SVN: r247322

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr80539.c [new file with mode: 0644]
gcc/tree-chrec.c

index cc202329c7f21a7de622158e0cc0e486f99919b9..44580fc15e2ed386dc191cf083e6b0622744b0c0 100644 (file)
@@ -1,3 +1,10 @@
+2017-04-27  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/80539
+       * tree-chrec.c (chrec_fold_plus_poly_poly): Deal with not
+       being in loop-closed SSA form conservatively.
+       (chrec_fold_multiply_poly_poly): Likewise.
+
 2017-04-27  Tamar Christina  <tamar.christina@arm.com>
 
        PR middle-end/79665
index fb60df234c6893192c1377f7a1e5d7dd8628ba98..a28e1a90634a1c66542db3db80b62fd3a709c2cd 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-27  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/80539
+       * gcc.dg/torture/pr80539.c: New testcase.
+
 2017-04-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/77728
diff --git a/gcc/testsuite/gcc.dg/torture/pr80539.c b/gcc/testsuite/gcc.dg/torture/pr80539.c
new file mode 100644 (file)
index 0000000..a667678
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+signed char a, b;
+void fn1()
+{
+  signed char c, e;
+  short d;
+  if (0) {
+      for (; d;) {
+l1:
+         for (c = 7; a; c++)
+           ;
+         e = 6;
+         for (; b; e++)
+           ;
+      }
+      c -= e;
+  }
+  if (d == 7)
+    goto l1;
+  a = c;
+}
index 80a1bbd2327344e3065c1d450816195e2f26a17c..28c08e7115c3865790a771142563893f5b3284de 100644 (file)
@@ -149,7 +149,12 @@ chrec_fold_plus_poly_poly (enum tree_code code,
 
   /* This function should never be called for chrecs of loops that
      do not belong to the same loop nest.  */
-  gcc_assert (loop0 == loop1);
+  if (loop0 != loop1)
+    {
+      /* It still can happen if we are not in loop-closed SSA form.  */
+      gcc_assert (! loops_state_satisfies_p (LOOP_CLOSED_SSA));
+      return chrec_dont_know;
+    }
 
   if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
     {
@@ -211,7 +216,12 @@ chrec_fold_multiply_poly_poly (tree type,
        chrec_fold_multiply (type, CHREC_LEFT (poly0), poly1),
        CHREC_RIGHT (poly0));
 
-  gcc_assert (loop0 == loop1);
+  if (loop0 != loop1)
+    {
+      /* It still can happen if we are not in loop-closed SSA form.  */
+      gcc_assert (! loops_state_satisfies_p (LOOP_CLOSED_SSA));
+      return chrec_dont_know;
+    }
 
   /* poly0 and poly1 are two polynomials in the same variable,
      {a, +, b}_x * {c, +, d}_x  ->  {a*c, +, a*d + b*c + b*d, +, 2*b*d}_x.  */