re PR rtl-optimization/89588 (ICE in unroll_loop_constant_iterations, at loop-unroll...
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 11 Mar 2019 11:37:46 +0000 (11:37 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 11 Mar 2019 11:37:46 +0000 (11:37 +0000)
PR rtl-optimization/89588
* loop-unroll.c (decide_unroll_constant_iterations): Make guard for
explicit unrolling factor more robust.

From-SVN: r269579

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

index cf2e61d2d1f8ed91b128e69406904eb3ebee310a..989f883053dcf579f0a1917c79ccca8501226577 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/89588
+       * loop-unroll.c (decide_unroll_constant_iterations): Make guard for
+       explicit unrolling factor more robust.
+
 2019-03-11  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/89649
index cbc66736c040c68a3bcd15a41e80ad9cacd5b5fe..0164762bee96e986b3828f5be0813f45f4406c8d 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 - 1 > desc->niter - 2)
+      if ((unsigned) loop->unroll > desc->niter - 1)
        {
          if (dump_file)
            fprintf (dump_file, ";; Loop should have been peeled\n");
index ac02d28b85752afcd08692f373b786e5e791e8c8..e8d393a8103ae415f3944f761222900ae42c63a8 100644 (file)
@@ -1,3 +1,7 @@
+2019-03-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * c-c++-common/unroll-6.c: New test.
+
 2019-03-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/87571
diff --git a/gcc/testsuite/c-c++-common/unroll-6.c b/gcc/testsuite/c-c++-common/unroll-6.c
new file mode 100644 (file)
index 0000000..fd74f19
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-loop-optimize" } */
+
+void test (void)
+{
+  #pragma GCC unroll 2
+  for (int nv = 0; nv <= 2; nv += 2)
+    {}
+}