From c1eaf3a1f1a86681661050ac8999aab9a7eaa1a2 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 4 Apr 2017 17:48:08 +0000 Subject: [PATCH] [InstCombine] Add more test cases for missing combines of selects with and/or/xor with constant argument. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299450 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/InstCombine/and.ll | 31 ++++++++++++++++++++++++++++++ test/Transforms/InstCombine/or.ll | 11 +++++++++++ test/Transforms/InstCombine/xor.ll | 11 +++++++++++ 3 files changed, 53 insertions(+) diff --git a/test/Transforms/InstCombine/and.ll b/test/Transforms/InstCombine/and.ll index b433574974a..9a23342feb1 100644 --- a/test/Transforms/InstCombine/and.ll +++ b/test/Transforms/InstCombine/and.ll @@ -494,3 +494,34 @@ define i64 @test39(i32 %X) { %res = and i64 %zsub, 240 ret i64 %res } + +define i32 @test40(i1 %C) { +; CHECK-LABEL: @test40( +; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], i32 104, i32 10 +; CHECK-NEXT: ret i32 [[A]] +; + %A = select i1 %C, i32 1000, i32 10 + %V = and i32 %A, 123 + ret i32 %V +} + +define <2 x i32> @test40vec(i1 %C) { +; CHECK-LABEL: @test40vec( +; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> +; CHECK-NEXT: ret <2 x i32> [[A]] +; + %A = select i1 %C, <2 x i32> , <2 x i32> + %V = and <2 x i32> %A, + ret <2 x i32> %V +} + +define <2 x i32> @test40vec2(i1 %C) { +; CHECK-LABEL: @test40vec2( +; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> +; CHECK-NEXT: [[V:%.*]] = and <2 x i32> [[A]], +; CHECK-NEXT: ret <2 x i32> [[V]] +; + %A = select i1 %C, <2 x i32> , <2 x i32> + %V = and <2 x i32> %A, + ret <2 x i32> %V +} diff --git a/test/Transforms/InstCombine/or.ll b/test/Transforms/InstCombine/or.ll index 2ca3997d135..24431095b36 100644 --- a/test/Transforms/InstCombine/or.ll +++ b/test/Transforms/InstCombine/or.ll @@ -722,3 +722,14 @@ define <2 x i32> @test49vec(i1 %C) { %V = or <2 x i32> %A, ret <2 x i32> %V } + +define <2 x i32> @test49vec2(i1 %C) { +; CHECK-LABEL: @test49vec2( +; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> +; CHECK-NEXT: [[V:%.*]] = or <2 x i32> [[A]], +; CHECK-NEXT: ret <2 x i32> [[V]] +; + %A = select i1 %C, <2 x i32> , <2 x i32> + %V = or <2 x i32> %A, + ret <2 x i32> %V +} diff --git a/test/Transforms/InstCombine/xor.ll b/test/Transforms/InstCombine/xor.ll index 374361030f2..444dfd1d29f 100644 --- a/test/Transforms/InstCombine/xor.ll +++ b/test/Transforms/InstCombine/xor.ll @@ -373,3 +373,14 @@ define <2 x i32> @test29vec(i1 %C) { %V = xor <2 x i32> %A, ret <2 x i32> %V } + +define <2 x i32> @test29vec2(i1 %C) { +; CHECK-LABEL: @test29vec2( +; CHECK-NEXT: [[A:%.*]] = select i1 [[C:%.*]], <2 x i32> , <2 x i32> +; CHECK-NEXT: [[V:%.*]] = xor <2 x i32> [[A]], +; CHECK-NEXT: ret <2 x i32> [[V]] +; + %A = select i1 %C, <2 x i32> , <2 x i32> + %V = xor <2 x i32> %A, + ret <2 x i32> %V +} -- 2.40.0