[llvm] [InstCombine] Fold Xor with or disjoint (PR #105992)
Amr Hesham via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 21:51:55 PDT 2024
================
@@ -4693,7 +4693,21 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
// calls in there are unnecessary as SimplifyDemandedInstructionBits should
// have already taken care of those cases.
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- Value *M;
+ Value *X, *Y, *M;
+
+ // (A | B) ^ C -> (A ^ C) ^ B
+ // C ^ (A | B) -> B ^ (A ^ C)
+ if (match(&I, m_c_Xor(m_OneUse(m_c_DisjointOr(m_Value(X), m_Value(Y))),
+ m_Value(M)))) {
+ if (Value *XorAC = simplifyBinOp(Instruction::Xor, X, M, SQ)) {
----------------
AmrDeveloper wrote:
Thank you, Done
https://github.com/llvm/llvm-project/pull/105992
More information about the llvm-commits
mailing list