1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Reapply the "or" half of r108136, which seems to be less problematic.

llvm-svn: 108152
This commit is contained in:
Benjamin Kramer 2010-07-12 16:15:48 +00:00
parent 9f6b0059e4
commit e391789246
2 changed files with 21 additions and 0 deletions

View File

@ -1597,6 +1597,14 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
Instruction *Ret = FoldOrWithConstants(I, Op0, A, V1, D);
if (Ret) return Ret;
}
// (A & ~D) | (B & D) -> ((B ^ A) & D) ^ A
if (Op0->hasOneUse() && Op1->hasOneUse() &&
match(C, m_Not(m_Specific(D)))) {
Value *Xor = Builder->CreateXor(B, A, "xor");
Value *And = Builder->CreateAnd(Xor, D, "and");
return BinaryOperator::CreateXor(And, A);
}
}
// (X >> Z) | (Y >> Z) -> (X|Y) >> Z for all shifts.

View File

@ -350,3 +350,16 @@ define <4 x i32> @test32(<4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32
; CHECK: or <4 x i32> %and.i, %and.i129
}
; PR6773
define i32 @test33(i32 %x, i32 %y, i32 %z) nounwind readnone {
%and = and i32 %y, %x
%not = xor i32 %x, -1
%and2 = and i32 %z, %not
%or = or i32 %and2, %and
ret i32 %or
; CHECK: @test33
; CHECK-NEXT: xor i32
; CHECK-NEXT: and i32
; CHECK-NEXT: xor i32
; CHECK-NEXT: ret i32
}