re PR rtl-optimization/89753 (ICE in unroll_loop_constant_iterations, at loop-unroll...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 19 Mar 2019 08:06:48 +0000 (08:06 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 19 Mar 2019 08:06:48 +0000 (08:06 +0000)
PR rtl-optimization/89753
* loop-unroll.c (decide_unroll_constant_iterations): Make guard for
explicit unrolling factor even more robust.

From-SVN: r269791

gcc/ChangeLog
gcc/loop-unroll.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/unroll-7.c [new file with mode: 0644]

index 568435819d7b26879e14ffe98e55dbcc91b33c4e..5ef58714b3e59e65a7989c751245a56f7c316fb9 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-19  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/89753
+       * loop-unroll.c (decide_unroll_constant_iterations): Make guard for
+       explicit unrolling factor even more robust.
+
 2019-03-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/89726
index 0164762bee96e986b3828f5be0813f45f4406c8d..bc7840e4bfabb0af3564c49a48601aea4e2255ad 100644 (file)
@@ -400,7 +400,7 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
     {
       /* However we cannot unroll completely at the RTL level a loop with
         constant number of iterations; it should have been peeled instead.  */
-      if ((unsigned) loop->unroll > desc->niter - 1)
+      if (desc->niter == 0 || (unsigned) loop->unroll > desc->niter - 1)
        {
          if (dump_file)
            fprintf (dump_file, ";; Loop should have been peeled\n");
index ae077a1fc8e74bbdfa486709a244a941dc71d533..4e35805af654f420b9418bc7f65b0fa355d511bc 100644 (file)
@@ -1,3 +1,7 @@
+2019-03-19  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * c-c++-common/unroll-7.c: New test.
+
 2019-03-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/89726
diff --git a/gcc/testsuite/c-c++-common/unroll-7.c b/gcc/testsuite/c-c++-common/unroll-7.c
new file mode 100644 (file)
index 0000000..8332e9f
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dominator-opts" } */
+
+int nv;
+
+void test (void)
+{
+  #pragma GCC unroll 2
+  for (nv = 0; nv < 1; ++nv)
+    {}
+}