summaryrefslogtreecommitdiff
path: root/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-08-27 23:29:38 +0000
committerOwen Anderson <resistor@mac.com>2010-08-27 23:29:38 +0000
commitee61fcf98bb84e7e9f3450035bef92c4d087c0ae (patch)
tree6228aa9f5c2400a67dc055b90043c1d618b5b9c0 /lib/Analysis/LazyValueInfo.cpp
parentd4bfd54ec2947e73ab152c3c548e4dd4beb700ba (diff)
downloadllvm-ee61fcf98bb84e7e9f3450035bef92c4d087c0ae.tar.gz
llvm-ee61fcf98bb84e7e9f3450035bef92c4d087c0ae.tar.bz2
llvm-ee61fcf98bb84e7e9f3450035bef92c4d087c0ae.tar.xz
Improve the precision of getConstant().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--lib/Analysis/LazyValueInfo.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp
index 7e00f143c6..e7929f3127 100644
--- a/lib/Analysis/LazyValueInfo.cpp
+++ b/lib/Analysis/LazyValueInfo.cpp
@@ -846,6 +846,11 @@ Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) {
if (Result.isConstant())
return Result.getConstant();
+ else if (Result.isConstantRange()) {
+ ConstantRange CR = Result.getConstantRange();
+ if (const APInt *SingleVal = CR.getSingleElement())
+ return ConstantInt::get(V->getContext(), *SingleVal);
+ }
return 0;
}