From: Philip Reames Date: Tue, 31 Aug 2021 17:59:02 +0000 (-0700) Subject: [SCEV] Add a testcase for zero max btc with non-constant exact btc X-Git-Tag: upstream/15.0.7~32618 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c49503a76db5f91b2dbae28f4154df5b3891f7a1;p=platform%2Fupstream%2Fllvm.git [SCEV] Add a testcase for zero max btc with non-constant exact btc Reduced from the ArchiveCommandLine.ll case seen in D108848. --- diff --git a/llvm/test/Analysis/ScalarEvolution/max-trip-count.ll b/llvm/test/Analysis/ScalarEvolution/max-trip-count.ll index f50ff14..36cf882 100644 --- a/llvm/test/Analysis/ScalarEvolution/max-trip-count.ll +++ b/llvm/test/Analysis/ScalarEvolution/max-trip-count.ll @@ -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)) +; 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)