[llvm] [ValueTracking] Infer relationship for the select with ICmp (PR #66668)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 29 18:49:35 PST 2023
================
@@ -8367,6 +8367,19 @@ 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
+ const APInt *CI;
+ 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_APInt(CI)) && CI->isNonPositive() &&
----------------
vfdff wrote:
Apply your comment, thanks
https://github.com/llvm/llvm-project/pull/66668
More information about the llvm-commits
mailing list