diff options
author | Bin Cheng <bin.cheng@arm.com> | 2016-02-10 14:09:05 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2016-02-10 14:09:05 +0000 |
commit | 13b562c502e92a602bf18e851c20fadfc2f4bfe9 (patch) | |
tree | 0e86553ae1799439c262ed251c08bab100f3fd5e /gcc/tree-ssa-loop-ivopts.c | |
parent | 00a8574af2b7df89e82dab3c415de8b7cb48a333 (diff) | |
download | gcc-13b562c502e92a602bf18e851c20fadfc2f4bfe9.zip gcc-13b562c502e92a602bf18e851c20fadfc2f4bfe9.tar.gz gcc-13b562c502e92a602bf18e851c20fadfc2f4bfe9.tar.bz2 |
re PR tree-optimization/68021 (ice in rewrite_use_nonlinear_expr with -O3)
PR tree-optimization/68021
* tree-ssa-loop-ivopts.c (get_computation_aff): Set ratio to 1 if
when computing the value of biv cand by itself.
gcc/testsuite/ChangeLog
PR tree-optimization/68021
* gcc.dg/tree-ssa/pr68021.c: New test.
From-SVN: r233269
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 4026d28..5302edf 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -3741,7 +3741,19 @@ get_computation_aff (struct loop *loop, var = fold_convert (uutype, var); } - if (!constant_multiple_of (ustep, cstep, &rat)) + /* Ratio is 1 when computing the value of biv cand by itself. + We can't rely on constant_multiple_of in this case because the + use is created after the original biv is selected. The call + could fail because of inconsistent fold behavior. See PR68021 + for more information. */ + if (cand->pos == IP_ORIGINAL && cand->incremented_at == use->stmt) + { + gcc_assert (is_gimple_assign (use->stmt)); + gcc_assert (use->iv->ssa_name == cand->var_after); + gcc_assert (gimple_assign_lhs (use->stmt) == cand->var_after); + rat = 1; + } + else if (!constant_multiple_of (ustep, cstep, &rat)) return false; /* In case both UBASE and CBASE are shortened to UUTYPE from some common |