[llvm] 4b8bc6b - [SCEV] Add additional tests for finite loop trip counts (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 12 02:55:41 PDT 2023
Author: Nikita Popov
Date: 2023-04-12T11:55:27+02:00
New Revision: 4b8bc6b4ab8543e9fc8cfe66c7714149c37e0b9a
URL: https://github.com/llvm/llvm-project/commit/4b8bc6b4ab8543e9fc8cfe66c7714149c37e0b9a
DIFF: https://github.com/llvm/llvm-project/commit/4b8bc6b4ab8543e9fc8cfe66c7714149c37e0b9a.diff
LOG: [SCEV] Add additional tests for finite loop trip counts (NFC)
Add post-inc variations of tests.
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll b/llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll
index 502201bd657f..a6b497567198 100644
--- a/llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll
+++ b/llvm/test/Analysis/ScalarEvolution/finite-trip-count.ll
@@ -6,9 +6,9 @@ target triple = "x86_64-unknown-linux-gnu"
declare void @non_exit_use(i32 %i) #0
-define void @SLE(i32 %len) willreturn {
-; CHECK-LABEL: 'SLE'
-; CHECK-NEXT: Determining loop execution counts for: @SLE
+define void @sle_pre_inc(i32 %len) willreturn {
+; CHECK-LABEL: 'sle_pre_inc'
+; CHECK-NEXT: Determining loop execution counts for: @sle_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (0 smax (1 + %len))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483647
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (0 smax (1 + %len))
@@ -30,9 +30,33 @@ for.end:
ret void
}
-define void @SLE_infinite(i32 %len) {
-; CHECK-LABEL: 'SLE_infinite'
-; CHECK-NEXT: Determining loop execution counts for: @SLE_infinite
+define void @sle_post_inc(i32 %len) willreturn {
+; CHECK-LABEL: 'sle_post_inc'
+; CHECK-NEXT: Determining loop execution counts for: @sle_post_inc
+; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
+; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
+; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
+; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 smax (1 + %len)))<nsw>
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %for.body: Trip multiple is 1
+;
+entry:
+ br label %for.body
+
+for.body:
+ %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
+ call void @non_exit_use(i32 %iv) nounwind willreturn
+ %inc = add i32 %iv, 1
+ %cmp = icmp sle i32 %inc, %len
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+define void @sle_pre_inc_infinite(i32 %len) {
+; CHECK-LABEL: 'sle_pre_inc_infinite'
+; CHECK-NEXT: Determining loop execution counts for: @sle_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
@@ -52,9 +76,9 @@ for.end:
ret void
}
-define void @ULE(i32 %len) willreturn {
-; CHECK-LABEL: 'ULE'
-; CHECK-NEXT: Determining loop execution counts for: @ULE
+define void @ule_pre_inc(i32 %len) willreturn {
+; CHECK-LABEL: 'ule_pre_inc'
+; CHECK-NEXT: Determining loop execution counts for: @ule_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (1 + %len)
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (1 + %len)
@@ -76,9 +100,33 @@ for.end:
ret void
}
-define void @ULE_infinite(i32 %len) {
-; CHECK-LABEL: 'ULE_infinite'
-; CHECK-NEXT: Determining loop execution counts for: @ULE_infinite
+define void @ule_post_inc(i32 %len) willreturn {
+; CHECK-LABEL: 'ule_post_inc'
+; CHECK-NEXT: Determining loop execution counts for: @ule_post_inc
+; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (1 umax (1 + %len)))
+; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
+; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (1 umax (1 + %len)))
+; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (1 umax (1 + %len)))
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %for.body: Trip multiple is 1
+;
+entry:
+ br label %for.body
+
+for.body:
+ %iv = phi i32 [ %inc, %for.body ], [ 0, %entry ]
+ call void @non_exit_use(i32 %iv) nounwind willreturn
+ %inc = add i32 %iv, 1
+ %cmp = icmp ule i32 %inc, %len
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+define void @ule_pre_inc_infinite(i32 %len) {
+; CHECK-LABEL: 'ule_pre_inc_infinite'
+; CHECK-NEXT: Determining loop execution counts for: @ule_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
@@ -98,9 +146,9 @@ for.end:
ret void
}
-define void @SGE(i32 %end) willreturn {
-; CHECK-LABEL: 'SGE'
-; CHECK-NEXT: Determining loop execution counts for: @SGE
+define void @sge_pre_inc(i32 %end) willreturn {
+; CHECK-LABEL: 'sge_pre_inc'
+; CHECK-NEXT: Determining loop execution counts for: @sge_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2147483548
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
@@ -122,9 +170,33 @@ for.end:
ret void
}
-define void @SGE_infinite(i32 %end) {
-; CHECK-LABEL: 'SGE_infinite'
-; CHECK-NEXT: Determining loop execution counts for: @SGE_infinite
+define void @sge_post_inc(i32 %end) willreturn {
+; CHECK-LABEL: 'sge_post_inc'
+; CHECK-NEXT: Determining loop execution counts for: @sge_post_inc
+; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
+; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2147483548
+; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
+; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (100 + (-1 * (100 smin (-1 + %end))))
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %for.body: Trip multiple is 1
+;
+entry:
+ br label %for.body
+
+for.body:
+ %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
+ call void @non_exit_use(i32 %iv) nounwind willreturn
+ %inc = add i32 %iv, -1
+ %cmp = icmp sge i32 %iv, %end
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+define void @sge_pre_inc_infinite(i32 %end) {
+; CHECK-LABEL: 'sge_pre_inc_infinite'
+; CHECK-NEXT: Determining loop execution counts for: @sge_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
@@ -144,9 +216,9 @@ for.end:
ret void
}
-define void @UGE(i32 %end) willreturn {
-; CHECK-LABEL: 'UGE'
-; CHECK-NEXT: Determining loop execution counts for: @UGE
+define void @use_pre_inc(i32 %end) willreturn {
+; CHECK-LABEL: 'use_pre_inc'
+; CHECK-NEXT: Determining loop execution counts for: @use_pre_inc
; CHECK-NEXT: Loop %for.body: backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 100
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (100 + (-1 * (100 umin (-1 + %end)))<nsw>)<nsw>
@@ -168,9 +240,33 @@ for.end:
ret void
}
-define void @UGE_infinite(i32 %end) {
-; CHECK-LABEL: 'UGE_infinite'
-; CHECK-NEXT: Determining loop execution counts for: @UGE_infinite
+define void @use_post_inc(i32 %end) willreturn {
+; CHECK-LABEL: 'use_post_inc'
+; CHECK-NEXT: Determining loop execution counts for: @use_post_inc
+; CHECK-NEXT: Loop %for.body: backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
+; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 99
+; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
+; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (99 + (-1 * (99 umin (-1 + %end)))<nsw>)<nsw>
+; CHECK-NEXT: Predicates:
+; CHECK: Loop %for.body: Trip multiple is 1
+;
+entry:
+ br label %for.body
+
+for.body:
+ %iv = phi i32 [ %inc, %for.body ], [ 100, %entry ]
+ call void @non_exit_use(i32 %iv) nounwind willreturn
+ %inc = add i32 %iv, -1
+ %cmp = icmp uge i32 %inc, %end
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+define void @uge_pre_inc_infinite(i32 %end) {
+; CHECK-LABEL: 'uge_pre_inc_infinite'
+; CHECK-NEXT: Determining loop execution counts for: @uge_pre_inc_infinite
; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
More information about the llvm-commits
mailing list