Skip to content

Commit

Permalink
[LVI] Don't require DataLayout in getConstantRangeOrFull() (NFC)
Browse files Browse the repository at this point in the history
We're only working on integers here, so we don't need DataLayout
to determine the width.
  • Loading branch information
nikic committed Dec 12, 2023
1 parent ed4194b commit bfebadc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions llvm/lib/Analysis/LazyValueInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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);
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit bfebadc

Please sign in to comment.