[llvm] [InstCombine] Canonicalize more saturated-add variants (PR #100008)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 13:48:15 PDT 2024
================
@@ -996,6 +989,30 @@ static Value *canonicalizeSaturatedAdd(ICmpInst *Cmp, Value *TVal, Value *FVal,
if (!match(TVal, m_AllOnes()))
return nullptr;
+ if ((Pred == ICmpInst::ICMP_UGE || Pred == ICmpInst::ICMP_UGT) &&
+ match(FVal, m_Add(m_Specific(Cmp0), m_APIntAllowPoison(C))) &&
+ match(Cmp1, m_SpecificIntAllowPoison(~*C))) {
+ // (X u> ~C) ? -1 : (X + C) --> uadd.sat(X, C)
----------------
topperc wrote:
need a comment for `(X u>= ~C) ? -1 : (X + C) --> uadd.sat(X, C)` too
https://github.com/llvm/llvm-project/pull/100008
More information about the llvm-commits
mailing list