mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[tests] Add a couple of tests for zero stride trip counts w/loop varying exit values
This commit is contained in:
parent
18c83b5d27
commit
be7020e420
@ -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"}
|
||||
|
Loading…
Reference in New Issue
Block a user