From ae892fe4466357d451caf353643dac7d56e84c40 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 7 Apr 2017 07:31:55 +0000 Subject: [PATCH] [InstCombine] Add additional tests with varied commuting to show missing combines. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299746 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/or.ll | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll index a83ee242b3f..57ceff27053 100644 --- a/test/Transforms/InstCombine/or.ll +++ b/test/Transforms/InstCombine/or.ll @@ -542,6 +542,44 @@ define i32 @test40(i32 %a, i32 %b) { ret i32 %or } +define i32 @test40b(i32 %a, i32 %b) { +; CHECK-LABEL: @test40b( +; CHECK-NEXT: [[AND:%.*]] = and i32 %b, %a +; CHECK-NEXT: [[XOR:%.*]] = xor i32 %a, -1 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[XOR]] +; CHECK-NEXT: ret i32 [[OR]] +; + %and = and i32 %b, %a + %xor = xor i32 %a, -1 + %or = or i32 %and, %xor + ret i32 %or +} + +define i32 @test40c(i32 %a, i32 %b) { +; CHECK-LABEL: @test40c( +; CHECK-NEXT: [[AND:%.*]] = and i32 %b, %a +; CHECK-NEXT: [[XOR:%.*]] = xor i32 %a, -1 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[XOR]] +; CHECK-NEXT: ret i32 [[OR]] +; + %and = and i32 %b, %a + %xor = xor i32 %a, -1 + %or = or i32 %xor, %and + ret i32 %or +} + +define i32 @test40d(i32 %a, i32 %b) { +; CHECK-LABEL: @test40d( +; CHECK-NEXT: [[XOR:%.*]] = xor i32 %a, -1 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR]], %b +; CHECK-NEXT: ret i32 [[OR]] +; + %and = and i32 %a, %b + %xor = xor i32 %a, -1 + %or = or i32 %xor, %and + ret i32 %or +} + define i32 @test41(i32 %a, i32 %b) { ; CHECK-LABEL: @test41( ; CHECK-NEXT: [[TMP1:%.*]] = xor i32 %a, -1 -- 2.40.0