1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt "-passes=print<scalar-evolution>" -disable-output < %s 2>&1 | FileCheck %s
4 define void @vscale_gep(ptr %p) {
5 ; CHECK-LABEL: 'vscale_gep'
6 ; CHECK-NEXT: Classifying expressions for: @vscale_gep
7 ; CHECK-NEXT: %1 = getelementptr <vscale x 4 x i32>, ptr null, i32 3
8 ; CHECK-NEXT: --> ((48 * vscale) + null) U: [0,-15) S: [-9223372036854775808,9223372036854775793)
9 ; CHECK-NEXT: %2 = getelementptr <vscale x 1 x i64>, ptr %p, i32 1
10 ; CHECK-NEXT: --> ((8 * vscale) + %p) U: full-set S: full-set
11 ; CHECK-NEXT: Determining loop execution counts for: @vscale_gep
13 getelementptr <vscale x 4 x i32>, ptr null, i32 3
14 getelementptr <vscale x 1 x i64>, ptr %p, i32 1
18 define void @vscale_gep_range(ptr %p) vscale_range(2, 16) {
19 ; CHECK-LABEL: 'vscale_gep_range'
20 ; CHECK-NEXT: Classifying expressions for: @vscale_gep_range
21 ; CHECK-NEXT: %1 = getelementptr <vscale x 4 x i32>, ptr null, i32 3
22 ; CHECK-NEXT: --> ((48 * vscale)<nuw><nsw> + null) U: [96,769) S: [96,769)
23 ; CHECK-NEXT: %2 = getelementptr <vscale x 1 x i64>, ptr %p, i32 1
24 ; CHECK-NEXT: --> ((8 * vscale)<nuw><nsw> + %p) U: full-set S: full-set
25 ; CHECK-NEXT: Determining loop execution counts for: @vscale_gep_range
27 getelementptr <vscale x 4 x i32>, ptr null, i32 3
28 getelementptr <vscale x 1 x i64>, ptr %p, i32 1
32 define i64 @vscale_no_range() {
33 ; CHECK-LABEL: 'vscale_no_range'
34 ; CHECK-NEXT: Classifying expressions for: @vscale_no_range
35 ; CHECK-NEXT: %vscale = call i64 @llvm.vscale.i64()
36 ; CHECK-NEXT: --> vscale U: [1,0) S: [1,0)
37 ; CHECK-NEXT: Determining loop execution counts for: @vscale_no_range
39 %vscale = call i64 @llvm.vscale.i64()
43 define i64 @vscale_min_max_range() vscale_range(2, 16) {
44 ; CHECK-LABEL: 'vscale_min_max_range'
45 ; CHECK-NEXT: Classifying expressions for: @vscale_min_max_range
46 ; CHECK-NEXT: %vscale = call i64 @llvm.vscale.i64()
47 ; CHECK-NEXT: --> vscale U: [2,17) S: [2,17)
48 ; CHECK-NEXT: Determining loop execution counts for: @vscale_min_max_range
50 %vscale = call i64 @llvm.vscale.i64()
54 define i64 @vscale_min_range() vscale_range(2, 0) {
55 ; CHECK-LABEL: 'vscale_min_range'
56 ; CHECK-NEXT: Classifying expressions for: @vscale_min_range
57 ; CHECK-NEXT: %vscale = call i64 @llvm.vscale.i64()
58 ; CHECK-NEXT: --> vscale U: [2,0) S: [2,0)
59 ; CHECK-NEXT: Determining loop execution counts for: @vscale_min_range
61 %vscale = call i64 @llvm.vscale.i64()
65 define i64 @vscale_exact_range() vscale_range(2) {
66 ; CHECK-LABEL: 'vscale_exact_range'
67 ; CHECK-NEXT: Classifying expressions for: @vscale_exact_range
68 ; CHECK-NEXT: %vscale = call i64 @llvm.vscale.i64()
69 ; CHECK-NEXT: --> vscale U: [2,3) S: [2,3)
70 ; CHECK-NEXT: Determining loop execution counts for: @vscale_exact_range
72 %vscale = call i64 @llvm.vscale.i64()
76 define void @vscale_step_ne_tripcount(i64 %N) vscale_range(2, 1024) {
77 ; CHECK-LABEL: 'vscale_step_ne_tripcount'
78 ; CHECK-NEXT: Classifying expressions for: @vscale_step_ne_tripcount
79 ; CHECK-NEXT: %0 = sub i64 -1, %N
80 ; CHECK-NEXT: --> (-1 + (-1 * %N)) U: full-set S: full-set
81 ; CHECK-NEXT: %1 = call i64 @llvm.vscale.i64()
82 ; CHECK-NEXT: --> vscale U: [2,1025) S: [2,1025)
83 ; CHECK-NEXT: %2 = mul i64 %1, 4
84 ; CHECK-NEXT: --> (4 * vscale)<nuw><nsw> U: [8,4097) S: [8,4097)
85 ; CHECK-NEXT: %4 = sub i64 %2, 1
86 ; CHECK-NEXT: --> (-1 + (4 * vscale)<nuw><nsw>)<nsw> U: [7,4096) S: [7,4096)
87 ; CHECK-NEXT: %n.rnd.up = add i64 %N, %4
88 ; CHECK-NEXT: --> (-1 + (4 * vscale)<nuw><nsw> + %N) U: full-set S: full-set
89 ; CHECK-NEXT: %n.mod.vf = urem i64 %n.rnd.up, %2
90 ; CHECK-NEXT: --> (-1 + (vscale * (4 + (-4 * ((-1 + (4 * vscale)<nuw><nsw> + %N) /u (4 * vscale)<nuw><nsw>))<nsw>)<nsw>) + %N) U: full-set S: full-set
91 ; CHECK-NEXT: %n.vec = sub i64 %n.rnd.up, %n.mod.vf
92 ; CHECK-NEXT: --> (4 * vscale * ((-1 + (4 * vscale)<nuw><nsw> + %N) /u (4 * vscale)<nuw><nsw>)) U: [0,-3) S: [-9223372036854775808,9223372036854775805)
93 ; CHECK-NEXT: %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
94 ; CHECK-NEXT: --> {0,+,(4 * vscale)<nuw><nsw>}<nuw><%vector.body> U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: (4 * vscale * ((-1 * vscale * (4 + (-4 * ((-1 + (4 * vscale)<nuw><nsw> + %N) /u (4 * vscale)<nuw><nsw>))<nsw>)<nsw>) /u (4 * vscale)<nuw><nsw>)) LoopDispositions: { %vector.body: Computable }
95 ; CHECK-NEXT: %index.next = add nuw i64 %index, %2
96 ; CHECK-NEXT: --> {(4 * vscale)<nuw><nsw>,+,(4 * vscale)<nuw><nsw>}<nuw><%vector.body> U: [8,-3) S: [-9223372036854775808,9223372036854775805) Exits: (vscale * (4 + (4 * ((-1 * vscale * (4 + (-4 * ((-1 + (4 * vscale)<nuw><nsw> + %N) /u (4 * vscale)<nuw><nsw>))<nsw>)<nsw>) /u (4 * vscale)<nuw><nsw>))<nuw><nsw>)<nuw>) LoopDispositions: { %vector.body: Computable }
97 ; CHECK-NEXT: Determining loop execution counts for: @vscale_step_ne_tripcount
98 ; CHECK-NEXT: Loop %vector.body: backedge-taken count is ((-1 * vscale * (4 + (-4 * ((-1 + (4 * vscale)<nuw><nsw> + %N) /u (4 * vscale)<nuw><nsw>))<nsw>)<nsw>) /u (4 * vscale)<nuw><nsw>)
99 ; CHECK-NEXT: Loop %vector.body: constant max backedge-taken count is i64 2305843009213693951
100 ; CHECK-NEXT: Loop %vector.body: symbolic max backedge-taken count is ((-1 * vscale * (4 + (-4 * ((-1 + (4 * vscale)<nuw><nsw> + %N) /u (4 * vscale)<nuw><nsw>))<nsw>)<nsw>) /u (4 * vscale)<nuw><nsw>)
101 ; CHECK-NEXT: Loop %vector.body: Trip multiple is 1
105 %1 = call i64 @llvm.vscale.i64()
107 %3 = icmp ult i64 %0, %2
108 br i1 %3, label %loop.exit, label %vector.ph
110 vector.ph: ; preds = %entry
112 %n.rnd.up = add i64 %N, %8
113 %n.mod.vf = urem i64 %n.rnd.up, %2
114 %n.vec = sub i64 %n.rnd.up, %n.mod.vf
115 br label %vector.body
117 vector.body: ; preds = %vector.body, %vector.ph
118 %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
119 %index.next = add nuw i64 %index, %2
120 %22 = icmp eq i64 %index.next, %n.vec
121 br i1 %22, label %loop.exit, label %vector.body
127 declare i64 @llvm.vscale.i64()