This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Add a framework for encoding implication rules
ClosedPublic

Authored by sanjoy on Nov 4 2015, 8:25 PM.

Details

Summary

This change adds a framework for adding more smarts to
isImpliedCondition around inequalities. Informally,
isImpliedCondition will now try to prove "A < B ==> C < D" by proving
"C <= A && B <= D", since then it follows "C <= A < B <= D".

While this change is in principle NFC, I could not think of a way to not
handle cases like "i +_nsw 1 < L ==> i < L +_nsw 1" (that ValueTracking
did not handle before) while keeping the change understandable. I've
added tests for these cases.

Diff Detail

Event Timeline

sanjoy updated this revision to Diff 39312.Nov 4 2015, 8:25 PM
sanjoy retitled this revision from to [ValueTracking] Add a framework for encoding implication rules.
sanjoy updated this object.
sanjoy added reviewers: reames, majnemer, hfinkel.
sanjoy added a subscriber: llvm-commits.
majnemer added inline comments.Nov 5 2015, 12:38 PM
lib/Analysis/ValueTracking.cpp
4113

Isn't this vacuously true? I don't think we need to restrict C here.

reames accepted this revision.Nov 5 2015, 5:42 PM
reames edited edge metadata.

LGTM w/minor comment.

lib/Analysis/ValueTracking.cpp
4124

For the comment, what are 'A' and 'B'?

This revision is now accepted and ready to land.Nov 5 2015, 5:42 PM
This revision was automatically updated to reflect the committed changes.
sanjoy added inline comments.Nov 6 2015, 11:09 AM
lib/Analysis/ValueTracking.cpp
4113

This was fixed in D14369, as you've seen.

4124

I accidentally checked this in without addressing this comment, I'll fix this in a separate commit shortly.