[llvm] [InstCombine] Fold comparisons of llvm.usub.sat result with its LHS (PR #214108)
Haram Jeong via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 01:48:30 PDT 2026
================
@@ -7741,6 +7740,24 @@ Instruction *InstCombinerImpl::foldICmpCommutative(CmpPredicate Pred,
}
const SimplifyQuery Q = SQ.getWithInstruction(&CxtI);
+
+ {
+ Value *Y;
+ // For Y != 0:
+ // usub.sat(X, Y) == X --> X == 0
+ // usub.sat(X, Y) != X --> X != 0
+ // usub.sat(X, Y) < X --> X != 0
+ if (match(Op0, m_Intrinsic<Intrinsic::usub_sat>(m_Specific(Op1),
+ m_Value(Y))) &&
----------------
haramj wrote:
Thanks! Updated to use m_NonZeroInt(), so this is now limited to nonzero constant RHS cases.
https://github.com/llvm/llvm-project/pull/214108
More information about the llvm-commits
mailing list