From: Sanjay Patel Date: Wed, 14 Sep 2016 23:15:11 +0000 (+0000) Subject: [InstCombine] add vector tests for foldICmpUsingKnownBits() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a18aa4cd29c8289bb2cc0f53397e0c22fb3b6e4f;p=llvm [InstCombine] add vector tests for foldICmpUsingKnownBits() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281559 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index f9091a008b1..8a5b97c433c 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -171,6 +171,20 @@ define i1 @test17(i32 %x) { ret i1 %cmp } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test17vec(<2 x i32> %x) { +; CHECK-LABEL: @test17vec( +; 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]], zeroinitializer +; 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, zeroinitializer + ret <2 x i1> %cmp +} + define i1 @test17a(i32 %x) { ; CHECK-LABEL: @test17a( ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 %x, 2 @@ -182,8 +196,22 @@ define i1 @test17a(i32 %x) { ret i1 %cmp } -define i1 @test18(i32 %x) { -; CHECK-LABEL: @test18( +; FIXME: Vectors should fold the same way. +define <2 x i1> @test17a_vec(<2 x i32> %x) { +; CHECK-LABEL: @test17a_vec( +; 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]], zeroinitializer +; 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, zeroinitializer + ret <2 x i1> %cmp +} + +define i1 @test18_eq(i32 %x) { +; CHECK-LABEL: @test18_eq( ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 %x, 3 ; CHECK-NEXT: ret i1 [[CMP]] ; @@ -193,6 +221,45 @@ define i1 @test18(i32 %x) { ret i1 %cmp } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test18_eq_vec(<2 x i32> %x) { +; CHECK-LABEL: @test18_eq_vec( +; CHECK-NEXT: [[SH:%.*]] = lshr <2 x i32> , %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SH]], +; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %sh = lshr <2 x i32> , %x + %and = and <2 x i32> %sh, + %cmp = icmp eq <2 x i32> %and, zeroinitializer + ret <2 x i1> %cmp +} + +define i1 @test18_ne(i32 %x) { +; CHECK-LABEL: @test18_ne( +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %x, 3 +; CHECK-NEXT: ret i1 [[CMP]] +; + %sh = lshr i32 8, %x + %and = and i32 %sh, 1 + %cmp = icmp ne i32 %and, 0 + ret i1 %cmp +} + +; FIXME: Vectors should fold the same way. +define <2 x i1> @test18_ne_vec(<2 x i32> %x) { +; CHECK-LABEL: @test18_ne_vec( +; CHECK-NEXT: [[SH:%.*]] = lshr <2 x i32> , %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SH]], +; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %sh = lshr <2 x i32> , %x + %and = and <2 x i32> %sh, + %cmp = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %cmp +} + define i1 @test19(i32 %x) { ; CHECK-LABEL: @test19( ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %x, 3 @@ -205,7 +272,6 @@ define i1 @test19(i32 %x) { } ; 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 @@ -240,6 +306,20 @@ define i1 @test20(i32 %x) { ret i1 %cmp } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test20vec(<2 x i32> %x) { +; CHECK-LABEL: @test20vec( +; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> , %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SHL]], +; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %shl = shl <2 x i32> , %x + %and = and <2 x i32> %shl, + %cmp = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %cmp +} + define i1 @test20a(i32 %x) { ; CHECK-LABEL: @test20a( ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 %x, 3 @@ -251,6 +331,20 @@ define i1 @test20a(i32 %x) { ret i1 %cmp } +; FIXME: Vectors should fold the same way. +define <2 x i1> @test20a_vec(<2 x i32> %x) { +; CHECK-LABEL: @test20a_vec( +; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i32> , %x +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[SHL]], +; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %shl = shl <2 x i32> , %x + %and = and <2 x i32> %shl, + %cmp = icmp ne <2 x i32> %and, zeroinitializer + ret <2 x i1> %cmp +} + define i1 @test21(i8 %x, i8 %y) { ; CHECK-LABEL: @test21( ; CHECK-NEXT: [[B:%.*]] = icmp ugt i8 %x, 3