[llvm] 07b0049 - [test] Add a couple more tests for D99912

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 09:57:03 PDT 2021


Author: Philip Reames
Date: 2021-04-20T09:56:57-07:00
New Revision: 07b004998a0c869a497198df0c1e5a86d8e39ef0

URL: https://github.com/llvm/llvm-project/commit/07b004998a0c869a497198df0c1e5a86d8e39ef0
DIFF: https://github.com/llvm/llvm-project/commit/07b004998a0c869a497198df0c1e5a86d8e39ef0.diff

LOG: [test] Add a couple more tests for D99912

Added: 
    

Modified: 
    llvm/test/Analysis/ValueTracking/known-non-equal.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/ValueTracking/known-non-equal.ll b/llvm/test/Analysis/ValueTracking/known-non-equal.ll
index 2d6e60cea067..257a0a255af3 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-equal.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-equal.ll
@@ -685,6 +685,115 @@ exit:
   ret i1 %res
 }
 
+; If the steps are 
diff erent, the invertibility is not enough
+; (Though, in this case, we could prove neq with 
diff erent logic)
+define i1 @recurrence_add_
diff _step(i8 %A) {
+; CHECK-LABEL: @recurrence_add_
diff _step(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[A_IV:%.*]] = phi i8 [ [[A]], [[ENTRY]] ], [ [[A_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ [[B_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT:    [[A_IV_NEXT]] = add i8 [[A_IV]], 1
+; CHECK-NEXT:    [[B_IV_NEXT]] = add i8 [[B_IV]], 2
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT:    br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       exit:
+; CHECK-NEXT:    [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+entry:
+  %B = add i8 %A, 1
+  br label %loop
+loop:
+  %iv = phi i64 [0, %entry], [%iv.next, %loop]
+  %A.iv = phi i8 [%A, %entry], [%A.iv.next, %loop]
+  %B.iv = phi i8 [%B, %entry], [%B.iv.next, %loop]
+  %iv.next = add i64 %iv, 1
+  %A.iv.next = add i8 %A.iv, 1
+  %B.iv.next = add i8 %B.iv, 2
+  %cmp = icmp ne i64 %iv.next, 10
+  br i1 %cmp, label %loop, label %exit
+exit:
+  %res = icmp eq i8 %A.iv, %B.iv
+  ret i1 %res
+}
+
+; We currently require recursion through first operand
+; (Though for add, which is cummutable, we could support either)
+define i1 @recurrence_add_op_order(i8 %A) {
+; CHECK-LABEL: @recurrence_add_op_order(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[A_IV:%.*]] = phi i8 [ [[A]], [[ENTRY]] ], [ [[A_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ [[B_IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT:    [[A_IV_NEXT]] = add i8 1, [[A_IV]]
+; CHECK-NEXT:    [[B_IV_NEXT]] = add i8 1, [[B_IV]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT:    br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       exit:
+; CHECK-NEXT:    [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+entry:
+  %B = add i8 %A, 1
+  br label %loop
+loop:
+  %iv = phi i64 [0, %entry], [%iv.next, %loop]
+  %A.iv = phi i8 [%A, %entry], [%A.iv.next, %loop]
+  %B.iv = phi i8 [%B, %entry], [%B.iv.next, %loop]
+  %iv.next = add i64 %iv, 1
+  %A.iv.next = add i8 1, %A.iv
+  %B.iv.next = add i8 1, %B.iv
+  %cmp = icmp ne i64 %iv.next, 10
+  br i1 %cmp, label %loop, label %exit
+exit:
+  %res = icmp eq i8 %A.iv, %B.iv
+  ret i1 %res
+}
+
+; Just to show that phi operand order doesn't matter
+define i1 @recurrence_add_neq_phi_order(i8 %A) {
+; CHECK-LABEL: @recurrence_add_neq_phi_order(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[B:%.*]] = add i8 [[A:%.*]], 1
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[A_IV:%.*]] = phi i8 [ [[A_IV_NEXT:%.*]], [[LOOP]] ], [ [[A]], [[ENTRY]] ]
+; CHECK-NEXT:    [[B_IV:%.*]] = phi i8 [ [[B_IV_NEXT:%.*]], [[LOOP]] ], [ [[B]], [[ENTRY]] ]
+; CHECK-NEXT:    [[IV_NEXT]] = add i64 [[IV]], 1
+; CHECK-NEXT:    [[A_IV_NEXT]] = add i8 [[A_IV]], 1
+; CHECK-NEXT:    [[B_IV_NEXT]] = add i8 [[B_IV]], 1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i64 [[IV_NEXT]], 10
+; CHECK-NEXT:    br i1 [[CMP]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK:       exit:
+; CHECK-NEXT:    [[RES:%.*]] = icmp eq i8 [[A_IV]], [[B_IV]]
+; CHECK-NEXT:    ret i1 [[RES]]
+;
+entry:
+  %B = add i8 %A, 1
+  br label %loop
+loop:
+  %iv = phi i64 [%iv.next, %loop], [0, %entry]
+  %A.iv = phi i8 [%A.iv.next, %loop], [%A, %entry]
+  %B.iv = phi i8 [%B.iv.next, %loop], [%B, %entry]
+  %iv.next = add i64 %iv, 1
+  %A.iv.next = add i8 %A.iv, 1
+  %B.iv.next = add i8 %B.iv, 1
+  %cmp = icmp ne i64 %iv.next, 10
+  br i1 %cmp, label %loop, label %exit
+exit:
+  %res = icmp eq i8 %A.iv, %B.iv
+  ret i1 %res
+}
 
 define i1 @recurrence_sub_neq(i8 %A) {
 ; CHECK-LABEL: @recurrence_sub_neq(


        


More information about the llvm-commits mailing list