Skip to content

Commit 6245252

Browse files
committed
[test] Add a SCEV backedge computation test with an explicit zero stride
1 parent ce25eb0 commit 6245252

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll

+50
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,55 @@ for.end: ; preds = %for.body, %entry
106106
ret void
107107
}
108108

109+
; FIXME: Currently we are more conservative for known zero stride than
110+
; for unknown but potentially zero stride.
111+
; CHECK: Determining loop execution counts for: @zero_stride
112+
; CHECK: Loop %for.body: Unpredictable backedge-taken count.
113+
; CHECK: Loop %for.body: Unpredictable max backedge-taken count.
114+
; CHECK: Loop %for.body: Unpredictable predicated backedge-taken count.
115+
; Note that this function is well defined only when %n <=s 0
116+
define void @zero_stride(i32* nocapture %A, i32 %n) {
117+
entry:
118+
br label %for.body
119+
120+
for.body: ; preds = %entry, %for.body
121+
%i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
122+
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.05
123+
%0 = load i32, i32* %arrayidx, align 4
124+
%inc = add nsw i32 %0, 1
125+
store i32 %inc, i32* %arrayidx, align 4
126+
%add = add nsw i32 %i.05, 0
127+
%cmp = icmp slt i32 %add, %n
128+
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !8
129+
130+
for.end: ; preds = %for.body, %entry
131+
ret void
132+
}
133+
134+
; CHECK: Determining loop execution counts for: @zero_stride_ub
135+
; CHECK: Loop %for.body: Unpredictable backedge-taken count.
136+
; CHECK: Loop %for.body: Unpredictable max backedge-taken count.
137+
; CHECK: Loop %for.body: Unpredictable predicated backedge-taken count.
138+
; Note that this function will always execute undefined behavior and thus
139+
; any value is valid for a backedge taken count.
140+
define void @zero_stride_ub(i32* nocapture %A, i32 %n, i32 %s) {
141+
entry:
142+
br label %for.body
143+
144+
for.body: ; preds = %entry, %for.body
145+
%i.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
146+
%arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.05
147+
%0 = load i32, i32* %arrayidx, align 4
148+
%inc = add nsw i32 %0, 1
149+
store i32 %inc, i32* %arrayidx, align 4
150+
%add = add nsw i32 %i.05, 0
151+
%cmp = icmp slt i32 %add, 2
152+
br i1 %cmp, label %for.body, label %for.end, !llvm.loop !8
153+
154+
for.end: ; preds = %for.body, %entry
155+
ret void
156+
}
157+
158+
109159
!8 = distinct !{!8, !9}
110160
!9 = !{!"llvm.loop.mustprogress"}

0 commit comments

Comments
 (0)