[llvm] c49503a - [SCEV] Add a testcase for zero max btc with non-constant exact btc
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 31 11:00:46 PDT 2021
Author: Philip Reames
Date: 2021-08-31T11:00:41-07:00
New Revision: c49503a76db5f91b2dbae28f4154df5b3891f7a1
URL: https://github.com/llvm/llvm-project/commit/c49503a76db5f91b2dbae28f4154df5b3891f7a1
DIFF: https://github.com/llvm/llvm-project/commit/c49503a76db5f91b2dbae28f4154df5b3891f7a1.diff
LOG: [SCEV] Add a testcase for zero max btc with non-constant exact btc
Reduced from the ArchiveCommandLine.ll case seen in D108848.
Added:
Modified:
llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/max-trip-count.ll b/llvm/test/Analysis/ScalarEvolution/max-trip-count.ll
index f50ff14630f3..36cf882c46ac 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))<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)
More information about the llvm-commits
mailing list