Skip to content

Commit 31c304b

Browse files
committed
[SCEV] Migrate some tests to be autogenerated
In advance of a change which needs to update these. This batch was the "easy" ones, I'll be landing the harder set a few a time for easier review.
1 parent 889d99a commit 31c304b

14 files changed

+434
-149
lines changed

llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
2-
3-
; CHECK: Loop %bb: backedge-taken count is ((-5 + %x) /u 3)
4-
; CHECK: Loop %bb: constant max backedge-taken count is 1431655764
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
53

64

75
; ScalarEvolution can't compute a trip count because it doesn't know if
86
; dividing by the stride will have a remainder. This could theoretically
97
; be teaching it how to use a more elaborate trip count computation.
108

119
define i32 @f(i32 %x) nounwind readnone {
10+
;
11+
; CHECK-LABEL: 'f'
12+
; CHECK-NEXT: Determining loop execution counts for: @f
13+
; CHECK-NEXT: Loop %bb: backedge-taken count is ((-5 + %x) /u 3)
14+
; CHECK-NEXT: Loop %bb: constant max backedge-taken count is 1431655764
15+
; CHECK-NEXT: Loop %bb: symbolic max backedge-taken count is ((-5 + %x) /u 3)
16+
; CHECK-NEXT: Loop %bb: Predicated backedge-taken count is ((-5 + %x) /u 3)
17+
; CHECK-NEXT: Predicates:
18+
; CHECK-NEXT: Loop %bb: Trip multiple is 1
19+
;
1220
entry:
1321
%0 = icmp ugt i32 %x, 4 ; <i1> [#uses=1]
1422
br i1 %0, label %bb.nph, label %bb2

llvm/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 2>&1 | FileCheck %s
2-
3-
; CHECK: Loop %bb: backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))
4-
; CHECK: Loop %bb: constant max backedge-taken count is 334
5-
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 2>&1 | FileCheck %s
63

74
; This is a tricky testcase for unsigned wrap detection which ScalarEvolution
85
; doesn't yet know how to do.
96

107
define i32 @f(i32 %x) nounwind readnone {
8+
;
9+
; CHECK-LABEL: 'f'
10+
; CHECK-NEXT: Determining loop execution counts for: @f
11+
; CHECK-NEXT: Loop %bb: backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))
12+
; CHECK-NEXT: Loop %bb: constant max backedge-taken count is 334
13+
; CHECK-NEXT: Loop %bb: symbolic max backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))
14+
; CHECK-NEXT: Loop %bb: Predicated backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))
15+
; CHECK-NEXT: Predicates:
16+
; CHECK-NEXT: Loop %bb: Trip multiple is 1
17+
;
1118
entry:
1219
%0 = icmp ugt i32 %x, 999 ; <i1> [#uses=1]
1320
br i1 %0, label %bb2, label %bb.nph

llvm/test/Analysis/ScalarEvolution/exhaustive-trip-counts.ll

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
23

34
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45
target triple = "x86_64-unknown-linux-gnu"
56

67
define void @f_0() {
7-
; CHECK-LABEL: Printing analysis 'Scalar Evolution Analysis' for function 'f_0':
8-
; CHECK: Loop %for.body: backedge-taken count is 5
9-
; CHECK: Loop %for.body: constant max backedge-taken count is 5
10-
; CHECK: Loop %for.body: Predicated backedge-taken count is 5
11-
8+
;
9+
; CHECK-LABEL: 'f_0'
10+
; CHECK-NEXT: Determining loop execution counts for: @f_0
11+
; CHECK-NEXT: Loop %for.body: backedge-taken count is 5
12+
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 5
13+
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is 5
14+
; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is 5
15+
; CHECK-NEXT: Predicates:
16+
; CHECK-NEXT: Loop %for.body: Trip multiple is 6
17+
;
1218
entry:
1319
br label %for.body
1420

llvm/test/Analysis/ScalarEvolution/exponential-behavior.ll

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
2-
3-
; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'f':
4-
5-
; CHECK: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
6-
; CHECK: Loop %loop: constant max backedge-taken count is 0
7-
; CHECK: Loop %loop: Unpredictable predicated backedge-taken count.
8-
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
93

104
define void @f(i32 %n, ptr %ptr) {
5+
;
6+
; CHECK-LABEL: 'f'
7+
; CHECK-NEXT: Determining loop execution counts for: @f
8+
; CHECK-NEXT: Loop %loop: <multiple exits> Unpredictable backedge-taken count.
9+
; CHECK-NEXT: exit count for loop: 0
10+
; CHECK-NEXT: exit count for be: ***COULDNOTCOMPUTE***
11+
; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 0
12+
; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is 0
13+
; CHECK-NEXT: symbolic max exit count for loop: 0
14+
; CHECK-NEXT: symbolic max exit count for be: ***COULDNOTCOMPUTE***
15+
; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
16+
;
1117
entry:
1218
br label %loop
1319

llvm/test/Analysis/ScalarEvolution/load-with-range-metadata.ll

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
23

34
define i32 @slt_trip_count_with_range(ptr %ptr0, ptr %ptr1) {
4-
; CHECK-LABEL: slt_trip_count_with_range
5+
;
6+
; CHECK-LABEL: 'slt_trip_count_with_range'
7+
; CHECK-NEXT: Determining loop execution counts for: @slt_trip_count_with_range
8+
; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %limit)<nsw>
9+
; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 98
10+
; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %limit)<nsw>
11+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %limit)<nsw>
12+
; CHECK-NEXT: Predicates:
13+
; CHECK-NEXT: Loop %loop: Trip multiple is 1
14+
;
515
entry:
616
%limit = load i32, ptr %ptr0, !range !0
717
br label %loop
818

919
loop:
10-
; CHECK: Loop %loop: constant max backedge-taken count is 98
1120
%index = phi i32 [ 0, %entry ], [ %index.inc, %loop ]
1221
%index.inc = add i32 %index, 1
1322
%continue = icmp slt i32 %index.inc, %limit
@@ -18,13 +27,21 @@ define i32 @slt_trip_count_with_range(ptr %ptr0, ptr %ptr1) {
1827
}
1928

2029
define i32 @ult_trip_count_with_range(ptr %ptr0, ptr %ptr1) {
21-
; CHECK-LABEL: ult_trip_count_with_range
30+
;
31+
; CHECK-LABEL: 'ult_trip_count_with_range'
32+
; CHECK-NEXT: Determining loop execution counts for: @ult_trip_count_with_range
33+
; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + %limit)<nsw>
34+
; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 98
35+
; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + %limit)<nsw>
36+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %limit)<nsw>
37+
; CHECK-NEXT: Predicates:
38+
; CHECK-NEXT: Loop %loop: Trip multiple is 1
39+
;
2240
entry:
2341
%limit = load i32, ptr %ptr0, !range !0
2442
br label %loop
2543

