[llvm] [InstCombine] Loosen one-use restriction if common operand is constant (PR #79767)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 08:57:08 PST 2024
================
@@ -4851,6 +4850,16 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
}
}
+ // (A | B) ^ (A | C) --> (B ^ C) & ~A -- There are 4 commuted variants.
+ // We do this if common operand is a constant.
+ if (match(Op0, m_c_Or(m_Value(A), m_Value(B))) &&
+ match(Op1, m_c_Or(m_Specific(A), m_Value(C)))) {
+ if (match(A, m_ImmConstant())) {
+ Value *NotA = Builder.CreateNot(A);
+ return BinaryOperator::CreateAnd(Builder.CreateXor(B, C), NotA);
----------------
nikic wrote:
It's not possible to remove one-use entirely. This may replace one instruction with two instructions.
https://github.com/llvm/llvm-project/pull/79767
More information about the llvm-commits
mailing list