Skip to content

Commit

Permalink
[SCEV] Add a testcase for zero max btc with non-constant exact btc
Browse files Browse the repository at this point in the history
Reduced from the ArchiveCommandLine.ll case seen in D108848.
  • Loading branch information
preames committed Aug 31, 2021
1 parent 4bb5f44 commit c49503a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
Expand Up @@ -517,3 +517,38 @@ loop:
exit:
ret void
}

; This is a case where our max-backedge taken count logic happens to be
; able to prove a zero btc, but our symbolic logic doesn't due to a lack
; of context sensativity.
define void @ne_zero_max_btc(i32 %a) {
; CHECK-LABEL: Determining loop execution counts for: @ne_zero_max_btc
; CHECK: Loop %for.body: backedge-taken count is (-1 + (zext i32 (1 umax (1 smin %a)) to i64))<nsw>
; CHECK: Loop %for.body: max backedge-taken count is 0
entry:
%cmp = icmp slt i32 %a, 1
%spec.select = select i1 %cmp, i32 %a, i32 1
%cmp8 = icmp sgt i32 %a, 0
br i1 %cmp8, label %for.body.preheader, label %loopexit

for.body.preheader: ; preds = %if.then4.i.i
%umax = call i32 @llvm.umax.i32(i32 %spec.select, i32 1)
%umax.i.i = zext i32 %umax to i64
br label %for.body

for.body: ; preds = %for.inc, %for.body.preheader
%indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.inc ]
call void @unknown()
br label %for.inc

for.inc: ; preds = %for.body
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%exitcond.i.not.i534 = icmp ne i64 %indvars.iv.next, %umax.i.i
br i1 %exitcond.i.not.i534, label %for.body, label %loopexit

loopexit:
ret void
}

declare void @unknown()
declare i32 @llvm.umax.i32(i32, i32)

0 comments on commit c49503a

Please sign in to comment.