[llvm] [InstCombine] Fold Xor with or disjoint (PR #105992)
Amr Hesham via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 2 13:25:23 PDT 2024
================
@@ -4706,6 +4706,15 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
return Xor;
Value *X, *Y;
+
+ // (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)))) {
+ Value *XorAC = Builder.CreateXor(X, M);
+ return BinaryOperator::CreateXor(XorAC, Y);
+ }
----------------
AmrDeveloper wrote:
Now i checked simplify and update samples, this is alive2 for current test depending that A ^ M will folded
https://alive2.llvm.org/ce/z/NLhfhN
https://github.com/llvm/llvm-project/pull/105992
More information about the llvm-commits
mailing list