isKnownNonEqual(A, B) returns true if it can be determined that A != B.
At the moment it only knows one fact, that a non-wrapping add of nonzero to a value cannot be that value:
A + B != A [where B != 0, addition is nsw or nuw]
Paths
| Differential D12801
[ValueTracking] Add a new predicate: isKnownNonEqual() ClosedPublic Authored by jmolloy on Sep 11 2015, 5:55 AM.
Details
Diff Detail
Event Timelinejmolloy updated this object. jmolloy added a parent revision: D12800: [ValueTracking] Teach isKnownNonZero about monotonically increasing PHIs. Comment Actions I don't think you need to check for no-wrap -- a non-zero B should be sufficient to prove A + B != A. Comment Actions I like the idea of this function, but I'm somewhat nervous of adding such a generic facility with such a limited implementation. It would make me feel much better if it also had the following check: call computeKnownBits on V1 and V2, and return true if any of the bits known to be 1 in one value are known to be zero in the other. That would naturally leverage much more of the existing infrastructure. Also, I assume you're planning on soon using this somewhere? Comment Actions
...
You can ignore this; I see you're using it in D12801. Comment Actions
Err... D12802. jmolloy edited edge metadata. Comment ActionsHi Hal, Sanjoy, Thanks for the review. I've addressed both your comments, and:
Comment Actions Some minor comments inline.
Comment Actions Hi Sanjoy, Thanks for the comments. Switching to PatternMatch was a good idea - the code is substantially more readable! All comments acted upon. Cheers, James This revision is now accepted and ready to land.Oct 22 2015, 2:10 AM
Revision Contents
Diff 34545 include/llvm/Analysis/ValueTracking.h
lib/Analysis/ValueTracking.cpp
unittests/Analysis/ValueTrackingTest.cpp
|
Isn't this checking V1 == V2 + X? They're both equivalent though, so the answer is still okay, just mildly confusing. :)