[llvm] r278132 - add tests for missing vector icmp folds

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 09:39:05 PDT 2016


Author: spatel
Date: Tue Aug  9 11:39:05 2016
New Revision: 278132

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

Modified:
    llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll
    llvm/trunk/test/Transforms/InstCombine/icmp.ll
    llvm/trunk/test/Transforms/InstCombine/xor2.ll

Modified: llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll?rev=278132&r1=278131&r2=278132&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/2008-08-17-ICmpXorSignbit.ll Tue Aug  9 11:39:05 2016
@@ -33,6 +33,18 @@ define i1 @test3(i8 %x) {
   ret i1 %tmp
 }
 
+; FIXME: Vectors should fold too.
+define <2 x i1> @test3vec(<2 x i8> %x) {
+; CHECK-LABEL: @test3vec(
+; CHECK-NEXT:    [[X:%.*]] = xor <2 x i8> %x, <i8 -128, i8 -128>
+; CHECK-NEXT:    [[TMP:%.*]] = icmp ugt <2 x i8> [[X]], <i8 14, i8 14>
+; CHECK-NEXT:    ret <2 x i1> [[TMP]]
+;
+  %X = xor <2 x i8> %x, <i8 128, i8 128>
+  %tmp = icmp uge <2 x i8> %X, <i8 15, i8 15>
+  ret <2 x i1> %tmp
+}
+
 define i1 @test4(i8 %x, i8 %y) {
 ; CHECK-LABEL: @test4(
 ; CHECK-NEXT:    [[TMP:%.*]] = icmp ugt i8 %x, %y
@@ -65,3 +77,15 @@ define i1 @test6(i8 %x) {
   ret i1 %tmp
 }
 
+; FIXME: Vectors should fold too.
+define <2 x i1> @test6vec(<2 x i8> %x) {
+; CHECK-LABEL: @test6vec(
+; CHECK-NEXT:    [[X:%.*]] = xor <2 x i8> %x, <i8 127, i8 127>
+; CHECK-NEXT:    [[TMP:%.*]] = icmp ugt <2 x i8> [[X]], <i8 14, i8 14>
+; CHECK-NEXT:    ret <2 x i1> [[TMP]]
+;
+  %X = xor <2 x i8> %x, <i8 127, i8 127>
+  %tmp = icmp uge <2 x i8> %X, <i8 15, i8 15>
+  ret <2 x i1> %tmp
+}
+

Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=278132&r1=278131&r2=278132&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Tue Aug  9 11:39:05 2016
@@ -1546,6 +1546,18 @@ define i1 @icmp_sub_-1_X_ult_4(i32 %X) {
   ret i1 %cmp
 }
 
+; FIXME: Vectors should fold too.
+define <2 x i1> @icmp_sub_neg1_X_ult_4_vec(<2 x i32> %X) {
+; CHECK-LABEL: @icmp_sub_neg1_X_ult_4_vec(
+; CHECK-NEXT:    [[SUB:%.*]] = xor <2 x i32> %X, <i32 -1, i32 -1>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult <2 x i32> [[SUB]], <i32 4, i32 4>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = sub <2 x i32> <i32 -1, i32 -1>, %X
+  %cmp = icmp ult <2 x i32> %sub, <i32 4, i32 4>
+  ret <2 x i1> %cmp
+}
+
 define i1 @icmp_sub_-1_X_uge_4(i32 %X) {
 ; CHECK-LABEL: @icmp_sub_-1_X_uge_4(
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 %X, -4
@@ -1556,6 +1568,18 @@ define i1 @icmp_sub_-1_X_uge_4(i32 %X) {
   ret i1 %cmp
 }
 
+; FIXME: Vectors should fold too.
+define <2 x i1> @icmp_sub_neg1_X_uge_4_vec(<2 x i32> %X) {
+; CHECK-LABEL: @icmp_sub_neg1_X_uge_4_vec(
+; CHECK-NEXT:    [[SUB:%.*]] = xor <2 x i32> %X, <i32 -1, i32 -1>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt <2 x i32> [[SUB]], <i32 3, i32 3>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = sub <2 x i32> <i32 -1, i32 -1>, %X
+  %cmp = icmp uge <2 x i32> %sub, <i32 4, i32 4>
+  ret <2 x i1> %cmp
+}
+
 define i1 @icmp_swap_operands_for_cse(i32 %X, i32 %Y) {
 ; CHECK-LABEL: @icmp_swap_operands_for_cse(
 ; CHECK-NEXT:  entry:

Modified: llvm/trunk/test/Transforms/InstCombine/xor2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/xor2.ll?rev=278132&r1=278131&r2=278132&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/xor2.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/xor2.ll Tue Aug  9 11:39:05 2016
@@ -12,6 +12,18 @@ define i1 @test0(i32 %A) {
   ret i1 %C
 }
 
+; FIXME: Vectors should fold too.
+define <2 x i1> @test0vec(<2 x i32> %A) {
+; CHECK-LABEL: @test0vec(
+; CHECK-NEXT:    [[B:%.*]] = xor <2 x i32> %A, <i32 -2147483648, i32 -2147483648>
+; CHECK-NEXT:    [[C:%.*]] = icmp sgt <2 x i32> [[B]], <i32 -1, i32 -1>
+; CHECK-NEXT:    ret <2 x i1> [[C]]
+;
+  %B = xor <2 x i32> %A, <i32 -2147483648, i32 -2147483648>
+  %C = icmp sgt <2 x i32> %B, <i32 -1, i32 -1>
+  ret <2 x i1> %C
+}
+
 define i1 @test1(i32 %A) {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:    [[C:%.*]] = icmp slt i32 %A, 0




More information about the llvm-commits mailing list