[PATCH] Add handling for range metadata in ValueTracking isKnownNonZero
hfinkel at anl.gov
hfinkel at anl.gov
Wed Oct 29 09:58:42 PDT 2014
Accounting for comments below, LGTM.
================
Comment at: lib/Analysis/ValueTracking.cpp:1542
@@ +1541,3 @@
+ // definitely non-zero.
+ IntegerType* Ty = cast<IntegerType>(V->getType());
+ ConstantInt* ZeroConstant = ConstantInt::get(Ty, 0);
----------------
Let's make this a little future-proof. At some point we'll likely support this range metadata on vectors, etc. So let's make this an if and a dyn_cast.
================
Comment at: lib/Analysis/ValueTracking.cpp:1544
@@ +1543,3 @@
+ ConstantInt* ZeroConstant = ConstantInt::get(Ty, 0);
+ const APInt ZeroValue = ZeroConstant->getValue();
+ if (rangeMetadataExcludesValue(Ranges, ZeroValue))
----------------
We don't need to construct the ZeroConstant here, just using something like this should work:
const APInt ZeroValue(Ty->getBitWidth(), 0);
http://reviews.llvm.org/D5947
More information about the llvm-commits
mailing list