[llvm] bc79ed7 - [LVI] Don't require operand number for range (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 25 07:33:54 PDT 2020
Author: Nikita Popov
Date: 2020-07-25T16:33:45+02:00
New Revision: bc79ed7e16003c8550da8710b321d6d5d4243faf
URL: https://github.com/llvm/llvm-project/commit/bc79ed7e16003c8550da8710b321d6d5d4243faf
DIFF: https://github.com/llvm/llvm-project/commit/bc79ed7e16003c8550da8710b321d6d5d4243faf.diff
LOG: [LVI] Don't require operand number for range (NFC)
Pass the Value* instead of the operand number, rename I to CxtI.
This makes the function a bit more generally useful.
Added:
Modified:
llvm/lib/Analysis/LazyValueInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index f5ffa7286b3b..34cc81c4bf2a 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -388,8 +388,8 @@ class LazyValueInfoImpl {
BasicBlock *BB);
Optional<ValueLatticeElement> solveBlockValueSelect(SelectInst *S,
BasicBlock *BB);
- Optional<ConstantRange> getRangeForOperand(unsigned Op, Instruction *I,
- BasicBlock *BB);
+ Optional<ConstantRange> getRangeFor(Value *V, Instruction *CxtI,
+ BasicBlock *BB);
Optional<ValueLatticeElement> solveBlockValueBinaryOpImpl(
Instruction *I, BasicBlock *BB,
std::function<ConstantRange(const ConstantRange &,
@@ -919,20 +919,19 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueSelect(
return Result;
}
-Optional<ConstantRange> LazyValueInfoImpl::getRangeForOperand(unsigned Op,
- Instruction *I,
- BasicBlock *BB) {
- Optional<ValueLatticeElement> OptVal = getBlockValue(I->getOperand(Op), BB);
+Optional<ConstantRange> LazyValueInfoImpl::getRangeFor(Value *V,
+ Instruction *CxtI,
+ BasicBlock *BB) {
+ Optional<ValueLatticeElement> OptVal = getBlockValue(V, BB);
if (!OptVal)
return None;
ValueLatticeElement &Val = *OptVal;
- intersectAssumeOrGuardBlockValueConstantRange(I->getOperand(Op), Val, I);
+ intersectAssumeOrGuardBlockValueConstantRange(V, Val, CxtI);
if (Val.isConstantRange())
return Val.getConstantRange();
- const unsigned OperandBitWidth =
- DL.getTypeSizeInBits(I->getOperand(Op)->getType());
+ const unsigned OperandBitWidth = DL.getTypeSizeInBits(V->getType());
return ConstantRange::getFull(OperandBitWidth);
}
@@ -962,7 +961,7 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueCast(
// Figure out the range of the LHS. If that fails, we still apply the
// transfer rule on the full set since we may be able to locally infer
// interesting facts.
- Optional<ConstantRange> LHSRes = getRangeForOperand(0, CI, BB);
+ Optional<ConstantRange> LHSRes = getRangeFor(CI->getOperand(0), CI, BB);
if (!LHSRes.hasValue())
// More work to do before applying this transfer rule.
return None;
@@ -985,8 +984,8 @@ Optional<ValueLatticeElement> LazyValueInfoImpl::solveBlockValueBinaryOpImpl(
// conservative range, but apply the transfer rule anyways. This
// lets us pick up facts from expressions like "and i32 (call i32
// @foo()), 32"
- Optional<ConstantRange> LHSRes = getRangeForOperand(0, I, BB);
- Optional<ConstantRange> RHSRes = getRangeForOperand(1, I, BB);
+ Optional<ConstantRange> LHSRes = getRangeFor(I->getOperand(0), I, BB);
+ Optional<ConstantRange> RHSRes = getRangeFor(I->getOperand(1), I, BB);
if (!LHSRes.hasValue() || !RHSRes.hasValue())
// More work to do before applying this transfer rule.
return None;
More information about the llvm-commits
mailing list