Skip to content

Commit f7668c3

Browse files
preamesmemfrob
authored andcommitted
[SCEV] Add a testcase for zero max btc with non-constant exact btc
Reduced from the ArchiveCommandLine.ll case seen in D108848.
1 parent 5b70857 commit f7668c3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,38 @@ loop:
517517
exit:
518518
ret void
519519
}
520+
521+
; This is a case where our max-backedge taken count logic happens to be
522+
; able to prove a zero btc, but our symbolic logic doesn't due to a lack
523+
; of context sensativity.
524+
define void @ne_zero_max_btc(i32 %a) {
525+
; CHECK-LABEL: Determining loop execution counts for: @ne_zero_max_btc
526+
; CHECK: Loop %for.body: backedge-taken count is (-1 + (zext i32 (1 umax (1 smin %a)) to i64))<nsw>
527+
; CHECK: Loop %for.body: max backedge-taken count is 0
528+
entry:
529+
%cmp = icmp slt i32 %a, 1
530+
%spec.select = select i1 %cmp, i32 %a, i32 1
531+
%cmp8 = icmp sgt i32 %a, 0
532+
br i1 %cmp8, label %for.body.preheader, label %loopexit
533+
534+
for.body.preheader: ; preds = %if.then4.i.i
535+
%umax = call i32 @llvm.umax.i32(i32 %spec.select, i32 1)
536+
%umax.i.i = zext i32 %umax to i64
537+
br label %for.body
538+
539+
for.body: ; preds = %for.inc, %for.body.preheader
540+
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.inc ]
541+
call void @unknown()
542+
br label %for.inc
543+
544+
for.inc: ; preds = %for.body
545+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
546+
%exitcond.i.not.i534 = icmp ne i64 %indvars.iv.next, %umax.i.i
547+
br i1 %exitcond.i.not.i534, label %for.body, label %loopexit
548+
549+
loopexit:
550+
ret void
551+
}
552+
553+
declare void @unknown()
554+
declare i32 @llvm.umax.i32(i32, i32)

0 commit comments

Comments
 (0)