Skip to content

Commit c0e6703

Browse files
committedMay 27, 2014
Adding testcase for PR18886.
Differential Revision: http://reviews.llvm.org/D3837 llvm-svn: 209645
1 parent 1c04bab commit c0e6703

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎llvm/test/Analysis/ScalarEvolution/max-trip-count.ll

+27
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,33 @@ bar.exit: ; preds = %for.cond.i, %for.bo
125125
ret i32 0
126126
}
127127

128+
; PR18886: Indvars miscompile due to an incorrect max backedge taken count from SCEV.
129+
; CHECK-LABEL: @pr18886
130+
; CHECK: Loop %for.body: <multiple exits> Unpredictable backedge-taken count.
131+
; CHECK: Loop %for.body: max backedge-taken count is 3
132+
@aa = global i64 0, align 8
133+
134+
define i32 @pr18886() {
135+
entry:
136+
store i64 -21, i64* @aa, align 8
137+
br label %for.body
138+
139+
for.body:
140+
%storemerge1 = phi i64 [ -21, %entry ], [ %add, %for.cond ]
141+
%tobool = icmp eq i64 %storemerge1, 0
142+
%add = add nsw i64 %storemerge1, 8
143+
br i1 %tobool, label %return, label %for.cond
144+
145+
for.cond:
146+
store i64 %add, i64* @aa, align 8
147+
%cmp = icmp slt i64 %add, 9
148+
br i1 %cmp, label %for.body, label %return
149+
150+
return:
151+
%retval.0 = phi i32 [ 1, %for.body ], [ 0, %for.cond ]
152+
ret i32 %retval.0
153+
}
154+
128155
; Here we have a must-exit loop latch that is not computable and a
129156
; may-exit early exit that can only have one non-exiting iteration
130157
; before the check is forever skipped.

0 commit comments

Comments
 (0)
Please sign in to comment.