aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2016-07-11 02:25:14 +0000
committerHal Finkel <hfinkel@anl.gov>2016-07-11 02:25:14 +0000
commit6fd5e1f02bf414803a86b6877a61818fb8914597 (patch)
treee69204f7571fba59219e0c26b47a75eb3f3df16b /llvm/lib/Analysis/ValueTracking.cpp
parent5c12d8fe8f7ac9a3ec13ddad1561d63477e014f6 (diff)
downloadllvm-6fd5e1f02bf414803a86b6877a61818fb8914597.zip
llvm-6fd5e1f02bf414803a86b6877a61818fb8914597.tar.gz
llvm-6fd5e1f02bf414803a86b6877a61818fb8914597.tar.bz2
Teach computeKnownBits to look through returned-argument functions
If a function is known to return one of its arguments, we can use that in order to compute known bits of the return value. Differential Revision: http://reviews.llvm.org/D9397 llvm-svn: 275036
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 5c5d213..3277c3c 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1279,11 +1279,16 @@ static void computeKnownBitsFromOperator(Operator *I, APInt &KnownZero,
}
case Instruction::Call:
case Instruction::Invoke:
+ // If range metadata is attached to this call, set known bits from that,
+ // and then intersect with known bits based on other properties of the
+ // function.
if (MDNode *MD = cast<Instruction>(I)->getMetadata(LLVMContext::MD_range))
computeKnownBitsFromRangeMetadata(*MD, KnownZero, KnownOne);
- // If a range metadata is attached to this IntrinsicInst, intersect the
- // explicit range specified by the metadata and the implicit range of
- // the intrinsic.
+ if (Value *RV = CallSite(I).getReturnedArgOperand()) {
+ computeKnownBits(RV, KnownZero2, KnownOne2, Depth + 1, Q);
+ KnownZero |= KnownZero2;
+ KnownOne |= KnownOne2;
+ }
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
switch (II->getIntrinsicID()) {
default: break;