[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:06 PDT 2025
AZero13 wrote:
// Match special-case for increment-by-1.
if (Pred == ICmpInst::ICMP_EQ) {
// (a + 1) == 0
// (1 + a) == 0
if (AddExpr.match(ICmpLHS) && m_ZeroInt().match(ICmpRHS) &&
(m_One().match(AddLHS) || m_One().match(AddRHS)))
return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpLHS);
// 0 == (a + 1)
// 0 == (1 + a)
if (m_ZeroInt().match(ICmpLHS) && AddExpr.match(ICmpRHS) &&
(m_One().match(AddLHS) || m_One().match(AddRHS)))
return L.match(AddLHS) && R.match(AddRHS) && S.match(ICmpRHS);
}
So does this mean I can remove this from UAddWithOverflow_match?
https://github.com/llvm/llvm-project/pull/144566
More information about the llvm-commits
mailing list