Index: lib/Analysis/InstructionSimplify.cpp =================================================================== --- lib/Analysis/InstructionSimplify.cpp +++ lib/Analysis/InstructionSimplify.cpp @@ -1603,6 +1603,11 @@ (A == Op0 || B == Op0)) return Constant::getAllOnesValue(Op0->getType()); + // (A^B) | (~(A)^B) -> 1 + if (match(Op0, m_Xor(m_Value(A), m_Value(B))) && + match(Op1, m_Xor(m_Not(m_Specific(A)), m_Specific(B)))) + return Constant::getAllOnesValue(Op0->getType()); + // Try some generic simplifications for associative operations. if (Value *V = SimplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q, MaxRecurse)) Index: test/Transforms/InstSimplify/AndOrXor.ll =================================================================== --- test/Transforms/InstSimplify/AndOrXor.ll +++ test/Transforms/InstSimplify/AndOrXor.ll @@ -20,3 +20,13 @@ ret i64 %e2 ; CHECK: ret i64 %e } + +define i32 @test(i32 %x, i32 %y) { + ; CHECK-LABEL: @test39( + %xor = xor i32 %x, %y + %nega = xor i32 %x, -1 + %xor1 = xor i32 %nega, %y + %or = or i32 %xor, %xor1 + ret i32 %or +; CHECK: ret i32 -1 +}