This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR rtl-optimization/89588
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Mar 2019 10:05:02 +0100
- Subject: [patch] Fix PR rtl-optimization/89588
Hi,
this is the failure of the assertion:
/* Should not get here (such loop should be peeled instead). */
gcc_assert (niter > max_unroll + 1);
in unroll_loop_constant_iterations on a testcase both containing #pragma GCC
unroll and compiled with -fno-tree-loop-optimize. The proposed fix is just to
disable the pragma altogether when the option is passed.
Tested on x86_64-suse-linux, OK for mainline and 8 branch?
2019-03-11 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/89588
* tree-cfg.c (replace_loop_annotate_in_block) <annot_expr_unroll_kind>:
Skip annotation and warn if -fno-tree-loop-optimize is specified.
2019-03-11 Eric Botcazou <ebotcazou@adacore.com>
* c-c++-common/unroll-6.c: New test.
--
Eric Botcazou
Index: tree-cfg.c
===================================================================
--- tree-cfg.c (revision 269546)
+++ tree-cfg.c (working copy)
@@ -280,9 +280,16 @@ replace_loop_annotate_in_block (basic_bl
loop->safelen = INT_MAX;
break;
case annot_expr_unroll_kind:
- loop->unroll
- = (unsigned short) tree_to_shwi (gimple_call_arg (stmt, 2));
- cfun->has_unroll = true;
+ if (flag_tree_loop_optimize)
+ {
+ loop->unroll
+ = (unsigned short) tree_to_shwi (gimple_call_arg (stmt, 2));
+ cfun->has_unroll = true;
+ }
+ else
+ warning_at (gimple_location (stmt), 0,
+ "pragma GCC unroll disabled by "
+ "-fno-tree-loop-optimize");
break;
case annot_expr_no_vector_kind:
loop->dont_vectorize = true;
/* { 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) /* { dg-warning "GCC unroll disabled" } */
{}
}