2644
loop:
27-
; CHECK: Loop %loop: constant max backedge-taken count is 98
2845
%index = phi i32 [ 0, %entry ], [ %index.inc, %loop ]
2946
%index.inc = add i32 %index, 1
3047
%continue = icmp ult i32 %index.inc, %limit

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 2>&1 | FileCheck %s
23

34
; ScalarEvolution should be able to understand the loop and eliminate the casts.
45

56
target datalayout = "e-p:32:32:32-p1:16:16:16-p2:8:8:8-p4:64:64:64-n16:32:64"
67

7-
; CHECK: {%d,+,4}<%bb>{{ U: [^ ]+ S: [^ ]+}}{{ *}} Exits: (-4 + (4 * (trunc i32 %n to i16)) + %d)
8-
9-
108
define void @foo(ptr addrspace(1) nocapture %d, i32 %n) nounwind {
11-
; CHECK: @foo
9+
;
10+
; CHECK-LABEL: 'foo'
11+
; CHECK-NEXT: Determining loop execution counts for: @foo
12+
; CHECK-NEXT: Loop %bb: backedge-taken count is (-1 + %n)
13+
; CHECK-NEXT: Loop %bb: constant max backedge-taken count is 2147483646
14+
; CHECK-NEXT: Loop %bb: symbolic max backedge-taken count is (-1 + %n)
15+
; CHECK-NEXT: Loop %bb: Predicated backedge-taken count is (-1 + %n)
16+
; CHECK-NEXT: Predicates:
17+
; CHECK-NEXT: Loop %bb: Trip multiple is 1
18+
;
1219
entry:
1320
%0 = icmp sgt i32 %n, 0 ; <i1> [#uses=1]
1421
br i1 %0, label %bb.nph, label %return
@@ -39,7 +46,16 @@ return: ; preds = %bb1.return_crit_edge, %entry
3946
}
4047

4148
define void @test(ptr addrspace(1) %a, i32 %n) nounwind {
42-
; CHECK: @test
49+
;
50+
; CHECK-LABEL: 'test'
51+
; CHECK-NEXT: Determining loop execution counts for: @test
52+
; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + (zext i32 %n to i64))<nsw>
53+
; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
54+
; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + (zext i32 %n to i64))<nsw>
55+
; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + (zext i32 %n to i64))<nsw>
56+
; CHECK-NEXT: Predicates:
57+
; CHECK-NEXT: Loop %for.body: Trip multiple is 1
58+
;
4359
entry:
4460
%cmp1 = icmp sgt i32 %n, 0
4561
br i1 %cmp1, label %for.body.lr.ph, label %for.end
@@ -62,7 +78,3 @@ for.cond.for.end_crit_edge: ; preds = %for.body
6278
for.end: ; preds = %for.cond.for.end_crit_edge, %entry
6379
ret void
6480
}
65-
66-
; CHECK: Determining loop execution counts for: @test
67-
; CHECK-NEXT: backedge-taken count is
68-
; CHECK-NEXT: constant max backedge-taken count is 2147483646

