[llvm] 4c40cfc - [tests] Add a couple of tests for zero stride trip counts w/loop varying exit values
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 16:33:25 PDT 2021
Author: Philip Reames
Date: 2021-07-19T16:33:10-07:00
New Revision: 4c40cfc20b3135e3e634ea694886e1570f460419
URL: https://github.com/llvm/llvm-project/commit/4c40cfc20b3135e3e634ea694886e1570f460419
DIFF: https://github.com/llvm/llvm-project/commit/4c40cfc20b3135e3e634ea694886e1570f460419.diff
LOG: [tests] Add a couple of tests for zero stride trip counts w/loop varying exit values
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll b/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
index ec03623fb9fb..f220e383b69c 100644
--- a/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
+++ b/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
@@ -163,7 +163,7 @@ for.end: ; preds = %for.body, %entry
; CHECK: Loop %for.body: Unpredictable predicated backedge-taken count.
; Note that this function will always execute undefined behavior and thus
; any value is valid for a backedge taken count.
-define void @zero_stride_ub(i32* nocapture %A, i32 %n, i32 %s) {
+define void @zero_stride_ub(i32* nocapture %A) {
entry:
br label %for.body
@@ -181,6 +181,54 @@ for.end: ; preds = %for.body, %entry
ret void
}
+; When %zero = 0, this loop is only well defined if %n < 0 and thus BTC = 0.
+; CHECK-LABEL: Determining loop execution counts for: @zero_stride_symbolic
+; CHECK: Loop %for.body: backedge-taken count is ((((-1 * (1 umin ((-1 * %zero) + (%n smax %zero))))<nuw><nsw> + (-1 * %zero) + (%n smax %zero)) /u (1 umax %zero)) + (1 umin ((-1 * %zero) + (%n smax %zero))))
+; CHECK: Loop %for.body: max backedge-taken count is -1
+
+define void @zero_stride_symbolic(i32* nocapture %A, i32 %n, i32 %zero) {
+entry:
+ br label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
+ %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.05
+ %0 = load i32, i32* %arrayidx, align 4
+ %inc = add nsw i32 %0, 1
+ store i32 %inc, i32* %arrayidx, align 4
+ %add = add nsw i32 %i.05, %zero
+ %cmp = icmp slt i32 %add, %n
+ br i1 %cmp, label %for.body, label %for.end, !llvm.loop !8
+
+for.end: ; preds = %for.body, %entry
+ ret void
+}
+
+
+; CHECK-LABEL: Determining loop execution counts for: @zero_stride_varying_rhs
+; CHECK: Loop %for.body: Unpredictable backedge-taken count.
+; CHECK: Loop %for.body: max backedge-taken count is -1
+
+define void @zero_stride_varying_rhs(i32* nocapture %A, i32* %n_p, i32 %zero) {
+entry:
+ br label %for.body
+
+for.body: ; preds = %entry, %for.body
+ %i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
+ %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.05
+ %0 = load i32, i32* %arrayidx, align 4
+ %inc = add nsw i32 %0, 1
+ store i32 %inc, i32* %arrayidx, align 4
+ %add = add nsw i32 %i.05, %zero
+ %n = load i32, i32* %n_p
+ %cmp = icmp slt i32 %add, %n
+ br i1 %cmp, label %for.body, label %for.end, !llvm.loop !8
+
+for.end: ; preds = %for.body, %entry
+ ret void
+}
+
+
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
More information about the llvm-commits
mailing list