This is an archive of the discontinued LLVM Phabricator instance.

[IndVars] Don't break dominance in `eliminateIdentitySCEV`
ClosedPublic

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

Details

Summary

After r249211, getSCEV(X) == getSCEV(Y) does not guarantee that X and
Y are related in the dominator tree, even if X is an operand to Y (I've
included a toy example in comments, and a real example as a test case).

This commit changes SimplifyIndVar to require a DominatorTree. I
don't think this is a problem because ScalarEvolution requires it
anyway.

Fixes PR25051.

Depends on D13459.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 36591.Oct 6 2015, 1:46 AM
sanjoy retitled this revision from to [IndVars] Don't break dominance in `eliminateIdentitySCEV`.
sanjoy updated this object.
sanjoy added reviewers: atrick, hfinkel.
sanjoy added a subscriber: llvm-commits.
mehdi_amini added inline comments.
lib/Transforms/Utils/SimplifyIndVar.cpp
328 ↗(On Diff #36591)

Not sure if it is related, but about live-out value for loops, if the exit value is the same you could RAUW uses that are outside of the loop. Does it mean that we will pessimize this case? Is it handled somewhere else?

sanjoy added inline comments.Oct 6 2015, 12:32 PM
lib/Transforms/Utils/SimplifyIndVar.cpp
328 ↗(On Diff #36591)

I'm not a 100% sure I understand what you mean, but RewriteLoopExitValues runs /after/ the induction variables have been simplified.

If you're concerned about breaking LCSSA, then see D13461. :)

This revision was automatically updated to reflect the committed changes.
sanjoy added a comment.Oct 6 2015, 2:51 PM

I decided to check this in and switch to a post-commit review for the following reasons:

  • The fix itself is fairly simple and low-risk
  • People were blocked on getting this fix in
  • I didn't want to mess up the history with revert / un-revert commits