OSDN Git Service

[NFC][InstCombine] Cleanup demorgan-sink-not-into-xor.ll test
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 8 Aug 2018 08:46:07 +0000 (08:46 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 8 Aug 2018 08:46:07 +0000 (08:46 +0000)
We are only going to do it if it is free to do.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339223 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/demorgan-sink-not-into-xor.ll

index a8d2d44..50d4601 100644 (file)
 ; Basic positive tests
 ; ============================================================================ ;
 
-; Just fold it into the first operand.
-define i32 @positive(i32 %x, i32 %y) {
-; CHECK-LABEL: @positive(
-; CHECK-NEXT:    [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = xor i32 [[TMP1]], -1
-; CHECK-NEXT:    ret i32 [[TMP2]]
-;
-  %tmp1 = xor i32 %x, %y
-  %tmp2 = xor i32 %tmp1, -1
-  ret i32 %tmp2
-}
-
-declare i32 @gen32()
-
-; If the [second] operand is easily-invertible, fold into it.
+; If the operand is easily-invertible, fold into it.
 declare i1 @gen1()
 
-define i1 @positive_easyinvert(i8 %y) {
+define i1 @positive_easyinvert(i16 %x, i8 %y) {
 ; CHECK-LABEL: @positive_easyinvert(
-; CHECK-NEXT:    [[TMP1:%.*]] = call i1 @gen1()
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp slt i16 [[X:%.*]], 0
 ; CHECK-NEXT:    [[TMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
-; CHECK-NEXT:    [[TMP3:%.*]] = xor i1 [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = xor i1 [[TMP2]], [[TMP1]]
 ; CHECK-NEXT:    [[TMP4:%.*]] = xor i1 [[TMP3]], true
 ; CHECK-NEXT:    ret i1 [[TMP4]]
 ;
-  %tmp1 = call i1 @gen1()
+  %tmp1 = icmp slt i16 %x, 0
   %tmp2 = icmp slt i8 %y, 0
-  %tmp3 = xor i1 %tmp1, %tmp2
+  %tmp3 = xor i1 %tmp2, %tmp1
   %tmp4 = xor i1 %tmp3, true
   ret i1 %tmp4
 }
 
-; ============================================================================ ;
-; Vector tests
-; ============================================================================ ;
-
-define <2 x i32> @positive_vec(<2 x i32> %x, <2 x i32> %y) {
-; CHECK-LABEL: @positive_vec(
-; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i32> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = xor <2 x i32> [[TMP1]], <i32 -1, i32 -1>
-; CHECK-NEXT:    ret <2 x i32> [[TMP2]]
-;
-  %tmp1 = xor <2 x i32> %x, %y
-  %tmp2 = xor <2 x i32> %tmp1, <i32 -1, i32 -1>
-  ret <2 x i32> %tmp2
-}
-
-define <3 x i32> @positive_vec_undef(<3 x i32> %x, <3 x i32> %y) {
-; CHECK-LABEL: @positive_vec_undef(
-; CHECK-NEXT:    [[TMP1:%.*]] = xor <3 x i32> [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = xor <3 x i32> [[TMP1]], <i32 -1, i32 undef, i32 -1>
-; CHECK-NEXT:    ret <3 x i32> [[TMP2]]
+define i1 @positive_easyinvert0(i8 %y) {
+; CHECK-LABEL: @positive_easyinvert0(
+; CHECK-NEXT:    [[TMP1:%.*]] = call i1 @gen1()
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
+; CHECK-NEXT:    [[TMP3:%.*]] = xor i1 [[TMP2]], [[TMP1]]
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i1 [[TMP3]], true
+; CHECK-NEXT:    ret i1 [[TMP4]]
 ;
-  %tmp1 = xor <3 x i32> %x, %y
-  %tmp2 = xor <3 x i32> %tmp1, <i32 -1, i32 undef, i32 -1>
-  ret <3 x i32> %tmp2
+  %tmp1 = call i1 @gen1()
+  %tmp2 = icmp slt i8 %y, 0
+  %tmp3 = xor i1 %tmp2, %tmp1
+  %tmp4 = xor i1 %tmp3, true
+  ret i1 %tmp4
 }
 
-; ============================================================================ ;
-; One-use tests.
-; ============================================================================ ;
-
-declare void @use32(i32)
-
-define i32 @oneuse_0(i32 %x, i32 %y) {
-; CHECK-LABEL: @oneuse_0(
-; CHECK-NEXT:    [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    call void @use32(i32 [[TMP1]])
-; CHECK-NEXT:    [[TMP2:%.*]] = xor i32 [[TMP1]], -1
-; CHECK-NEXT:    ret i32 [[TMP2]]
+define i1 @positive_easyinvert1(i8 %y) {
+; CHECK-LABEL: @positive_easyinvert1(
+; CHECK-NEXT:    [[TMP1:%.*]] = call i1 @gen1()
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp slt i8 [[Y:%.*]], 0
+; CHECK-NEXT:    [[TMP3:%.*]] = xor i1 [[TMP1]], [[TMP2]]
+; CHECK-NEXT:    [[TMP4:%.*]] = xor i1 [[TMP3]], true
+; CHECK-NEXT:    ret i1 [[TMP4]]
 ;
-  %tmp1 = xor i32 %x, %y
-  call void @use32(i32 %tmp1)
-  %tmp2 = xor i32 %tmp1, -1
-  ret i32 %tmp2
+  %tmp1 = call i1 @gen1()
+  %tmp2 = icmp slt i8 %y, 0
+  %tmp3 = xor i1 %tmp1, %tmp2
+  %tmp4 = xor i1 %tmp3, true
+  ret i1 %tmp4
 }
 
 ; ============================================================================ ;
@@ -157,14 +128,14 @@ define i1 @oneuse_easyinvert_2(i8 %y) {
 ; Negative tests
 ; ============================================================================ ;
 
-; It has to be 'not'.
+; Not easily invertible.
 define i32 @negative(i32 %x, i32 %y) {
 ; CHECK-LABEL: @negative(
 ; CHECK-NEXT:    [[TMP1:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = xor i32 [[TMP1]], 1
+; CHECK-NEXT:    [[TMP2:%.*]] = xor i32 [[TMP1]], -1
 ; CHECK-NEXT:    ret i32 [[TMP2]]
 ;
   %tmp1 = xor i32 %x, %y
-  %tmp2 = xor i32 %tmp1, 1 ; not -1
+  %tmp2 = xor i32 %tmp1, -1
   ret i32 %tmp2
 }