diff options
author | Richard Biener <rguenther@suse.de> | 2022-10-24 08:52:12 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-10-25 13:40:10 +0200 |
commit | 4c5b1160776382772fc0a33130dfaf621699fdbf (patch) | |
tree | e62c6cc7b34750164fa02c4518434162d155778c /gcc/expr.cc | |
parent | cb21297f9259ceedd5f5dd7c3973535f14124d6d (diff) | |
download | gcc-4c5b1160776382772fc0a33130dfaf621699fdbf.zip gcc-4c5b1160776382772fc0a33130dfaf621699fdbf.tar.gz gcc-4c5b1160776382772fc0a33130dfaf621699fdbf.tar.bz2 |
tree-optimization/107176 - SCEV analysis association issue
The following fixes a wrong-code issue caused by SCEV analysis
associating an addition due trying to use tail-recursion in
follow_ssa_edge_expr. That causes us to apply a conversion at
the wrong point and thus miscompute the scalar evolution of
an induction variable. This reverts the PR66375 fix and
revisits the PR42512 fix by keeping the evolution symbolic
up to the point we process the first linear function when
we then can check for the supported cases and substitute the
whole symbolic expression with the built chrec substituting
the proper initial value.
To simplify passing around things and to clarify scoping of
the involved functions this change wraps the SCEV DFS walking
code into a class.
PR tree-optimization/107176
PR tree-optimization/66375
PR tree-optimization/42512
* tree-scalar-evolution.cc (follow_ssa_edge_expr): Revert
the PR66375 fix, do not not associate PLUS_EXPR to be able
to use tail-recursion.
(follow_ssa_edge_binary): Likewise.
(interpret_loop_phi): Revert PR42512 fix, do not throw
away analyze_evolution_in_loop result after the fact.
(follow_ssa_edge_expr): When reaching halting_phi initalize
the evolution to the symbolic value of the PHI result.
(add_to_evolution_1): When adding the first evolution verify
we can handle the expression wrapping the symbolic evolution
and replace that in full using the initial condition.
(class scev_dfs): New, contains ...
(follow_ssa_edge_expr, follow_ssa_edge_binary,
follow_ssa_edge_in_condition_phi_branch,
follow_ssa_edge_in_condition_phi,
follow_ssa_edge_inner_loop_phi,
add_to_evolution, add_to_evolution_1): ... these with
loop and halting_phi arguments in class data.
(scev_dfs::get_ev): New toplevel DFS entry, start with
a chrec_dont_know evolution.
(analyze_evolution_in_loop): Use scev_dfs.
* gcc.dg/torture/pr107176.c: New testcase.
Diffstat (limited to 'gcc/expr.cc')
0 files changed, 0 insertions, 0 deletions