[llvm] [InstCombine] Canonicalize (a + 1 == 0) ? -1 : a + 1 -> uadd.sat(a, 1) (PR #144566)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 12:55:04 PDT 2025


AZero13 wrote:

> InstCombinerImpl::foldICmpBinOpEqualityWithConstant

Oh I did a different thing: 


  // (X + C1) == C) --> X == C - C1
  // (X + C1) != C) --> X != C - C1
  Constant *C1;
  if (Cmp.isEquality() && match(Y, m_ImmConstant(C1))) {
    return new ICmpInst(Pred, Y,
                        ConstantExpr::getSub(ConstantInt::get(Ty, C), C1));
  }
  
  

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


More information about the llvm-commits mailing list