summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Analysis/LazyValueInfo.h6
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp16
2 files changed, 22 insertions, 0 deletions
diff --git a/llvm/include/llvm/Analysis/LazyValueInfo.h b/llvm/include/llvm/Analysis/LazyValueInfo.h
index 42002062dca..b51237e82f3 100644
--- a/llvm/include/llvm/Analysis/LazyValueInfo.h
+++ b/llvm/include/llvm/Analysis/LazyValueInfo.h
@@ -20,6 +20,7 @@
namespace llvm {
class AssumptionCache;
class Constant;
+ class ConstantRange;
class DataLayout;
class DominatorTree;
class Instruction;
@@ -65,6 +66,11 @@ public:
/// constant at the end of the specified block. Return null if not.
Constant *getConstant(Value *V, BasicBlock *BB, Instruction *CxtI = nullptr);
+ /// Return the ConstantRange constraint that is known to hold for the
+ /// specified value at the end of the specified block. This may only be called
+ /// on integer-typed Values.
+ ConstantRange getConstantRange(Value *V, BasicBlock *BB, Instruction *CxtI = nullptr);
+
/// Determine whether the specified value is known to be a
/// constant on the specified edge. Return null if not.
Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB,
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index cb1ad5e6525..cb26da55c87 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1485,6 +1485,22 @@ Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB,
return nullptr;
}
+ConstantRange LazyValueInfo::getConstantRange(Value *V, BasicBlock *BB,
+ Instruction *CxtI) {
+ assert(V->getType()->isIntegerTy());
+ unsigned Width = V->getType()->getIntegerBitWidth();
+ const DataLayout &DL = BB->getModule()->getDataLayout();
+ LVILatticeVal Result =
+ getCache(PImpl, AC, &DL, DT).getValueInBlock(V, BB, CxtI);
+ assert(!Result.isConstant());
+ if (Result.isUndefined())
+ return ConstantRange(Width, /*isFullSet=*/false);
+ if (Result.isConstantRange())
+ return Result.getConstantRange();
+ else
+ return ConstantRange(Width, /*isFullSet=*/true);
+}
+
/// Determine whether the specified value is known to be a
/// constant on the specified edge. Return null if not.
Constant *LazyValueInfo::getConstantOnEdge(Value *V, BasicBlock *FromBB,
OpenPOWER on IntegriCloud