[llvm] ed4227a - [SCEV] Add tests for symbolic max BTC requiring predicates.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue May 28 14:37:32 PDT 2024
Author: Florian Hahn
Date: 2024-05-28T14:37:16-07:00
New Revision: ed4227aad37f2c4adf307b63050fb9aee52b07f8
URL: https://github.com/llvm/llvm-project/commit/ed4227aad37f2c4adf307b63050fb9aee52b07f8
DIFF: https://github.com/llvm/llvm-project/commit/ed4227aad37f2c4adf307b63050fb9aee52b07f8.diff
LOG: [SCEV] Add tests for symbolic max BTC requiring predicates.
Add extra tests for https://github.com/llvm/llvm-project/pull/93498.
Added:
llvm/test/Analysis/ScalarEvolution/predicated-symbolic-max-backedge-taken-count.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ScalarEvolution/predicated-symbolic-max-backedge-taken-count.ll b/llvm/test/Analysis/ScalarEvolution/predicated-symbolic-max-backedge-taken-count.ll
new file mode 100644
index 0000000000000..d40416359b65c
--- /dev/null
+++ b/llvm/test/Analysis/ScalarEvolution/predicated-symbolic-max-backedge-taken-count.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -passes='print<scalar-evolution>' -scalar-evolution-classify-expressions=0 -disable-output %s 2>&1 | FileCheck %s
+
+; %i and %i + 1 can overflow.
+define void @test1(i64 %x, ptr %a, ptr %b) {
+; CHECK-LABEL: 'test1'
+; CHECK-NEXT: Determining loop execution counts for: @test1
+; CHECK-NEXT: Loop %header: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for header: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: Loop %header: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT: Loop %header: Unpredictable symbolic max backedge-taken count.
+; CHECK-NEXT: symbolic max exit count for header: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
+;
+entry:
+ br label %header
+
+header:
+ %conv11 = phi i64 [ 0, %entry ], [ %conv, %latch ]
+ %i.010 = phi i32 [ 0, %entry ], [ %add, %latch ]
+ %add = add i32 %i.010, 1
+ %idxprom = zext i32 %add to i64
+ %arrayidx = getelementptr inbounds i32, ptr %a, i64 %idxprom
+ %ld = load i32, ptr %arrayidx, align 4
+ %uncountable.c = icmp eq i32 %ld, 10
+ br i1 %uncountable.c, label %exit, label %latch
+
+latch:
+ %add2 = add nsw i32 %ld, 1
+ %arrayidx4 = getelementptr inbounds i32, ptr %b, i64 %conv11
+ store i32 %add2, ptr %arrayidx4, align 4
+ %conv = zext i32 %add to i64
+ %cmp = icmp ult i64 %conv, %x
+ br i1 %cmp, label %header, label %exit
+
+exit:
+ ret void
+}
+
+; %i can overflow.
+;
+; We need to check that i doesn't wrap, but we don't need a run-time alias
+; check. We also need an extra no-wrap check to get the backedge taken count.
+define void @test2(i64 %x, ptr %a) {
+; CHECK-LABEL: 'test2'
+; CHECK-NEXT: Determining loop execution counts for: @test2
+; CHECK-NEXT: Loop %header: <multiple exits> Unpredictable backedge-taken count.
+; CHECK-NEXT: exit count for header: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: exit count for latch: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: Loop %header: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT: Loop %header: Unpredictable symbolic max backedge-taken count.
+; CHECK-NEXT: symbolic max exit count for header: ***COULDNOTCOMPUTE***
+; CHECK-NEXT: symbolic max exit count for latch: ***COULDNOTCOMPUTE***
+;
+entry:
+ br label %header
+
+header:
+ %conv11 = phi i64 [ 0, %entry ], [ %conv, %latch ]
+ %i.010 = phi i32 [ 0, %entry ], [ %inc, %latch ]
+ %arrayidx = getelementptr inbounds i32, ptr %a, i64 %conv11
+ %ld = load i32, ptr %arrayidx, align 4
+ %uncountable.c = icmp eq i32 %ld, 10
+ br i1 %uncountable.c, label %exit, label %latch
+
+latch:
+ %add = add nsw i32 %ld, 1
+ store i32 %add, ptr %arrayidx, align 4
+ %inc = add i32 %i.010, 1
+ %conv = zext i32 %inc to i64
+ %cmp = icmp ult i64 %conv, %x
+ br i1 %cmp, label %header, label %exit
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list