From cb90c0014070f4ace5bb88258b31c1d654162306 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 11 Mar 2019 11:37:46 +0000 Subject: [PATCH] re PR rtl-optimization/89588 (ICE in unroll_loop_constant_iterations, at loop-unroll.c:498) PR rtl-optimization/89588 * loop-unroll.c (decide_unroll_constant_iterations): Make guard for explicit unrolling factor more robust. From-SVN: r269579 --- gcc/ChangeLog | 6 ++++++ gcc/loop-unroll.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/unroll-6.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/unroll-6.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cf2e61d2d1f..989f883053d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-11 Eric Botcazou + + PR rtl-optimization/89588 + * loop-unroll.c (decide_unroll_constant_iterations): Make guard for + explicit unrolling factor more robust. + 2019-03-11 Richard Biener PR tree-optimization/89649 diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index cbc66736c04..0164762bee9 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -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"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac02d28b857..e8d393a8103 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-03-11 Eric Botcazou + + * c-c++-common/unroll-6.c: New test. + 2019-03-11 Paolo Carlini 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 index 00000000000..fd74f19bed5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/unroll-6.c @@ -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) + {} +} -- 2.30.2