[llvm] [ValueTracking] Infer relationship for the select with ICmp (PR #66668)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 21:36:59 PDT 2024
================
@@ -8332,6 +8332,18 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
if (areMatchingOperands(L0, L1, R0, R1, AreSwappedOps))
return isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps);
+ // Take SGT as an example: x > y and C <= 0 ==> x -nsw y < C is false
+ Value *X, *Y;
+ if (((LPred == ICmpInst::ICMP_SGT || LPred == ICmpInst::ICMP_SGE) &&
+ match(R0, m_NSWSub(m_Value(X), m_Value(Y)))) ||
+ ((LPred == ICmpInst::ICMP_UGT || LPred == ICmpInst::ICMP_UGE) &&
+ match(R0, m_NUWSub(m_Value(X), m_Value(Y))))) {
+ if (match(R1, m_NonPositive()) &&
+ areMatchingOperands(L0, L1, X, Y, AreSwappedOps) &&
+ isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps) == false)
+ return false;
----------------
vfdff wrote:
Ok, thanks for your idea, I'll address that with a separate PR later, and this PR is just intend to fix [#54735](https://github.com/llvm/llvm-project/issues/54735)
https://github.com/llvm/llvm-project/pull/66668
More information about the llvm-commits
mailing list