Improve the precision of getConstant().

llvm-svn: 112323
This commit is contained in:
Owen Anderson 2010-08-27 23:29:38 +00:00
parent 13ce07fa92
commit 38f6b7fe3b
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}