mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
InstCombine: ((A | ~B) ^ (~A | B)) to A ^ B
Proof using CVC3 follows: $ cat t.cvc A, B : BITVECTOR(32); QUERY BVXOR((A | ~B),(~A |B)) = BVXOR(A,B); $ cvc3 t.cvc Valid. Patch by Mayur Pandey! Differential Revision: http://reviews.llvm.org/D4883 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215621 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8c651f5c26
commit
eb323b2b3c
@ -2512,6 +2512,16 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
||||
if ((A == C && B == D) || (A == D && B == C))
|
||||
return BinaryOperator::CreateXor(A, B);
|
||||
}
|
||||
// (A | ~B) ^ (~A | B) -> A ^ B
|
||||
if (match(Op0I, m_Or(m_Value(A), m_Not(m_Value(B)))) &&
|
||||
match(Op1I, m_Or(m_Not(m_Specific(A)), m_Specific(B)))) {
|
||||
return BinaryOperator::CreateXor(A, B);
|
||||
}
|
||||
// (~A | B) ^ (A | ~B) -> A ^ B
|
||||
if (match(Op0I, m_Or(m_Not(m_Value(A)), m_Value(B))) &&
|
||||
match(Op1I, m_Or(m_Specific(A), m_Not(m_Specific(B))))) {
|
||||
return BinaryOperator::CreateXor(A, B);
|
||||
}
|
||||
// (A ^ B)^(A | B) -> A & B
|
||||
if (match(Op0I, m_Xor(m_Value(A), m_Value(B))) &&
|
||||
match(Op1I, m_Or(m_Value(C), m_Value(D)))) {
|
||||
|
@ -147,3 +147,16 @@ define i32 @test15(i32 %x, i32 %y) {
|
||||
; CHECK-NEXT: %1 = and i32 %y, %x
|
||||
; CHECK-NEXT: ret i32 %1
|
||||
}
|
||||
|
||||
; ((x | ~y) ^ (~x | y)) -> x ^ y
|
||||
define i32 @test16(i32 %x, i32 %y) {
|
||||
%noty = xor i32 %y, -1
|
||||
%notx = xor i32 %x, -1
|
||||
%or1 = or i32 %x, %noty
|
||||
%or2 = or i32 %notx, %y
|
||||
%xor = xor i32 %or1, %or2
|
||||
ret i32 %xor
|
||||
; CHECK-LABEL: @test16(
|
||||
; CHECK-NEXT: %xor = xor i32 %x, %y
|
||||
; CHECK-NEXT: ret i32 %xor
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user