1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
4 define void @s32_max1(i32 %n, ptr %p) {
5 ; CHECK-LABEL: 's32_max1'
6 ; CHECK-NEXT: Determining loop execution counts for: @s32_max1
7 ; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((1 + %n) smax %n))
8 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 1, actual taken count either this or zero.
9 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((1 + %n) smax %n)), actual taken count either this or zero.
10 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
17 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
18 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
19 store i32 %i.0, ptr %arrayidx, align 4
20 %inc = add i32 %i.0, 1
21 %cmp = icmp slt i32 %i.0, %add
22 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 1 times
28 define void @s32_max2(i32 %n, ptr %p) {
29 ; CHECK-LABEL: 's32_max2'
30 ; CHECK-NEXT: Determining loop execution counts for: @s32_max2
31 ; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((2 + %n) smax %n))
32 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 2, actual taken count either this or zero.
33 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((2 + %n) smax %n)), actual taken count either this or zero.
34 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
41 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
42 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
43 store i32 %i.0, ptr %arrayidx, align 4
44 %inc = add i32 %i.0, 1
45 %cmp = icmp slt i32 %i.0, %add
46 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 2 times
52 define void @s32_maxx(i32 %n, i32 %x, ptr %p) {
53 ; CHECK-LABEL: 's32_maxx'
54 ; CHECK-NEXT: Determining loop execution counts for: @s32_maxx
55 ; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((%n + %x) smax %n))
56 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 -1
57 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((%n + %x) smax %n))
58 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
65 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
66 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
67 store i32 %i.0, ptr %arrayidx, align 4
68 %inc = add i32 %i.0, 1
69 %cmp = icmp slt i32 %i.0, %add
70 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or x times
76 define void @s32_max2_unpredictable_exit(i32 %n, i32 %x, ptr %p) {
77 ; CHECK-LABEL: 's32_max2_unpredictable_exit'
78 ; CHECK-NEXT: Determining loop execution counts for: @s32_max2_unpredictable_exit
79 ; CHECK-NEXT: Loop %do.body: <multiple exits> backedge-taken count is (((-1 * %n) + ((2 + %n) smax %n)) umin ((-1 * %n) + %x))
80 ; CHECK-NEXT: exit count for do.body: ((-1 * %n) + %x)
81 ; CHECK-NEXT: exit count for if.end: ((-1 * %n) + ((2 + %n) smax %n))
82 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 2
83 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is (((-1 * %n) + ((2 + %n) smax %n)) umin ((-1 * %n) + %x))
84 ; CHECK-NEXT: symbolic max exit count for do.body: ((-1 * %n) + %x)
85 ; CHECK-NEXT: symbolic max exit count for if.end: ((-1 * %n) + ((2 + %n) smax %n))
86 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
93 %i.0 = phi i32 [ %n, %entry ], [ %inc, %if.end ]
94 %cmp = icmp eq i32 %i.0, %x
95 br i1 %cmp, label %do.end, label %if.end ; unpredictable
98 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
99 store i32 %i.0, ptr %arrayidx, align 4
100 %inc = add i32 %i.0, 1
101 %cmp1 = icmp slt i32 %i.0, %add
102 br i1 %cmp1, label %do.body, label %do.end ; taken either 0 or 2 times
108 define void @u32_max1(i32 %n, ptr %p) {
109 ; CHECK-LABEL: 'u32_max1'
110 ; CHECK-NEXT: Determining loop execution counts for: @u32_max1
111 ; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((1 + %n) umax %n))
112 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 1, actual taken count either this or zero.
113 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((1 + %n) umax %n)), actual taken count either this or zero.
114 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
121 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
122 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
123 store i32 %i.0, ptr %arrayidx, align 4
124 %inc = add i32 %i.0, 1
125 %cmp = icmp ult i32 %i.0, %add
126 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 1 times
132 define void @u32_max2(i32 %n, ptr %p) {
133 ; CHECK-LABEL: 'u32_max2'
134 ; CHECK-NEXT: Determining loop execution counts for: @u32_max2
135 ; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((2 + %n) umax %n))
136 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 2, actual taken count either this or zero.
137 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((2 + %n) umax %n)), actual taken count either this or zero.
138 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
145 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
146 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
147 store i32 %i.0, ptr %arrayidx, align 4
148 %inc = add i32 %i.0, 1
149 %cmp = icmp ult i32 %i.0, %add
150 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or 2 times
156 define void @u32_maxx(i32 %n, i32 %x, ptr %p) {
157 ; CHECK-LABEL: 'u32_maxx'
158 ; CHECK-NEXT: Determining loop execution counts for: @u32_maxx
159 ; CHECK-NEXT: Loop %do.body: backedge-taken count is ((-1 * %n) + ((%n + %x) umax %n))
160 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 -1
161 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is ((-1 * %n) + ((%n + %x) umax %n))
162 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
165 %add = add i32 %x, %n
169 %i.0 = phi i32 [ %n, %entry ], [ %inc, %do.body ]
170 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
171 store i32 %i.0, ptr %arrayidx, align 4
172 %inc = add i32 %i.0, 1
173 %cmp = icmp ult i32 %i.0, %add
174 br i1 %cmp, label %do.body, label %do.end ; taken either 0 or x times
180 define void @u32_max2_unpredictable_exit(i32 %n, i32 %x, ptr %p) {
181 ; CHECK-LABEL: 'u32_max2_unpredictable_exit'
182 ; CHECK-NEXT: Determining loop execution counts for: @u32_max2_unpredictable_exit
183 ; CHECK-NEXT: Loop %do.body: <multiple exits> backedge-taken count is (((-1 * %n) + ((2 + %n) umax %n)) umin ((-1 * %n) + %x))
184 ; CHECK-NEXT: exit count for do.body: ((-1 * %n) + %x)
185 ; CHECK-NEXT: exit count for if.end: ((-1 * %n) + ((2 + %n) umax %n))
186 ; CHECK-NEXT: Loop %do.body: constant max backedge-taken count is i32 2
187 ; CHECK-NEXT: Loop %do.body: symbolic max backedge-taken count is (((-1 * %n) + ((2 + %n) umax %n)) umin ((-1 * %n) + %x))
188 ; CHECK-NEXT: symbolic max exit count for do.body: ((-1 * %n) + %x)
189 ; CHECK-NEXT: symbolic max exit count for if.end: ((-1 * %n) + ((2 + %n) umax %n))
190 ; CHECK-NEXT: Loop %do.body: Trip multiple is 1
197 %i.0 = phi i32 [ %n, %entry ], [ %inc, %if.end ]
198 %cmp = icmp eq i32 %i.0, %x
199 br i1 %cmp, label %do.end, label %if.end ; unpredictable
202 %arrayidx = getelementptr i32, ptr %p, i32 %i.0
203 store i32 %i.0, ptr %arrayidx, align 4
204 %inc = add i32 %i.0, 1
205 %cmp1 = icmp ult i32 %i.0, %add
206 br i1 %cmp1, label %do.body, label %do.end ; taken either 0 or 2 times