From: Philip Reames Date: Wed, 28 Apr 2021 20:46:26 +0000 (-0700) Subject: [tests] Precommit some extra tests for D100884 X-Git-Tag: llvmorg-14-init~8153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4623d4ff85b0f214a4ce2b50649e6f1e8cff8d01;p=platform%2Fupstream%2Fllvm.git [tests] Precommit some extra tests for D100884 --- diff --git a/llvm/test/Analysis/ValueTracking/known-non-equal.ll b/llvm/test/Analysis/ValueTracking/known-non-equal.ll index 4e3a0ec..a41d228 100644 --- a/llvm/test/Analysis/ValueTracking/known-non-equal.ll +++ b/llvm/test/Analysis/ValueTracking/known-non-equal.ll @@ -721,8 +721,6 @@ exit: 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: @@ -966,6 +964,77 @@ exit: ret i1 %res } +define i1 @recurrence_sub_op_order(i8 %A) { +; CHECK-LABEL: @recurrence_sub_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]] = sub i8 1, [[A_IV]] +; CHECK-NEXT: [[B_IV_NEXT]] = sub 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 = sub i8 1, %A.iv + %B.iv.next = sub 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 +} + +define i1 @recurrence_sub_op_order2(i8 %A) { +; CHECK-LABEL: @recurrence_sub_op_order2( +; 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]] = sub i8 1, [[A_IV]] +; CHECK-NEXT: [[B_IV_NEXT]] = sub 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 [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 = sub i8 1, %A.iv + %B.iv.next = sub 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_mul_neq(i8 %A) { ; CHECK-LABEL: @recurrence_mul_neq( ; CHECK-NEXT: entry: @@ -1238,6 +1307,42 @@ exit: ret i1 %res } +; Represents a power function, but still invertable! +define i1 @recurrence_shl_op_order(i8 %A) { +; CHECK-LABEL: @recurrence_shl_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]] = shl nuw i8 1, [[A_IV]] +; CHECK-NEXT: [[B_IV_NEXT]] = shl nuw 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 = shl nuw i8 1, %A.iv + %B.iv.next = shl nuw 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 +} + define i1 @recurrence_lshr_neq(i8 %A) { ; CHECK-LABEL: @recurrence_lshr_neq( ; CHECK-NEXT: entry: @@ -1374,6 +1479,40 @@ exit: ret i1 %res } +define i1 @recurrence_lshr_op_order(i8 %A) { +; CHECK-LABEL: @recurrence_lshr_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]] ], [ 1, [[LOOP]] ] +; CHECK-NEXT: [[B_IV:%.*]] = phi i8 [ [[B]], [[ENTRY]] ], [ 1, [[LOOP]] ] +; CHECK-NEXT: [[IV_NEXT]] = add i64 [[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 [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 = lshr exact i8 1, %A.iv + %B.iv.next = lshr exact 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 +} + + define i1 @recurrence_ashr_neq(i8 %A) { ; CHECK-LABEL: @recurrence_ashr_neq( ; CHECK-NEXT: entry: