[llvm] eac2c94 - [ValueTracking] Add more non-zero add/mul recurrence tests (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 26 10:30:16 PDT 2021


Author: Nikita Popov
Date: 2021-03-26T18:30:07+01:00
New Revision: eac2c94bc22641526c3fefd4d1424edd1062cef3

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

LOG: [ValueTracking] Add more non-zero add/mul recurrence tests (NFC)

Added: 
    

Modified: 
    llvm/test/Analysis/ValueTracking/monotonic-phi.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/ValueTracking/monotonic-phi.ll b/llvm/test/Analysis/ValueTracking/monotonic-phi.ll
index d0c8f403ed95..5b9abda25c71 100644
--- a/llvm/test/Analysis/ValueTracking/monotonic-phi.ll
+++ b/llvm/test/Analysis/ValueTracking/monotonic-phi.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -instsimplify -S < %s | FileCheck %s
 
-define i1 @test1(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test1(
+define i1 @test_add_nsw(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_nsw(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -26,8 +26,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test2(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test2(
+define i1 @test_add_may_wrap(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_may_wrap(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -53,8 +53,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test3(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test3(
+define i1 @test_add_nuw(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_nuw(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -78,8 +78,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test4(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test4(
+define i1 @test_add_zero_start(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_zero_start(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -105,8 +105,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test5(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test5(
+define i1 @test_add_nuw_negative_start(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_nuw_negative_start(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -132,8 +132,60 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test6(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test6(
+define i1 @test_add_nsw_negative_start(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_nsw_negative_start(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[A:%.*]] = phi i8 [ -2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[NEXT]] = add nsw i8 [[A]], 1
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
+; CHECK-NEXT:    br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:       exit:
+; CHECK-NEXT:    [[ADD:%.*]] = or i8 [[A]], [[R:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[ADD]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+entry:
+  br label %loop
+loop:
+  %A = phi i8 [ -2, %entry ], [ %next, %loop ]
+  %next = add nsw i8 %A, 1
+  %cmp1 = icmp eq i8 %A, %n
+  br i1 %cmp1, label %exit, label %loop
+exit:
+  %add = or i8 %A, %r
+  %cmp = icmp eq i8 %add, 0
+  ret i1 %cmp
+}
+
+define i1 @test_add_nsw_negative_start_and_step(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_add_nsw_negative_start_and_step(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[A:%.*]] = phi i8 [ -1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[NEXT]] = add nsw i8 [[A]], -1
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
+; CHECK-NEXT:    br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:       exit:
+; CHECK-NEXT:    ret i1 false
+;
+entry:
+  br label %loop
+loop:
+  %A = phi i8 [ -1, %entry ], [ %next, %loop ]
+  %next = add nsw i8 %A, -1
+  %cmp1 = icmp eq i8 %A, %n
+  br i1 %cmp1, label %exit, label %loop
+exit:
+  %add = or i8 %A, %r
+  %cmp = icmp eq i8 %add, 0
+  ret i1 %cmp
+}
+
+define i1 @test_mul_nsw(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_nsw(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -156,8 +208,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test7(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test7(
+define i1 @test_mul_may_wrap(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_may_wrap(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -181,8 +233,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test8(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test8(
+define i1 @test_mul_nuw(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_nuw(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -205,8 +257,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test9(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test9(
+define i1 @test_mul_zero_start(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_zero_start(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -230,8 +282,8 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test10(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test10(
+define i1 @test_mul_nuw_negative_step(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_nuw_negative_step(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:
@@ -255,8 +307,33 @@ exit:
   ret i1 %cmp
 }
 
-define i1 @test11(i8 %p, i8* %pq, i8 %n, i8 %r) {
-; CHECK-LABEL: @test11(
+define i1 @test_mul_nsw_negative_step(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_nsw_negative_step(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[A:%.*]] = phi i8 [ 2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[NEXT]] = mul nsw i8 [[A]], -2
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
+; CHECK-NEXT:    br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:       exit:
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[A]], 0
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+entry:
+  br label %loop
+loop:
+  %A = phi i8 [ 2, %entry ], [ %next, %loop ]
+  %next = mul nsw i8 %A, -2
+  %cmp1 = icmp eq i8 %A, %n
+  br i1 %cmp1, label %exit, label %loop
+exit:
+  %cmp = icmp eq i8 %A, 0
+  ret i1 %cmp
+}
+
+define i1 @test_mul_nuw_negative_start(i8 %p, i8* %pq, i8 %n, i8 %r) {
+; CHECK-LABEL: @test_mul_nuw_negative_start(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br label [[LOOP:%.*]]
 ; CHECK:       loop:


        


More information about the llvm-commits mailing list