[llvm] [ValueTracking] Infer relationship for the select with ICmp (PR #66668)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 21:28:49 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()) &&
----------------
vfdff wrote:
Thanks, I update the comment, also rebase to top as the upstream has delete the API **areMatchingOperands** since commit 01d8e1ca
https://github.com/llvm/llvm-project/pull/66668
More information about the llvm-commits
mailing list