[llvm] bfebadc - [LVI] Don't require DataLayout in getConstantRangeOrFull() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 05:29:16 PST 2023


Author: Nikita Popov
Date: 2023-12-12T14:29:08+01:00
New Revision: bfebadc8c392fc3bc8cbd54af735a006f50a5d8c

URL: https://github.com/llvm/llvm-project/commit/bfebadc8c392fc3bc8cbd54af735a006f50a5d8c
DIFF: https://github.com/llvm/llvm-project/commit/bfebadc8c392fc3bc8cbd54af735a006f50a5d8c.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Analysis/LazyValueInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index ec870694f5b60a..c475321521903c 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>


        


More information about the llvm-commits mailing list