[llvm] [InstSimplify] Simplify the select with integer comparison relationship (PR #66668)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 16 21:24:41 PDT 2023
================
@@ -8285,6 +8285,15 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
if (areMatchingOperands(L0, L1, R0, R1, AreSwappedOps))
return isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps);
+ if (RPred == ICmpInst::ICMP_SLT) {
+ Value *X;
+ Value *Y;
+ // x -nsw y is non-negative when x >= y or negative when x < y
+ if (match(R0, m_NSWSub(m_Value(X), m_Value(Y))) && match(R1, m_AllOnes()) &&
+ areMatchingOperands(L0, L1, X, Y, AreSwappedOps))
+ return isImpliedCondMatchingOperands(LPred, RPred, AreSwappedOps);
----------------
vfdff wrote:
Thanks, now I restrict it `x -nsw y <= -1 <==> x < y`.
And add extra match pattern `x > y and C <= 0 ==> x -nsw y < C is false` to fix #54735
https://github.com/llvm/llvm-project/pull/66668
More information about the llvm-commits
mailing list