aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-12-12 14:26:40 +0100
committerNikita Popov <npopov@redhat.com>2023-12-12 14:29:08 +0100
commitbfebadc8c392fc3bc8cbd54af735a006f50a5d8c (patch)
treea6a8ae7d2a3d80e160e3d24e000478568d0b54fa /llvm/lib/Analysis/LazyValueInfo.cpp
parented4194bb8dbca5222628c2cddbc032fff57193b5 (diff)
downloadllvm-bfebadc8c392fc3bc8cbd54af735a006f50a5d8c.zip
llvm-bfebadc8c392fc3bc8cbd54af735a006f50a5d8c.tar.gz
llvm-bfebadc8c392fc3bc8cbd54af735a006f50a5d8c.tar.bz2
[LVI] Don't require DataLayout in getConstantRangeOrFull() (NFC)
We're only working on integers here, so we don't need DataLayout to determine the width.
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index ec87069..c475321 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -802,10 +802,11 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
}
static ConstantRange getConstantRangeOrFull(const ValueLatticeElement &Val,
- Type *Ty, const DataLayout &DL) {
+ Type *Ty) {
+ assert(Ty->isIntOrIntVectorTy() && "Must be integer type");
if (Val.isConstantRange(/*UndefAllowed*/ false))
return Val.getConstantRange();
- return ConstantRange::getFull(DL.getTypeSizeInBits(Ty));
+ return ConstantRange::getFull(Ty->getScalarSizeInBits());
}
std::optional<ValueLatticeElement>
@@ -825,9 +826,9 @@ LazyValueInfoImpl::solveBlockValueSelect(SelectInst *SI, BasicBlock *BB) {
if (TrueVal.isConstantRange() || FalseVal.isConstantRange()) {
const ConstantRange &TrueCR =
- getConstantRangeOrFull(TrueVal, SI->getType(), DL);
+ getConstantRangeOrFull(TrueVal, SI->getType());
const ConstantRange &FalseCR =
- getConstantRangeOrFull(FalseVal, SI->getType(), DL);
+ getConstantRangeOrFull(FalseVal, SI->getType());
Value *LHS = nullptr;
Value *RHS = nullptr;
SelectPatternResult SPR = matchSelectPattern(SI, LHS, RHS);
@@ -898,7 +899,7 @@ LazyValueInfoImpl::getRangeFor(Value *V, Instruction *CxtI, BasicBlock *BB) {
std::optional<ValueLatticeElement> OptVal = getBlockValue(V, BB, CxtI);
if (!OptVal)
return std::nullopt;
- return getConstantRangeOrFull(*OptVal, V->getType(), DL);
+ return getConstantRangeOrFull(*OptVal, V->getType());
}
std::optional<ValueLatticeElement>