diff --git a/llvm/test/Transforms/InstCombine/xor2.ll b/llvm/test/Transforms/InstCombine/xor2.ll index 5c209f660ba2..ca93419681af 100644 --- a/llvm/test/Transforms/InstCombine/xor2.ll +++ b/llvm/test/Transforms/InstCombine/xor2.ll @@ -144,6 +144,20 @@ define i32 @test9(i32 %b, i32 %c) { ret i32 %xor2 } +; (A & B) ^ (B ^ A) -> (A | B) +define i32 @test9b(i32 %b, i32 %c) { +; CHECK-LABEL: @test9b( +; CHECK-NEXT: [[AND:%.*]] = and i32 [[B:%.*]], [[C:%.*]] +; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[C]], [[B]] +; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[AND]], [[XOR]] +; CHECK-NEXT: ret i32 [[XOR2]] +; + %and = and i32 %b, %c + %xor = xor i32 %c, %b + %xor2 = xor i32 %and, %xor + ret i32 %xor2 +} + ; (A ^ B) ^ (A & B) -> (A | B) define i32 @test10(i32 %b, i32 %c) { ; CHECK-LABEL: @test10( @@ -156,6 +170,20 @@ define i32 @test10(i32 %b, i32 %c) { ret i32 %xor2 } +; (A ^ B) ^ (A & B) -> (A | B) +define i32 @test10b(i32 %b, i32 %c) { +; CHECK-LABEL: @test10b( +; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[B:%.*]], [[C:%.*]] +; CHECK-NEXT: [[AND:%.*]] = and i32 [[C]], [[B]] +; CHECK-NEXT: [[XOR2:%.*]] = xor i32 [[XOR]], [[AND]] +; CHECK-NEXT: ret i32 [[XOR2]] +; + %xor = xor i32 %b, %c + %and = and i32 %c, %b + %xor2 = xor i32 %xor, %and + ret i32 %xor2 +} + define i32 @test11(i32 %A, i32 %B) { ; CHECK-LABEL: @test11( ; CHECK-NEXT: ret i32 0