From 9eac2717c65864f60b0da53d20a4912b557e8188 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 11 Apr 2017 18:50:48 +0000 Subject: [PATCH] [InstCombine] Add testcases for (B&A)^A -> ~B & A and (B|A)^A -> B & ~A llvm-svn: 299971 --- llvm/test/Transforms/InstCombine/xor.ll | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/xor.ll b/llvm/test/Transforms/InstCombine/xor.ll index b5fbfab..570155b 100644 --- a/llvm/test/Transforms/InstCombine/xor.ll +++ b/llvm/test/Transforms/InstCombine/xor.ll @@ -448,3 +448,91 @@ final: %value = xor <2 x i32> %A, ret <2 x i32> %value } + +define i32 @test31(i32 %A, i32 %B) { +; CHECK-LABEL: @test31( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = or i32 %A, %B + %xor = xor i32 %B, %and + ret i32 %xor +} + +define i32 @test32(i32 %A, i32 %B) { +; CHECK-LABEL: @test32( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = or i32 %B, %A + %xor = xor i32 %B, %and + ret i32 %xor +} + +define i32 @test33(i32 %A, i32 %B) { +; CHECK-LABEL: @test33( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = or i32 %A, %B + %xor = xor i32 %and, %B + ret i32 %xor +} + +define i32 @test34(i32 %A, i32 %B) { +; CHECK-LABEL: @test34( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[B:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[A:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = or i32 %B, %A + %xor = xor i32 %and, %B + ret i32 %xor +} + +define i32 @test35(i32 %A, i32 %B) { +; CHECK-LABEL: @test35( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = and i32 %A, %B + %xor = xor i32 %B, %and + ret i32 %xor +} + +define i32 @test36(i32 %A, i32 %B) { +; CHECK-LABEL: @test36( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = and i32 %B, %A + %xor = xor i32 %B, %and + ret i32 %xor +} + +define i32 @test37(i32 %A, i32 %B) { +; CHECK-LABEL: @test37( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = and i32 %A, %B + %xor = xor i32 %and, %B + ret i32 %xor +} + +define i32 @test38(i32 %A, i32 %B) { +; CHECK-LABEL: @test38( +; CHECK-NEXT: [[TMP1:%.*]] = xor i32 [[A:%.*]], -1 +; CHECK-NEXT: [[XOR:%.*]] = and i32 [[TMP1]], [[B:%.*]] +; CHECK-NEXT: ret i32 [[XOR]] +; + %and = and i32 %B, %A + %xor = xor i32 %and, %B + ret i32 %xor +} -- 2.7.4