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
6 define void @test_trip_multiple_4(i32 %num) {
7 ; CHECK-LABEL: 'test_trip_multiple_4'
8 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4
9 ; CHECK-NEXT: %u = urem i32 %num, 4
10 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
11 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
12 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
13 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
14 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
15 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4
16 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
17 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
18 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
19 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
20 ; CHECK-NEXT: Predicates:
21 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
25 %cmp = icmp eq i32 %u, 0
26 tail call void @llvm.assume(i1 %cmp)
27 %cmp.1 = icmp uge i32 %num, 4
28 tail call void @llvm.assume(i1 %cmp.1)
32 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
33 %inc = add nuw nsw i32 %i.010, 1
34 %cmp2 = icmp ult i32 %inc, %num
35 br i1 %cmp2, label %for.body, label %exit
41 define void @test_trip_multiple_4_guard(i32 %num) {
42 ; CHECK-LABEL: 'test_trip_multiple_4_guard'
43 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_guard
44 ; CHECK-NEXT: %u = urem i32 %num, 4
45 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
46 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
47 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
48 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
49 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
50 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_guard
51 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
52 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
53 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
54 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
55 ; CHECK-NEXT: Predicates:
56 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
60 %cmp = icmp eq i32 %u, 0
61 call void(i1, ...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
62 %cmp.1 = icmp uge i32 %num, 4
63 call void(i1, ...) @llvm.experimental.guard(i1 %cmp.1) [ "deopt"() ]
67 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
68 %inc = add nuw nsw i32 %i.010, 1
69 %cmp2 = icmp ult i32 %inc, %num
70 br i1 %cmp2, label %for.body, label %exit
77 define void @test_trip_multiple_4_ugt_5(i32 %num) {
78 ; CHECK-LABEL: 'test_trip_multiple_4_ugt_5'
79 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_ugt_5
80 ; CHECK-NEXT: %u = urem i32 %num, 4
81 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
82 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
83 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
84 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
85 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
86 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_ugt_5
87 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
88 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
89 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
90 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
91 ; CHECK-NEXT: Predicates:
92 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
96 %cmp = icmp eq i32 %u, 0
97 tail call void @llvm.assume(i1 %cmp)
98 %cmp.1 = icmp ugt i32 %num, 5
99 tail call void @llvm.assume(i1 %cmp.1)
103 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
104 %inc = add nuw nsw i32 %i.010, 1
105 %cmp2 = icmp ult i32 %inc, %num
106 br i1 %cmp2, label %for.body, label %exit
112 define void @test_trip_multiple_4_ugt_5_order_swapped(i32 %num) {
113 ; TODO: Trip multiple can be 4, it is missed due to the processing order of the assumes.
114 ; CHECK-LABEL: 'test_trip_multiple_4_ugt_5_order_swapped'
115 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_ugt_5_order_swapped
116 ; CHECK-NEXT: %u = urem i32 %num, 4
117 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
118 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
119 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
120 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
121 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
122 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_ugt_5_order_swapped
123 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
124 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
125 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
126 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
127 ; CHECK-NEXT: Predicates:
128 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
131 %u = urem i32 %num, 4
132 %cmp.1 = icmp ugt i32 %num, 5
133 tail call void @llvm.assume(i1 %cmp.1)
134 %cmp = icmp eq i32 %u, 0
135 tail call void @llvm.assume(i1 %cmp)
139 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
140 %inc = add nuw nsw i32 %i.010, 1
141 %cmp2 = icmp ult i32 %inc, %num
142 br i1 %cmp2, label %for.body, label %exit
148 define void @test_trip_multiple_4_sgt_5(i32 %num) {
149 ; CHECK-LABEL: 'test_trip_multiple_4_sgt_5'
150 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_sgt_5
151 ; CHECK-NEXT: %u = urem i32 %num, 4
152 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
153 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
154 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
155 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
156 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
157 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_sgt_5
158 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
159 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
160 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
161 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
162 ; CHECK-NEXT: Predicates:
163 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
166 %u = urem i32 %num, 4
167 %cmp = icmp eq i32 %u, 0
168 tail call void @llvm.assume(i1 %cmp)
169 %cmp.1 = icmp sgt i32 %num, 5
170 tail call void @llvm.assume(i1 %cmp.1)
174 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
175 %inc = add nuw nsw i32 %i.010, 1
176 %cmp2 = icmp slt i32 %inc, %num
177 br i1 %cmp2, label %for.body, label %exit
183 define void @test_trip_multiple_4_sgt_5_order_swapped(i32 %num) {
184 ; TODO: Trip multiple can be 4, it is missed due to the processing order of the assumes.
185 ; CHECK-LABEL: 'test_trip_multiple_4_sgt_5_order_swapped'
186 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_sgt_5_order_swapped
187 ; CHECK-NEXT: %u = urem i32 %num, 4
188 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
189 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
190 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
191 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
192 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
193 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_sgt_5_order_swapped
194 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
195 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
196 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
197 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
198 ; CHECK-NEXT: Predicates:
199 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
202 %u = urem i32 %num, 4
203 %cmp.1 = icmp sgt i32 %num, 5
204 tail call void @llvm.assume(i1 %cmp.1)
205 %cmp = icmp eq i32 %u, 0
206 tail call void @llvm.assume(i1 %cmp)
210 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
211 %inc = add nuw nsw i32 %i.010, 1
212 %cmp2 = icmp slt i32 %inc, %num
213 br i1 %cmp2, label %for.body, label %exit
219 define void @test_trip_multiple_4_uge_5(i32 %num) {
220 ; CHECK-LABEL: 'test_trip_multiple_4_uge_5'
221 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_uge_5
222 ; CHECK-NEXT: %u = urem i32 %num, 4
223 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
224 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
225 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
226 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
227 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
228 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_uge_5
229 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
230 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
231 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
232 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
233 ; CHECK-NEXT: Predicates:
234 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
237 %u = urem i32 %num, 4
238 %cmp = icmp eq i32 %u, 0
239 tail call void @llvm.assume(i1 %cmp)
240 %cmp.1 = icmp uge i32 %num, 5
241 tail call void @llvm.assume(i1 %cmp.1)
245 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
246 %inc = add nuw nsw i32 %i.010, 1
247 %cmp2 = icmp ult i32 %inc, %num
248 br i1 %cmp2, label %for.body, label %exit
254 define void @test_trip_multiple_4_uge_5_order_swapped(i32 %num) {
255 ; TODO: Trip multiple can be 4, it is missed due to the processing order of the assumes.
256 ; CHECK-LABEL: 'test_trip_multiple_4_uge_5_order_swapped'
257 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_uge_5_order_swapped
258 ; CHECK-NEXT: %u = urem i32 %num, 4
259 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
260 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
261 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
262 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
263 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
264 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_uge_5_order_swapped
265 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
266 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
267 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
268 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
269 ; CHECK-NEXT: Predicates:
270 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
273 %u = urem i32 %num, 4
274 %cmp = icmp eq i32 %u, 0
275 %cmp.1 = icmp uge i32 %num, 5
276 tail call void @llvm.assume(i1 %cmp.1)
277 tail call void @llvm.assume(i1 %cmp)
281 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
282 %inc = add nuw nsw i32 %i.010, 1
283 %cmp2 = icmp ult i32 %inc, %num
284 br i1 %cmp2, label %for.body, label %exit
290 define void @test_trip_multiple_4_sge_5(i32 %num) {
291 ; TODO: Trip multiple can be 4, it is missed due to the processing order of the assumes.
292 ; CHECK-LABEL: 'test_trip_multiple_4_sge_5'
293 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_sge_5
294 ; CHECK-NEXT: %u = urem i32 %num, 4
295 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
296 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
297 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
298 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
299 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
300 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_sge_5
301 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
302 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
303 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
304 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
305 ; CHECK-NEXT: Predicates:
306 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
309 %u = urem i32 %num, 4
310 %cmp = icmp eq i32 %u, 0
311 tail call void @llvm.assume(i1 %cmp)
312 %cmp.1 = icmp sge i32 %num, 5
313 tail call void @llvm.assume(i1 %cmp.1)
317 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
318 %inc = add nuw nsw i32 %i.010, 1
319 %cmp2 = icmp slt i32 %inc, %num
320 br i1 %cmp2, label %for.body, label %exit
326 define void @test_trip_multiple_4_sge_5_order_swapped(i32 %num) {
327 ; CHECK-LABEL: 'test_trip_multiple_4_sge_5_order_swapped'
328 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_sge_5_order_swapped
329 ; CHECK-NEXT: %u = urem i32 %num, 4
330 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
331 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
332 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
333 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
334 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
335 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_sge_5_order_swapped
336 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
337 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is 2147483646
338 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
339 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
340 ; CHECK-NEXT: Predicates:
341 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
344 %u = urem i32 %num, 4
345 %cmp = icmp eq i32 %u, 0
346 %cmp.1 = icmp sge i32 %num, 5
347 tail call void @llvm.assume(i1 %cmp.1)
348 tail call void @llvm.assume(i1 %cmp)
352 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
353 %inc = add nuw nsw i32 %i.010, 1
354 %cmp2 = icmp slt i32 %inc, %num
355 br i1 %cmp2, label %for.body, label %exit
361 ; Same as @test_trip_multiple_4 but with the icmp operands swapped.
362 define void @test_trip_multiple_4_icmp_ops_swapped(i32 %num) {
363 ; CHECK-LABEL: 'test_trip_multiple_4_icmp_ops_swapped'
364 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_icmp_ops_swapped
365 ; CHECK-NEXT: %u = urem i32 %num, 4
366 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
367 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
368 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
369 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
370 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
371 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_icmp_ops_swapped
372 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
373 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
374 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
375 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
376 ; CHECK-NEXT: Predicates:
377 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
380 %u = urem i32 %num, 4
381 %cmp = icmp eq i32 0, %u
382 tail call void @llvm.assume(i1 %cmp)
383 %cmp.1 = icmp uge i32 %num, 4
384 tail call void @llvm.assume(i1 %cmp.1)
388 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
389 %inc = add nuw nsw i32 %i.010, 1
390 %cmp2 = icmp ult i32 %inc, %num
391 br i1 %cmp2, label %for.body, label %exit
397 define void @test_trip_multiple_4_upper_lower_bounds(i32 %num) {
398 ; CHECK-LABEL: 'test_trip_multiple_4_upper_lower_bounds'
399 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_upper_lower_bounds
400 ; CHECK-NEXT: %u = urem i32 %num, 4
401 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
402 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
403 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
404 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
405 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
406 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_upper_lower_bounds
407 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
408 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
409 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
410 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
411 ; CHECK-NEXT: Predicates:
412 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
415 %cmp.1 = icmp uge i32 %num, 5
416 tail call void @llvm.assume(i1 %cmp.1)
417 %u = urem i32 %num, 4
418 %cmp = icmp eq i32 %u, 0
419 tail call void @llvm.assume(i1 %cmp)
420 %cmp.2 = icmp ult i32 %num, 59000
421 tail call void @llvm.assume(i1 %cmp.2)
425 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
426 %inc = add nuw nsw i32 %i.010, 1
427 %cmp2 = icmp ult i32 %inc, %num
428 br i1 %cmp2, label %for.body, label %exit
434 define void @test_trip_multiple_4_upper_lower_bounds_swapped1(i32 %num) {
435 ; CHECK-LABEL: 'test_trip_multiple_4_upper_lower_bounds_swapped1'
436 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_upper_lower_bounds_swapped1
437 ; CHECK-NEXT: %u = urem i32 %num, 4
438 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
439 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
440 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
441 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
442 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
443 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_upper_lower_bounds_swapped1
444 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
445 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
446 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
447 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
448 ; CHECK-NEXT: Predicates:
449 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
452 %cmp.1 = icmp uge i32 %num, 5
453 tail call void @llvm.assume(i1 %cmp.1)
454 %u = urem i32 %num, 4
455 %cmp = icmp eq i32 %u, 0
456 tail call void @llvm.assume(i1 %cmp)
457 %cmp.2 = icmp ult i32 %num, 59000
458 tail call void @llvm.assume(i1 %cmp.2)
462 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
463 %inc = add nuw nsw i32 %i.010, 1
464 %cmp2 = icmp ult i32 %inc, %num
465 br i1 %cmp2, label %for.body, label %exit
471 define void @test_trip_multiple_4_upper_lower_bounds_swapped2(i32 %num) {
472 ; CHECK-LABEL: 'test_trip_multiple_4_upper_lower_bounds_swapped2'
473 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_upper_lower_bounds_swapped2
474 ; CHECK-NEXT: %u = urem i32 %num, 4
475 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
476 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
477 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
478 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
479 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
480 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_upper_lower_bounds_swapped2
481 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
482 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
483 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
484 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
485 ; CHECK-NEXT: Predicates:
486 ; CHECK-NEXT: Loop %for.body: Trip multiple is 4
489 %cmp.1 = icmp uge i32 %num, 5
490 tail call void @llvm.assume(i1 %cmp.1)
491 %cmp.2 = icmp ult i32 %num, 59000
492 tail call void @llvm.assume(i1 %cmp.2)
493 %u = urem i32 %num, 4
494 %cmp = icmp eq i32 %u, 0
495 tail call void @llvm.assume(i1 %cmp)
499 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
500 %inc = add nuw nsw i32 %i.010, 1
501 %cmp2 = icmp ult i32 %inc, %num
502 br i1 %cmp2, label %for.body, label %exit
508 define void @test_trip_multiple_5(i32 %num) {
509 ; CHECK-LABEL: 'test_trip_multiple_5'
510 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_5
511 ; CHECK-NEXT: %u = urem i32 %num, 5
512 ; CHECK-NEXT: --> ((-5 * (%num /u 5)) + %num) U: full-set S: full-set
513 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
514 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-2147483648) S: [0,-2147483648) Exits: (-1 + %num) LoopDispositions: { %for.body: Computable }
515 ; CHECK-NEXT: %inc = add nuw nsw i32 %i.010, 1
516 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-2147483648) S: [1,-2147483648) Exits: %num LoopDispositions: { %for.body: Computable }
517 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_5
518 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %num)
519 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -2
520 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %num)
521 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %num)
522 ; CHECK-NEXT: Predicates:
523 ; CHECK-NEXT: Loop %for.body: Trip multiple is 5
526 %u = urem i32 %num, 5
527 %cmp = icmp eq i32 %u, 0
528 tail call void @llvm.assume(i1 %cmp)
529 %cmp.1 = icmp uge i32 %num, 5
530 tail call void @llvm.assume(i1 %cmp.1)
534 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
535 %inc = add nuw nsw i32 %i.010, 1
536 %cmp2 = icmp ult i32 %inc, %num
537 br i1 %cmp2, label %for.body, label %exit
543 define void @test_trunc_operand_larger_than_urem_expr(i64 %N) {
544 ; CHECK-LABEL: 'test_trunc_operand_larger_than_urem_expr'
545 ; CHECK-NEXT: Classifying expressions for: @test_trunc_operand_larger_than_urem_expr
546 ; CHECK-NEXT: %conv = trunc i64 %N to i32
547 ; CHECK-NEXT: --> (trunc i64 %N to i32) U: full-set S: full-set
548 ; CHECK-NEXT: %and = and i32 %conv, 1
549 ; CHECK-NEXT: --> (zext i1 (trunc i64 %N to i1) to i32) U: [0,2) S: [0,2)
550 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
551 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%for.body> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: (-1 + %N) LoopDispositions: { %for.body: Computable }
552 ; CHECK-NEXT: %iv.next = add nuw nsw i64 %iv, 1
553 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%for.body> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: %N LoopDispositions: { %for.body: Computable }
554 ; CHECK-NEXT: Determining loop execution counts for: @test_trunc_operand_larger_than_urem_expr
555 ; CHECK-NEXT: Loop %for.body: backedge-taken count is (-1 + %N)
556 ; CHECK-NEXT: Loop %for.body: constant max backedge-taken count is -1
557 ; CHECK-NEXT: Loop %for.body: symbolic max backedge-taken count is (-1 + %N)
558 ; CHECK-NEXT: Loop %for.body: Predicated backedge-taken count is (-1 + %N)
559 ; CHECK-NEXT: Predicates:
560 ; CHECK-NEXT: Loop %for.body: Trip multiple is 1
563 %conv = trunc i64 %N to i32
564 %and = and i32 %conv, 1
565 %cmp.pre = icmp eq i32 %and, 0
566 br i1 %cmp.pre, label %for.body, label %exit
569 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
570 %iv.next = add nuw nsw i64 %iv, 1
571 %cmp.1 = icmp ne i64 %iv.next, %N
572 br i1 %cmp.1, label %for.body, label %exit
578 ; TODO: Even though %num is known to divide by 4, and the loop's IV advances by 4, SCEV can't compute the trip count.
579 define void @test_trip_multiple_4_vectorized_iv(i32 %num) {
580 ; CHECK-LABEL: 'test_trip_multiple_4_vectorized_iv'
581 ; CHECK-NEXT: Classifying expressions for: @test_trip_multiple_4_vectorized_iv
582 ; CHECK-NEXT: %u = urem i32 %num, 4
583 ; CHECK-NEXT: --> (zext i2 (trunc i32 %num to i2) to i32) U: [0,4) S: [0,4)
584 ; CHECK-NEXT: %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
585 ; CHECK-NEXT: --> {0,+,4}<%for.body> U: [0,-3) S: [-2147483648,2147483645) Exits: <<Unknown>> LoopDispositions: { %for.body: Computable }
586 ; CHECK-NEXT: %inc = add i32 %i.010, 4
587 ; CHECK-NEXT: --> {4,+,4}<%for.body> U: [0,-3) S: [-2147483648,2147483645) Exits: <<Unknown>> LoopDispositions: { %for.body: Computable }
588 ; CHECK-NEXT: Determining loop execution counts for: @test_trip_multiple_4_vectorized_iv
589 ; CHECK-NEXT: Loop %for.body: Unpredictable backedge-taken count.
590 ; CHECK-NEXT: Loop %for.body: Unpredictable constant max backedge-taken count.
591 ; CHECK-NEXT: Loop %for.body: Unpredictable symbolic max backedge-taken count.
592 ; CHECK-NEXT: Loop %for.body: Unpredictable predicated backedge-taken count.
595 %u = urem i32 %num, 4
596 %cmp = icmp eq i32 %u, 0
597 tail call void @llvm.assume(i1 %cmp)
601 %i.010 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
602 %inc = add i32 %i.010, 4
603 %cmp2 = icmp ult i32 %inc, %num
604 br i1 %cmp2, label %for.body, label %exit
610 declare void @llvm.assume(i1)
611 declare void @llvm.experimental.guard(i1, ...)