From 392594621391ab6dd6f6ccd4ad8a77b883c84a5b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 25 Apr 2017 09:27:01 +0200 Subject: [PATCH] re PR rtl-optimization/80500 (ICE: internal consistency failure (error: invalid rtl sharing found in the insn)) PR rtl-optimization/80500 * loop-unroll.c (combine_var_copies_in_loop_exit): Call copy_rtx on sum's initial value. * gcc.dg/pr80500.c: New test. From-SVN: r247126 --- gcc/ChangeLog | 6 ++++++ gcc/loop-unroll.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr80500.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr80500.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b389a0630f..1138786b996 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-25 Jakub Jelinek + + PR rtl-optimization/80500 + * loop-unroll.c (combine_var_copies_in_loop_exit): Call copy_rtx on + sum's initial value. + 2017-04-25 Julian Brown Naveen H.S diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index dd5bdc519b0..3d48a8fb7bc 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -1913,6 +1913,9 @@ combine_var_copies_in_loop_exit (struct var_to_expand *ve, basic_block place) if (ve->var_expansions.length () == 0) return; + /* ve->reg might be SUBREG or some other non-shareable RTL, and we use + it both here and as the destination of the assignment. */ + sum = copy_rtx (sum); start_sequence (); switch (ve->op) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4fb111ebe90..96f33f04755 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-25 Jakub Jelinek + + PR rtl-optimization/80500 + * gcc.dg/pr80500.c: New test. + 2017-04-25 Marc Glisse * gcc.dg/tree-ssa/cmpmul-1.c: New file. diff --git a/gcc/testsuite/gcc.dg/pr80500.c b/gcc/testsuite/gcc.dg/pr80500.c new file mode 100644 index 00000000000..ae3ac0184be --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr80500.c @@ -0,0 +1,15 @@ +/* PR rtl-optimization/80500 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -funroll-loops -ftree-loop-if-convert -fvariable-expansion-in-unroller" } */ + +signed char v; + +void +foo (int x) +{ + while (x != 0) + { + v = (x >= 0) + 1; + ++x; + } +} -- 2.30.2