[llvm] [InstCombine] Fix saturated add canonicalization (PR #97973)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 02:00:20 PDT 2024
================
@@ -996,6 +989,23 @@ static Value *canonicalizeSaturatedAdd(ICmpInst *Cmp, Value *TVal, Value *FVal,
if (!match(TVal, m_AllOnes()))
return nullptr;
+ if (Pred == ICmpInst::ICMP_UGE &&
+ match(FVal, m_Add(m_Value(X), m_APInt(C))) && X == Cmp0 &&
+ match(TVal, m_AllOnes()) && match(Cmp1, m_APInt(CmpC)) && *CmpC == ~*C) {
+ // (X u >= ~C) ? -1 : (X + C) --> uadd.sat(X, C)
----------------
nikic wrote:
```suggestion
// (X u>= ~C) ? -1 : (X + C) --> uadd.sat(X, C)
```
https://github.com/llvm/llvm-project/pull/97973
More information about the llvm-commits
mailing list