[PATCH] D12799: [ValueTracking] Teach isKnownNonZero a new trick
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 10:14:05 PDT 2015
reames added a subscriber: reames.
================
Comment at: lib/Analysis/ValueTracking.cpp:1837
@@ +1836,3 @@
+ APInt LoBits = APInt::getLowBitsSet(BitWidth, Shift->getLimitedValue());
+ if ((KnownZero & LoBits).eq(LoBits))
+ return KnownOne.getBoolValue() || isKnownNonZero(X, DL, Depth, Q);
----------------
This really seems like two distinct cases and the code would be clearer if organized as such.
case 1 - There's a known one bit somewhere in the portion not shifted out.
case 2 - All bits shifted out are known-zero and X is known non-zero.
I think what you have is correct, I just found the flow of the code confusing on first read.
================
Comment at: unittests/Analysis/ValueTrackingTest.cpp:203
@@ +202,3 @@
+
+TEST_F(KnownValueTest, NonZeroShiftRight) {
+ parseAssembly(
----------------
I'd probably just phrase this as a normal IR test for inst combine or inst simplify. What's here is correct, just needlessly complicated.
Repository:
rL LLVM
http://reviews.llvm.org/D12799
More information about the llvm-commits
mailing list