From e063ddb3470d482a3dae086ce1d11f562e5e8e2e Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Fri, 22 Jul 2016 22:19:52 +0000 Subject: [PATCH] add tests for icmp vector folds llvm-svn: 276482 --- llvm/test/Transforms/InstCombine/and.ll | 24 ++++++++++++++++++++++++ llvm/test/Transforms/InstCombine/icmp.ll | 27 ++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll index 43b80e3..9a6ae74 100644 --- a/llvm/test/Transforms/InstCombine/and.ll +++ b/llvm/test/Transforms/InstCombine/and.ll @@ -196,6 +196,18 @@ define i1 @test18(i32 %A) { ret i1 %C } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test18_vec(<2 x i32> %A) { +; CHECK-LABEL: @test18_vec( +; CHECK-NEXT: [[B:%.*]] = and <2 x i32> %A, +; CHECK-NEXT: [[C:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %B = and <2 x i32> %A, + %C = icmp ne <2 x i32> %B, zeroinitializer + ret <2 x i1> %C +} + define i1 @test18a(i8 %A) { ; CHECK-LABEL: @test18a( ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 %A, 2 @@ -206,6 +218,18 @@ define i1 @test18a(i8 %A) { ret i1 %C } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test18a_vec(<2 x i8> %A) { +; CHECK-LABEL: @test18a_vec( +; CHECK-NEXT: [[B:%.*]] = and <2 x i8> %A, +; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i8> [[B]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[C]] +; + %B = and <2 x i8> %A, + %C = icmp eq <2 x i8> %B, zeroinitializer + ret <2 x i1> %C +} + define i32 @test19(i32 %A) { ; CHECK-LABEL: @test19( ; CHECK-NEXT: [[B:%.*]] = shl i32 %A, 3 diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 326e24f9..cefe45c 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -193,7 +193,7 @@ define i1 @test18(i32 %x) nounwind { ret i1 %cmp } -define i1 @test19(i32 %x) nounwind { +define i1 @test19(i32 %x) { ; CHECK-LABEL: @test19( ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %x, 3 ; CHECK-NEXT: ret i1 [[CMP]] @@ -204,6 +204,31 @@ define i1 @test19(i32 %x) nounwind { ret i1 %cmp } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test19vec(<2 x i32> %x) { +; CHECK-LABEL: @test19vec( +; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> , %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SHL]], +; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[AND]], +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %shl = shl <2 x i32> , %x + %and = and <2 x i32> %shl, + %cmp = icmp eq <2 x i32> %and, + ret <2 x i1> %cmp +} + +define <2 x i1> @cmp_and_signbit_vec(<2 x i3> %x) { +; CHECK-LABEL: @cmp_and_signbit_vec( +; CHECK-NEXT: [[AND:%.*]] = and <2 x i3> %x, +; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i3> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %and = and <2 x i3> %x, + %cmp = icmp ne <2 x i3> %and, zeroinitializer + ret <2 x i1> %cmp +} + define i1 @test20(i32 %x) nounwind { ; CHECK-LABEL: @test20( ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %x, 3 -- 2.7.4