summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-08-12 10:14:11 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-08-12 10:14:11 +0000
commit6669f253d582f3de896737001f8e67c84bab5b0e (patch)
tree4f7a85e05a3cf73067c38b92b43fc0f4e518fa71 /llvm/lib/Analysis
parent05e760ec4b53cac179dc5dfc4d3f76e1024a097e (diff)
downloadbcm5719-llvm-6669f253d582f3de896737001f8e67c84bab5b0e.tar.gz
bcm5719-llvm-6669f253d582f3de896737001f8e67c84bab5b0e.zip
[LVI] Take range metadata into account while calculating icmp condition constraints
Take range metadata into account for conditions like this: %length = load i32, i32* %length_ptr, !range !{i32 0, i32 2147483647} %cmp = icmp ult i32 %a, %length This is a common pattern for range checks where the length of the array is dynamically loaded. Reviewed By: sanjoy Differential Revision: https://reviews.llvm.org/D23267 llvm-svn: 278496
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index c5c90271a08..8c090108c60 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1211,6 +1211,9 @@ static LVILatticeVal getValueFromICmpCondition(Value *Val, ICmpInst *ICI,
/*isFullSet=*/true);
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
RHSRange = ConstantRange(CI->getValue());
+ else if (Instruction *I = dyn_cast<Instruction>(RHS))
+ if (auto *Ranges = I->getMetadata(LLVMContext::MD_range))
+ RHSRange = getConstantRangeFromMetadata(*Ranges);
// If we're interested in the false dest, invert the condition
CmpInst::Predicate Pred =
OpenPOWER on IntegriCloud