[llvm] [InstCombine] Fix saturated add canonicalization (PR #97973)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 8 02:00:21 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 &&
----------------
nikic wrote:

```suggestion
      match(FVal, m_Add(m_Specific(Cmp0), m_APInt(C))) &&
```

https://github.com/llvm/llvm-project/pull/97973


More information about the llvm-commits mailing list