llvm/test/Analysis/ScalarEvolution/pr25369.ll

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1-
; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
23

34
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
45
target triple = "x86_64-unknown-linux-gnu"
56

67
define void @hoge1() {
7-
; CHECK-LABEL: Classifying expressions for: @hoge1
8+
;
9+
; CHECK-LABEL: 'hoge1'
10+
; CHECK-NEXT: Determining loop execution counts for: @hoge1
11+
; CHECK-NEXT: Loop %bb13: backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6)
12+
; CHECK-NEXT: Loop %bb13: constant max backedge-taken count is -1
13+
; CHECK-NEXT: Loop %bb13: symbolic max backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6)
14+
; CHECK-NEXT: Loop %bb13: Predicated backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6)
15+
; CHECK-NEXT: Predicates:
16+
; CHECK-NEXT: Loop %bb13: Trip multiple is 1
17+
; CHECK-NEXT: Loop %bb4: backedge-taken count is 20
18+
; CHECK-NEXT: Loop %bb4: constant max backedge-taken count is 20
19+
; CHECK-NEXT: Loop %bb4: symbolic max backedge-taken count is 20
20+
; CHECK-NEXT: Loop %bb4: Predicated backedge-taken count is 20
21+
; CHECK-NEXT: Predicates:
22+
; CHECK-NEXT: Loop %bb4: Trip multiple is 21
23+
; CHECK-NEXT: Loop %bb2: Unpredictable backedge-taken count.
24+
; CHECK-NEXT: Loop %bb2: Unpredictable constant max backedge-taken count.
25+
; CHECK-NEXT: Loop %bb2: Unpredictable symbolic max backedge-taken count.
26+
; CHECK-NEXT: Loop %bb2: Unpredictable predicated backedge-taken count.
27+
;
828
bb:
929
br i1 undef, label %bb4, label %bb2
1030

@@ -26,8 +46,6 @@ bb4: ; preds = %bb4, %bb2, %bb
2646
%tmp12 = icmp eq i64 %tmp11, 64
2747
br i1 %tmp12, label %bb3, label %bb4
2848

29-
; CHECK: Loop %bb4: backedge-taken count is 20
30-
; CHECK: Loop %bb4: constant max backedge-taken count is 20
3149

3250
bb13: ; preds = %bb13, %bb3
3351
%tmp14 = phi i64 [ 0, %bb3 ], [ %tmp15, %bb13 ]
@@ -41,7 +59,24 @@ bb18: ; preds = %bb13
4159
}
4260

4361
define void @hoge2() {
44-
; CHECK-LABEL: Classifying expressions for: @hoge2
62+
;
63+
; CHECK-LABEL: 'hoge2'
64+
; CHECK-NEXT: Determining loop execution counts for: @hoge2
65+
; CHECK-NEXT: Loop %bb13: backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6)
66+
; CHECK-NEXT: Loop %bb13: constant max backedge-taken count is -1
67+
; CHECK-NEXT: Loop %bb13: symbolic max backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6)
68+
; CHECK-NEXT: Loop %bb13: Predicated backedge-taken count is (-2 + (2 * undef) + %tmp7 + %tmp6)
69+
; CHECK-NEXT: Predicates:
70+
; CHECK-NEXT: Loop %bb13: Trip multiple is 1
71+
; CHECK-NEXT: Loop %bb4: Unpredictable backedge-taken count.
72+
; CHECK-NEXT: Loop %bb4: Unpredictable constant max backedge-taken count.
73+
; CHECK-NEXT: Loop %bb4: Unpredictable symbolic max backedge-taken count.
74+
; CHECK-NEXT: Loop %bb4: Unpredictable predicated backedge-taken count.
75+
; CHECK-NEXT: Loop %bb2: Unpredictable backedge-taken count.
76+
; CHECK-NEXT: Loop %bb2: Unpredictable constant max backedge-taken count.
77+
; CHECK-NEXT: Loop %bb2: Unpredictable symbolic max backedge-taken count.
78+
; CHECK-NEXT: Loop %bb2: Unpredictable predicated backedge-taken count.
79+
;
4580
bb:
4681
br i1 undef, label %bb4, label %bb2
4782

@@ -63,8 +98,6 @@ bb4: ; preds = %bb4, %bb2, %bb
6398
%tmp12 = icmp eq i64 %tmp11, 64
6499
br i1 %tmp12, label %bb3, label %bb4
65100

66-
; CHECK: Loop %bb4: Unpredictable backedge-taken count.
67-
; CHECK: Loop %bb4: Unpredictable constant max backedge-taken count.
68101

69102
bb13: ; preds = %bb13, %bb3
70103
%tmp14 = phi i64 [ 0, %bb3 ], [ %tmp15, %bb13 ]

0 commit comments

Comments
 (0)