[llvm] [InstCombine] Fold `A == MIN_INT ? MAX_INT : 0 - A` to `ssub_sat 0, A` (PR #194519)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 07:11:53 PDT 2026
================
@@ -2154,6 +2154,15 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI,
if (Pred == ICmpInst::ICMP_NE)
std::swap(TrueVal, FalseVal);
+ /// `A == MIN_INT ? MAX_INT : 0 - A` --> `ssub_sat 0, A`
+ if (match(CmpRHS, m_MinSignedValue()) && match(TrueVal, m_MaxSignedValue()) &&
+ match(FalseVal, m_Sub(m_ZeroInt(), m_Specific(CmpLHS)))) {
----------------
antoniofrighetto wrote:
```suggestion
match(FalseVal, m_Neg(m_Specific(CmpLHS)))) {
```
https://github.com/llvm/llvm-project/pull/194519
More information about the llvm-commits
mailing list