From ee61fcf98bb84e7e9f3450035bef92c4d087c0ae Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 27 Aug 2010 23:29:38 +0000 Subject: Improve the precision of getConstant(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112323 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/LazyValueInfo.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/Analysis/LazyValueInfo.cpp') diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp index 7e00f14..e7929f3 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; } -- cgit v1.1