diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-07-03 13:26:02 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-07-03 13:26:02 +0000 |
| commit | 42396ae0ea555bbea240b5b7d8f57a6730d282d4 (patch) | |
| tree | 3c893a05d721d114bbc476b2720cc4ec306e9037 /llvm | |
| parent | 7c2fbdc101d8acfdc9b8742e758f5a9c22e96920 (diff) | |
| download | bcm5719-llvm-42396ae0ea555bbea240b5b7d8f57a6730d282d4.tar.gz bcm5719-llvm-42396ae0ea555bbea240b5b7d8f57a6730d282d4.zip | |
add vector bool select tests and regenerate checks for scalar bool select tests
llvm-svn: 274460
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/select.ll | 198 |
1 files changed, 139 insertions, 59 deletions
diff --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll index 00b474231be..180fe03c327 100644 --- a/llvm/test/Transforms/InstCombine/select.ll +++ b/llvm/test/Transforms/InstCombine/select.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -S | FileCheck %s -; This test makes sure that these instructions are properly eliminated. + ; PR1822 target datalayout = "e-p:64:64-p1:16:16-p2:32:32:32-p3:64:64:64" @@ -54,41 +54,157 @@ define i32 @test6(i1 %C) { } define i1 @test7(i1 %C, i1 %X) { - ; R = or C, X - %R = select i1 %C, i1 true, i1 %X - ret i1 %R ; CHECK-LABEL: @test7( -; CHECK: %R = or i1 %C, %X -; CHECK: ret i1 %R +; CHECK-NEXT: [[R:%.*]] = or i1 %C, %X +; CHECK-NEXT: ret i1 [[R]] +; + %R = select i1 %C, i1 true, i1 %X + ret i1 %R +} + +define <2 x i1> @test7vec(<2 x i1> %C, <2 x i1> %X) { +; CHECK-LABEL: @test7vec( +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> %C, <2 x i1> <i1 true, i1 true>, <2 x i1> %X +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %R = select <2 x i1> %C, <2 x i1> <i1 true, i1 true>, <2 x i1> %X + ret <2 x i1> %R } define i1 @test8(i1 %C, i1 %X) { - ; R = and C, X - %R = select i1 %C, i1 %X, i1 false - ret i1 %R ; CHECK-LABEL: @test8( -; CHECK: %R = and i1 %C, %X -; CHECK: ret i1 %R +; CHECK-NEXT: [[R:%.*]] = and i1 %C, %X +; CHECK-NEXT: ret i1 [[R]] +; + %R = select i1 %C, i1 %X, i1 false + ret i1 %R +} + +define <2 x i1> @test8vec(<2 x i1> %C, <2 x i1> %X) { +; CHECK-LABEL: @test8vec( +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> %C, <2 x i1> %X, <2 x i1> zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %R = select <2 x i1> %C, <2 x i1> %X, <2 x i1> <i1 false, i1 false> + ret <2 x i1> %R } define i1 @test9(i1 %C, i1 %X) { - ; R = and !C, X - %R = select i1 %C, i1 false, i1 %X - ret i1 %R ; CHECK-LABEL: @test9( -; CHECK: xor i1 %C, true -; CHECK: %R = and i1 -; CHECK: ret i1 %R +; CHECK-NEXT: [[NOT_C:%.*]] = xor i1 %C, true +; CHECK-NEXT: [[R:%.*]] = and i1 [[NOT_C]], %X +; CHECK-NEXT: ret i1 [[R]] +; + %R = select i1 %C, i1 false, i1 %X + ret i1 %R +} + +define <2 x i1> @test9vec(<2 x i1> %C, <2 x i1> %X) { +; CHECK-LABEL: @test9vec( +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> %C, <2 x i1> zeroinitializer, <2 x i1> %X +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %R = select <2 x i1> %C, <2 x i1> <i1 false, i1 false>, <2 x i1> %X + ret <2 x i1> %R } define i1 @test10(i1 %C, i1 %X) { - ; R = or !C, X - %R = select i1 %C, i1 %X, i1 true - ret i1 %R ; CHECK-LABEL: @test10( -; CHECK: xor i1 %C, true -; CHECK: %R = or i1 -; CHECK: ret i1 %R +; CHECK-NEXT: [[NOT_C:%.*]] = xor i1 %C, true +; CHECK-NEXT: [[R:%.*]] = or i1 [[NOT_C]], %X +; CHECK-NEXT: ret i1 [[R]] +; + %R = select i1 %C, i1 %X, i1 true + ret i1 %R +} + +define <2 x i1> @test10vec(<2 x i1> %C, <2 x i1> %X) { +; CHECK-LABEL: @test10vec( +; CHECK-NEXT: [[R:%.*]] = select <2 x i1> %C, <2 x i1> %X, <2 x i1> <i1 true, i1 true> +; CHECK-NEXT: ret <2 x i1> [[R]] +; + %R = select <2 x i1> %C, <2 x i1> %X, <2 x i1> <i1 true, i1 true> + ret <2 x i1> %R +} + +define i1 @test23(i1 %a, i1 %b) { +; CHECK-LABEL: @test23( +; CHECK-NEXT: [[C:%.*]] = and i1 %a, %b +; CHECK-NEXT: ret i1 [[C]] +; + %c = select i1 %a, i1 %b, i1 %a + ret i1 %c +} + +define <2 x i1> @test23vec(<2 x i1> %a, <2 x i1> %b) { +; CHECK-LABEL: @test23vec( +; CHECK-NEXT: [[C:%.*]] = select <2 x i1> %a, <2 x i1> %b, <2 x i1> %a +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %c = select <2 x i1> %a, <2 x i1> %b, <2 x i1> %a + ret <2 x i1> %c +} + +define i1 @test24(i1 %a, i1 %b) { +; CHECK-LABEL: @test24( +; CHECK-NEXT: [[C:%.*]] = or i1 %a, %b +; CHECK-NEXT: ret i1 [[C]] +; + %c = select i1 %a, i1 %a, i1 %b + ret i1 %c +} + +define <2 x i1> @test24vec(<2 x i1> %a, <2 x i1> %b) { +; CHECK-LABEL: @test24vec( +; CHECK-NEXT: [[C:%.*]] = select <2 x i1> %a, <2 x i1> %a, <2 x i1> %b +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %c = select <2 x i1> %a, <2 x i1> %a, <2 x i1> %b + ret <2 x i1> %c +} + +define i1 @test62(i1 %A, i1 %B) { +; CHECK-LABEL: @test62( +; CHECK-NEXT: [[NOT:%.*]] = xor i1 %A, true +; CHECK-NEXT: [[C:%.*]] = and i1 [[NOT]], %B +; CHECK-NEXT: ret i1 [[C]] +; + %not = xor i1 %A, true + %C = select i1 %A, i1 %not, i1 %B + ret i1 %C +} + +define <2 x i1> @test62vec(<2 x i1> %A, <2 x i1> %B) { +; CHECK-LABEL: @test62vec( +; CHECK-NEXT: [[NOT:%.*]] = xor <2 x i1> %A, <i1 true, i1 true> +; CHECK-NEXT: [[C:%.*]] = select <2 x i1> %A, <2 x i1> [[NOT]], <2 x i1> %B +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %not = xor <2 x i1> %A, <i1 true, i1 true> + %C = select <2 x i1> %A, <2 x i1> %not, <2 x i1> %B + ret <2 x i1> %C +} + +define i1 @test63(i1 %A, i1 %B) { +; CHECK-LABEL: @test63( +; CHECK-NEXT: [[NOT:%.*]] = xor i1 %A, true +; CHECK-NEXT: [[C:%.*]] = or i1 %B, [[NOT]] +; CHECK-NEXT: ret i1 [[C]] +; + %not = xor i1 %A, true + %C = select i1 %A, i1 %B, i1 %not + ret i1 %C +} + +define <2 x i1> @test63vec(<2 x i1> %A, <2 x i1> %B) { +; CHECK-LABEL: @test63vec( +; CHECK-NEXT: [[NOT:%.*]] = xor <2 x i1> %A, <i1 true, i1 true> +; CHECK-NEXT: [[C:%.*]] = select <2 x i1> %A, <2 x i1> %B, <2 x i1> [[NOT]] +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %not = xor <2 x i1> %A, <i1 true, i1 true> + %C = select <2 x i1> %A, <2 x i1> %B, <2 x i1> %not + ret <2 x i1> %C } define i32 @test11(i32 %a) { @@ -386,22 +502,6 @@ define i16 @test22(i32 %x) { ; CHECK-NEXT: ret i16 } -define i1 @test23(i1 %a, i1 %b) { - %c = select i1 %a, i1 %b, i1 %a - ret i1 %c -; CHECK-LABEL: @test23( -; CHECK-NEXT: %c = and i1 %a, %b -; CHECK-NEXT: ret i1 %c -} - -define i1 @test24(i1 %a, i1 %b) { - %c = select i1 %a, i1 %a, i1 %b - ret i1 %c -; CHECK-LABEL: @test24( -; CHECK-NEXT: %c = or i1 %a, %b -; CHECK-NEXT: ret i1 %c -} - define i32 @test25(i1 %c) { entry: br i1 %c, label %jump, label %ret @@ -878,26 +978,6 @@ define i32 @test61(i32* %ptr) { ; CHECK: ret i32 10 } -define i1 @test62(i1 %A, i1 %B) { - %not = xor i1 %A, true - %C = select i1 %A, i1 %not, i1 %B - ret i1 %C -; CHECK-LABEL: @test62( -; CHECK: %not = xor i1 %A, true -; CHECK: %C = and i1 %not, %B -; CHECK: ret i1 %C -} - -define i1 @test63(i1 %A, i1 %B) { - %not = xor i1 %A, true - %C = select i1 %A, i1 %B, i1 %not - ret i1 %C -; CHECK-LABEL: @test63( -; CHECK: %not = xor i1 %A, true -; CHECK: %C = or i1 %B, %not -; CHECK: ret i1 %C -} - ; PR14131 define void @test64(i32 %p, i16 %b) noreturn nounwind { entry: |

