[llvm] 257eda0 - [NFC][LVI] getPredicateAt(): drop default value for UseBlockValue
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 10 10:46:39 PDT 2021
Author: Roman Lebedev
Date: 2021-04-10T20:46:01+03:00
New Revision: 257eda07940d8e6d46dbb5944589a0186e07c6e9
URL: https://github.com/llvm/llvm-project/commit/257eda07940d8e6d46dbb5944589a0186e07c6e9
DIFF: https://github.com/llvm/llvm-project/commit/257eda07940d8e6d46dbb5944589a0186e07c6e9.diff
LOG: [NFC][LVI] getPredicateAt(): drop default value for UseBlockValue
The default is likely wrong.
Out of all the callees, only a single one needs to pass-in false (JumpThread),
everything else either already passes true, or should pass true.
Until the default is flipped, at least make it harder to unintentionally
add new callees with UseBlockValue=false.
Added:
Modified:
llvm/include/llvm/Analysis/LazyValueInfo.h
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
llvm/lib/Transforms/Scalar/JumpThreading.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/LazyValueInfo.h b/llvm/include/llvm/Analysis/LazyValueInfo.h
index 363cb49af382..d5a407352284 100644
--- a/llvm/include/llvm/Analysis/LazyValueInfo.h
+++ b/llvm/include/llvm/Analysis/LazyValueInfo.h
@@ -75,7 +75,7 @@ class LazyValueInfo {
/// \p Pred is a CmpInst predicate. If \p UseBlockValue is true, the block
/// value is also taken into account.
Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C,
- Instruction *CxtI, bool UseBlockValue = false);
+ Instruction *CxtI, bool UseBlockValue);
/// Determine whether the specified value is known to be a constant at the
/// specified instruction. Return null if not.
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
index e84f6eb63da5..9a62f2f6641a 100644
--- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -597,8 +597,8 @@ static bool processCallSite(CallBase &CB, LazyValueInfo *LVI) {
if (Type && !CB.paramHasAttr(ArgNo, Attribute::NonNull) &&
!isa<Constant>(V) &&
LVI->getPredicateAt(ICmpInst::ICMP_EQ, V,
- ConstantPointerNull::get(Type),
- &CB) == LazyValueInfo::False)
+ ConstantPointerNull::get(Type), &CB,
+ /*UseBlockValue=*/false) == LazyValueInfo::False)
ArgNos.push_back(ArgNo);
ArgNo++;
}
@@ -619,13 +619,15 @@ static bool processCallSite(CallBase &CB, LazyValueInfo *LVI) {
static bool isNonNegative(Value *V, LazyValueInfo *LVI, Instruction *CxtI) {
Constant *Zero = ConstantInt::get(V->getType(), 0);
- auto Result = LVI->getPredicateAt(ICmpInst::ICMP_SGE, V, Zero, CxtI);
+ auto Result = LVI->getPredicateAt(ICmpInst::ICMP_SGE, V, Zero, CxtI,
+ /*UseBlockValue=*/false);
return Result == LazyValueInfo::True;
}
static bool isNonPositive(Value *V, LazyValueInfo *LVI, Instruction *CxtI) {
Constant *Zero = ConstantInt::get(V->getType(), 0);
- auto Result = LVI->getPredicateAt(ICmpInst::ICMP_SLE, V, Zero, CxtI);
+ auto Result = LVI->getPredicateAt(ICmpInst::ICMP_SLE, V, Zero, CxtI,
+ /*UseBlockValue=*/false);
return Result == LazyValueInfo::True;
}
@@ -975,8 +977,8 @@ static Constant *getConstantAt(Value *V, Instruction *At, LazyValueInfo *LVI) {
Constant *Op1 = dyn_cast<Constant>(C->getOperand(1));
if (!Op1) return nullptr;
- LazyValueInfo::Tristate Result =
- LVI->getPredicateAt(C->getPredicate(), Op0, Op1, At);
+ LazyValueInfo::Tristate Result = LVI->getPredicateAt(
+ C->getPredicate(), Op0, Op1, At, /*UseBlockValue=*/false);
if (Result == LazyValueInfo::Unknown)
return nullptr;
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index e4852958703a..92b33f08e6fc 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -1155,8 +1155,8 @@ bool JumpThreadingPass::processBlock(BasicBlock *BB) {
assert(CondBr->isConditional() && "Threading on unconditional terminator");
LazyValueInfo::Tristate Ret =
- LVI->getPredicateAt(CondCmp->getPredicate(), CondCmp->getOperand(0),
- CondConst, CondBr);
+ LVI->getPredicateAt(CondCmp->getPredicate(), CondCmp->getOperand(0),
+ CondConst, CondBr, /*UseBlockValue=*/false);
if (Ret != LazyValueInfo::Unknown) {
unsigned ToRemove = Ret == LazyValueInfo::True ? 1 : 0;
unsigned ToKeep = Ret == LazyValueInfo::True ? 0 : 1;
More information about the llvm-commits
mailing list