[llvm] r276482 - add tests for icmp vector folds

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 15:19:52 PDT 2016


Author: spatel
Date: Fri Jul 22 17:19:52 2016
New Revision: 276482

URL: http://llvm.org/viewvc/llvm-project?rev=276482&view=rev
Log:
add tests for icmp vector folds

Modified:
    llvm/trunk/test/Transforms/InstCombine/and.ll
    llvm/trunk/test/Transforms/InstCombine/icmp.ll

Modified: llvm/trunk/test/Transforms/InstCombine/and.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/and.ll?rev=276482&r1=276481&r2=276482&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/and.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/and.ll Fri Jul 22 17:19:52 2016
@@ -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, <i32 -128, i32 -128>
+; CHECK-NEXT:    [[C:%.*]] = icmp ne <2 x i32> [[B]], zeroinitializer
+; CHECK-NEXT:    ret <2 x i1> [[C]]
+;
+  %B = and <2 x i32> %A, <i32 -128, i32 -128>
+  %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, <i8 -2, i8 -2>
+; CHECK-NEXT:    [[C:%.*]] = icmp eq <2 x i8> [[B]], zeroinitializer
+; CHECK-NEXT:    ret <2 x i1> [[C]]
+;
+  %B = and <2 x i8> %A, <i8 -2, i8 -2>
+  %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

Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=276482&r1=276481&r2=276482&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Fri Jul 22 17:19:52 2016
@@ -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> <i32 1, i32 1>, %x
+; CHECK-NEXT:    [[AND:%.*]] = and <2 x i32> [[SHL]], <i32 8, i32 8>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i32> [[AND]], <i32 8, i32 8>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %shl = shl <2 x i32> <i32 1, i32 1>, %x
+  %and = and <2 x i32> %shl, <i32 8, i32 8>
+  %cmp = icmp eq <2 x i32> %and, <i32 8, i32 8>
+  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, <i3 -4, i3 -4>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne <2 x i3> [[AND]], zeroinitializer
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %and = and <2 x i3> %x, <i3 4, i3 4>
+  %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




More information about the llvm-commits mailing list