This is an archive of the discontinued LLVM Phabricator instance.

[JumpThreading] Use dominating conditions to prove implications
ClosedPublic

Authored by sanjoy on Oct 21 2015, 9:55 PM.

Details

Summary

If P branches to Q conditional on C and Q branches to R conditional on
C' and C => C' then the branch conditional on C' can be folded to an
unconditional branch.

Diff Detail

Repository
rL LLVM

Event Timeline

sanjoy updated this revision to Diff 38087.Oct 21 2015, 9:55 PM
sanjoy retitled this revision from to [JumpThreading] Use dominating conditions to prove implications.
sanjoy updated this object.
sanjoy added a reviewer: reames.
sanjoy added a subscriber: llvm-commits.
hfinkel added inline comments.
lib/Transforms/Scalar/JumpThreading.cpp
909 ↗(On Diff #38087)

Don't you need to update CurrentPred in this loop in order to continue the search?

sanjoy updated this revision to Diff 38620.Oct 27 2015, 7:46 PM
  • fix bug pointed out by Hal, and add a test case that would've caught it
sanjoy marked an inline comment as done.Oct 27 2015, 7:47 PM
sanjoy added inline comments.
lib/Transforms/Scalar/JumpThreading.cpp
909 ↗(On Diff #38620)

Yes, I do need to update CurrentPred! Fixed.

hfinkel accepted this revision.Oct 27 2015, 8:40 PM
hfinkel added a reviewer: hfinkel.

LGTM.

This revision is now accepted and ready to land.Oct 27 2015, 8:40 PM

Also, while I'm generally not in favor of these "small search radius" optimizations, in this case, doing anything else would be a larger change because JumpThreading currently has no DominatorTree dependence. Thus, I'm okay with this as-is.

This revision was automatically updated to reflect the committed changes.
sanjoy marked an inline comment as done.