[llvm] [InstCombine] Fold `(add X, (sext/zext (icmp eq X, C)))` (PR #93840)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 1 10:10:10 PDT 2024
================
@@ -1694,6 +1694,26 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
return BinaryOperator::CreateOr(LHS, Zext);
}
+ {
+ Value *Cond, *Ext;
+ Constant *C;
+ // (add X, (sext/zext (icmp eq X, C)))
+ // -> (select (icmp eq X, C), (add C, (sext/zext 1)), X)
+ auto CondMatcher = m_CombineAnd(
+ m_Value(Cond), m_ICmp(Pred, m_Deferred(A), m_ImmConstant(C)));
----------------
goldsteinn wrote:
That will be flakey if `X` itself is a `sext`/`zext` of another value though no?
https://github.com/llvm/llvm-project/pull/93840
More information about the llvm-commits
mailing list