[llvm] r304555 - [InstCombine] fix/add tests for icmp with not ops; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 08:35:46 PDT 2017


Author: spatel
Date: Fri Jun  2 10:35:45 2017
New Revision: 304555

URL: http://llvm.org/viewvc/llvm-project?rev=304555&view=rev
Log:
[InstCombine] fix/add tests for icmp with not ops; NFC

The existing test was not minimal, and there was no coverage
for the variants with a constant or vector types.

Modified:
    llvm/trunk/test/Transforms/InstCombine/not.ll

Modified: llvm/trunk/test/Transforms/InstCombine/not.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/not.ll?rev=304555&r1=304554&r2=304555&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/not.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/not.ll Fri Jun  2 10:35:45 2017
@@ -33,17 +33,47 @@ define i1 @invert_fcmp(float %X, float %
 
 ; PR2298
 
-define zeroext i8 @test6(i32 %a, i32 %b) {
-; CHECK-LABEL: @test6(
-; CHECK-NEXT:    [[TMP3:%.*]] = icmp slt i32 %b, %a
-; CHECK-NEXT:    [[RETVAL67:%.*]] = zext i1 [[TMP3]] to i8
-; CHECK-NEXT:    ret i8 [[RETVAL67]]
+define i1 @not_not_cmp(i32 %a, i32 %b) {
+; CHECK-LABEL: @not_not_cmp(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i32 %b, %a
+; CHECK-NEXT:    ret i1 [[CMP]]
 ;
-  %tmp1not = xor i32 %a, -1
-  %tmp2not = xor i32 %b, -1
-  %tmp3 = icmp slt i32 %tmp1not, %tmp2not
-  %retval67 = zext i1 %tmp3 to i8
-  ret i8 %retval67
+  %nota = xor i32 %a, -1
+  %notb = xor i32 %b, -1
+  %cmp = icmp slt i32 %nota, %notb
+  ret i1 %cmp
+}
+
+define <2 x i1> @not_not_cmp_vector(<2 x i32> %a, <2 x i32> %b) {
+; CHECK-LABEL: @not_not_cmp_vector(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt <2 x i32> %b, %a
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %nota = xor <2 x i32> %a, <i32 -1, i32 -1>
+  %notb = xor <2 x i32> %b, <i32 -1, i32 -1>
+  %cmp = icmp ugt <2 x i32> %nota, %notb
+  ret <2 x i1> %cmp
+}
+
+define i1 @not_cmp_constant(i32 %a) {
+; CHECK-LABEL: @not_cmp_constant(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 %a, -43
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %nota = xor i32 %a, -1
+  %cmp = icmp ugt i32 %nota, 42
+  ret i1 %cmp
+}
+
+define <2 x i1> @not_cmp_constant_vector(<2 x i32> %a) {
+; CHECK-LABEL: @not_cmp_constant_vector(
+; CHECK-NEXT:    [[NOTA:%.*]] = xor <2 x i32> %a, <i32 -1, i32 -1>
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt <2 x i32> [[NOTA]], <i32 42, i32 42>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %nota = xor <2 x i32> %a, <i32 -1, i32 -1>
+  %cmp = icmp slt <2 x i32> %nota, <i32 42, i32 42>
+  ret <2 x i1> %cmp
 }
 
 define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {




More information about the llvm-commits mailing list