Page MenuHomePhabricator

[SCEV] Pick backedge values for phi nodes correctly

Authored by sanjoy on Oct 6 2015, 1:45 AM.



getConstantEvolutionLoopExitValue and ComputeExitCountExhaustively
assumed all phi nodes in the loop header have the same order of incoming
values. This is not correct, and this commit changes
getConstantEvolutionLoopExitValue and ComputeExitCountExhaustively
to lookup the backedge value of a phi node using the loop's latch block.

Unfortunately, there is still some code duplication
getConstantEvolutionLoopExitValue and ComputeExitCountExhaustively.
At some point in the future we should extract out a helper class /
method that can evolve constant evolution phi nodes across iterations.

Fixes 25060. Thanks to Mattias Eriksson for the spot-on analysis!

Depends on D13457.

Diff Detail


Event Timeline

sanjoy updated this revision to Diff 36589.Oct 6 2015, 1:45 AM
sanjoy retitled this revision from to [SCEV] Pick backedge values for phi nodes correctly.
sanjoy updated this object.
sanjoy added reviewers: atrick, hfinkel.
sanjoy added a subscriber: llvm-commits.
materi added a subscriber: materi.Oct 6 2015, 2:40 AM
reames accepted this revision.Oct 8 2015, 9:54 AM
reames added a reviewer: reames.
reames added a subscriber: reames.


5745 ↗(On Diff #36589)

This line should probably be below the following comment.

5759 ↗(On Diff #36589)

Please put a comment that says not all phis have to list their arguments in the same order. This is subtle and easily confused.

This revision is now accepted and ready to land.Oct 8 2015, 9:54 AM
This revision was automatically updated to reflect the committed changes.