[llvm] d6e8f3b - [ValueTracking] Convert isKnownPositive() to use SimplifyQuery (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 02:08:48 PST 2023
Author: Nikita Popov
Date: 2023-11-29T11:08:39+01:00
New Revision: d6e8f3b9a23475e0da6ebbfd6950c6b8c8bd20c0
URL: https://github.com/llvm/llvm-project/commit/d6e8f3b9a23475e0da6ebbfd6950c6b8c8bd20c0
DIFF: https://github.com/llvm/llvm-project/commit/d6e8f3b9a23475e0da6ebbfd6950c6b8c8bd20c0.diff
LOG: [ValueTracking] Convert isKnownPositive() to use SimplifyQuery (NFC)
Added:
Modified:
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 4670f42db0c3b34..cd90ad470342cc9 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -143,11 +143,8 @@ bool isKnownNonNegative(const Value *V, const SimplifyQuery &SQ,
/// Returns true if the given value is known be positive (i.e. non-negative
/// and non-zero).
-bool isKnownPositive(const Value *V, const DataLayout &DL, unsigned Depth = 0,
- AssumptionCache *AC = nullptr,
- const Instruction *CxtI = nullptr,
- const DominatorTree *DT = nullptr,
- bool UseInstrInfo = true);
+bool isKnownPositive(const Value *V, const SimplifyQuery &SQ,
+ unsigned Depth = 0);
/// Returns true if the given value is known be negative (i.e. non-positive
/// and non-zero).
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1bd6f06a49c973b..e626dacb28d0bc5 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -281,17 +281,14 @@ bool llvm::isKnownNonNegative(const Value *V, const SimplifyQuery &SQ,
return computeKnownBits(V, Depth, SQ).isNonNegative();
}
-bool llvm::isKnownPositive(const Value *V, const DataLayout &DL, unsigned Depth,
- AssumptionCache *AC, const Instruction *CxtI,
- const DominatorTree *DT, bool UseInstrInfo) {
+bool llvm::isKnownPositive(const Value *V, const SimplifyQuery &SQ,
+ unsigned Depth) {
if (auto *CI = dyn_cast<ConstantInt>(V))
return CI->getValue().isStrictlyPositive();
// TODO: We'd doing two recursive queries here. We should factor this such
// that only a single query is needed.
- return isKnownNonNegative(V, SimplifyQuery(DL, DT, AC, CxtI, UseInstrInfo),
- Depth) &&
- isKnownNonZero(V, DL, Depth, AC, CxtI, DT, UseInstrInfo);
+ return isKnownNonNegative(V, SQ, Depth) && ::isKnownNonZero(V, Depth, SQ);
}
bool llvm::isKnownNegative(const Value *V, const DataLayout &DL, unsigned Depth,
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 69b96445c76e9fb..1d09d9b44a9e58f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1202,9 +1202,9 @@ Instruction *InstCombinerImpl::foldICmpWithZero(ICmpInst &Cmp) {
if (Pred == ICmpInst::ICMP_SGT) {
Value *A, *B;
if (match(Cmp.getOperand(0), m_SMin(m_Value(A), m_Value(B)))) {
- if (isKnownPositive(A, DL, 0, &AC, &Cmp, &DT))
+ if (isKnownPositive(A, SQ.getWithInstruction(&Cmp)))
return new ICmpInst(Pred, B, Cmp.getOperand(1));
- if (isKnownPositive(B, DL, 0, &AC, &Cmp, &DT))
+ if (isKnownPositive(B, SQ.getWithInstruction(&Cmp)))
return new ICmpInst(Pred, A, Cmp.getOperand(1));
}
}
More information about the llvm-commits
mailing list