[llvm] [InstCombine] Fold (x + y) & (2^C) -> x & 2^C when y % 2^(C+1) == 0 (PR #157072)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 7 07:33:06 PDT 2025
================
@@ -2476,6 +2476,20 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
return SelectInst::Create(Cmp, ConstantInt::getNullValue(Ty), Y);
}
+ // (x + y) & (2^C) -> x & 2^C when y % 2^(C+1) == 0
+ if (match(Op0, m_Add(m_Value(X), m_Value(Y)))) {
----------------
dtcxzyw wrote:
Please add a commuted test (i..e, `(x + y) & (2^C) -> y & 2^C when x % 2^(C+1) == 0`).
https://github.com/llvm/llvm-project/pull/157072
More information about the llvm-commits
mailing list