1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=loop-unroll -unroll-peel-max-count=4 -verify-dom-info | FileCheck %s
8 ; Check that we can peel off iterations that make conditions true.
9 define void @test1(i32 %k) {
10 ; CHECK-LABEL: @test1(
11 ; CHECK-NEXT: for.body.lr.ph:
12 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
13 ; CHECK: for.body.peel.begin:
14 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
15 ; CHECK: for.body.peel:
16 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp ult i32 0, 2
17 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[IF_ELSE_PEEL:%.*]]
18 ; CHECK: if.else.peel:
19 ; CHECK-NEXT: call void @f2()
20 ; CHECK-NEXT: br label [[FOR_INC_PEEL:%.*]]
21 ; CHECK: if.then.peel:
22 ; CHECK-NEXT: call void @f1()
23 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
24 ; CHECK: for.inc.peel:
25 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i32 0, 1
26 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[INC_PEEL]], [[K:%.*]]
27 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%[^,]*]]
28 ; Verify that MD_loop metadata is dropped.
29 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
30 ; CHECK: for.body.peel.next:
31 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
32 ; CHECK: for.body.peel2:
33 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp ult i32 [[INC_PEEL]], 2
34 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL5:%.*]], label [[IF_ELSE_PEEL4:%.*]]
35 ; CHECK: if.else.peel4:
36 ; CHECK-NEXT: call void @f2()
37 ; CHECK-NEXT: br label [[FOR_INC_PEEL6:%.*]]
38 ; CHECK: if.then.peel5:
39 ; CHECK-NEXT: call void @f1()
40 ; CHECK-NEXT: br label [[FOR_INC_PEEL6]]
41 ; CHECK: for.inc.peel6:
42 ; CHECK-NEXT: [[INC_PEEL7:%.*]] = add nsw i32 [[INC_PEEL]], 1
43 ; CHECK-NEXT: [[CMP_PEEL8:%.*]] = icmp slt i32 [[INC_PEEL7]], [[K]]
44 ; CHECK-NEXT: br i1 [[CMP_PEEL8]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
45 ; Verify that MD_loop metadata is dropped.
46 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
47 ; CHECK: for.body.peel.next1:
48 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT9:%.*]]
49 ; CHECK: for.body.peel.next9:
50 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
51 ; CHECK: for.body.lr.ph.peel.newph:
52 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
54 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL7]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
55 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
57 ; CHECK-NEXT: call void @f1()
58 ; CHECK-NEXT: br label [[FOR_INC]]
60 ; CHECK-NEXT: call void @f2()
61 ; CHECK-NEXT: br label [[FOR_INC]]
63 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
64 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K]]
65 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop !{{.*}}
66 ; CHECK: for.end.loopexit:
67 ; CHECK-NEXT: br label [[FOR_END]]
69 ; CHECK-NEXT: ret void
75 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
76 %cmp1 = icmp ult i32 %i.05, 2
77 br i1 %cmp1, label %if.then, label %if.else
88 %inc = add nsw i32 %i.05, 1
89 %cmp = icmp slt i32 %inc, %k
90 br i1 %cmp, label %for.body, label %for.end, !llvm.loop !1
98 ; Check we peel off the maximum number of iterations that make conditions true.
99 define void @test2(i32 %k) {
100 ; CHECK-LABEL: @test2(
101 ; CHECK-NEXT: for.body.lr.ph:
102 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
103 ; CHECK: for.body.peel.begin:
104 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
105 ; CHECK: for.body.peel:
106 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp ult i32 0, 2
107 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[IF_ELSE_PEEL:%.*]]
108 ; CHECK: if.else.peel:
109 ; CHECK-NEXT: call void @f2()
110 ; CHECK-NEXT: br label [[IF2_PEEL:%.*]]
111 ; CHECK: if.then.peel:
112 ; CHECK-NEXT: call void @f1()
113 ; CHECK-NEXT: br label [[IF2_PEEL]]
115 ; CHECK-NEXT: [[CMP2_PEEL:%.*]] = icmp ult i32 0, 4
116 ; CHECK-NEXT: br i1 [[CMP2_PEEL]], label [[IF_THEN2_PEEL:%.*]], label [[FOR_INC_PEEL:%.*]]
117 ; CHECK: if.then2.peel:
118 ; CHECK-NEXT: call void @f1()
119 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
120 ; CHECK: for.inc.peel:
121 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i32 0, 1
122 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[INC_PEEL]], [[K:%.*]]
123 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%[^,]*]]
124 ; Verify that MD_loop metadata is dropped.
125 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
126 ; CHECK: for.body.peel.next:
127 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
128 ; CHECK: for.body.peel2:
129 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp ult i32 [[INC_PEEL]], 2
130 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL5:%.*]], label [[IF_ELSE_PEEL4:%.*]]
131 ; CHECK: if.else.peel4:
132 ; CHECK-NEXT: call void @f2()
133 ; CHECK-NEXT: br label [[IF2_PEEL6:%.*]]
134 ; CHECK: if.then.peel5:
135 ; CHECK-NEXT: call void @f1()
136 ; CHECK-NEXT: br label [[IF2_PEEL6]]
138 ; CHECK-NEXT: [[CMP2_PEEL7:%.*]] = icmp ult i32 [[INC_PEEL]], 4
139 ; CHECK-NEXT: br i1 [[CMP2_PEEL7]], label [[IF_THEN2_PEEL8:%.*]], label [[FOR_INC_PEEL9:%.*]]
140 ; CHECK: if.then2.peel8:
141 ; CHECK-NEXT: call void @f1()
142 ; CHECK-NEXT: br label [[FOR_INC_PEEL9]]
143 ; CHECK: for.inc.peel9:
144 ; CHECK-NEXT: [[INC_PEEL10:%.*]] = add nsw i32 [[INC_PEEL]], 1
145 ; CHECK-NEXT: [[CMP_PEEL11:%.*]] = icmp slt i32 [[INC_PEEL10]], [[K]]
146 ; CHECK-NEXT: br i1 [[CMP_PEEL11]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
147 ; Verify that MD_loop metadata is dropped.
148 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
149 ; CHECK: for.body.peel.next1:
150 ; CHECK-NEXT: br label [[FOR_BODY_PEEL13:%.*]]
151 ; CHECK: for.body.peel13:
152 ; CHECK-NEXT: [[CMP1_PEEL14:%.*]] = icmp ult i32 [[INC_PEEL10]], 2
153 ; CHECK-NEXT: br i1 [[CMP1_PEEL14]], label [[IF_THEN_PEEL16:%.*]], label [[IF_ELSE_PEEL15:%.*]]
154 ; CHECK: if.else.peel15:
155 ; CHECK-NEXT: call void @f2()
156 ; CHECK-NEXT: br label [[IF2_PEEL17:%.*]]
157 ; CHECK: if.then.peel16:
158 ; CHECK-NEXT: call void @f1()
159 ; CHECK-NEXT: br label [[IF2_PEEL17]]
161 ; CHECK-NEXT: [[CMP2_PEEL18:%.*]] = icmp ult i32 [[INC_PEEL10]], 4
162 ; CHECK-NEXT: br i1 [[CMP2_PEEL18]], label [[IF_THEN2_PEEL19:%.*]], label [[FOR_INC_PEEL20:%.*]]
163 ; CHECK: if.then2.peel19:
164 ; CHECK-NEXT: call void @f1()
165 ; CHECK-NEXT: br label [[FOR_INC_PEEL20]]
166 ; CHECK: for.inc.peel20:
167 ; CHECK-NEXT: [[INC_PEEL21:%.*]] = add nsw i32 [[INC_PEEL10]], 1
168 ; CHECK-NEXT: [[CMP_PEEL22:%.*]] = icmp slt i32 [[INC_PEEL21]], [[K]]
169 ; CHECK-NEXT: br i1 [[CMP_PEEL22]], label [[FOR_BODY_PEEL_NEXT12:%.*]], label [[FOR_END]]
170 ; Verify that MD_loop metadata is dropped.
171 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
172 ; CHECK: for.body.peel.next12:
173 ; CHECK-NEXT: br label [[FOR_BODY_PEEL24:%.*]]
174 ; CHECK: for.body.peel24:
175 ; CHECK-NEXT: [[CMP1_PEEL25:%.*]] = icmp ult i32 [[INC_PEEL21]], 2
176 ; CHECK-NEXT: br i1 [[CMP1_PEEL25]], label [[IF_THEN_PEEL27:%.*]], label [[IF_ELSE_PEEL26:%.*]]
177 ; CHECK: if.else.peel26:
178 ; CHECK-NEXT: call void @f2()
179 ; CHECK-NEXT: br label [[IF2_PEEL28:%.*]]
180 ; CHECK: if.then.peel27:
181 ; CHECK-NEXT: call void @f1()
182 ; CHECK-NEXT: br label [[IF2_PEEL28]]
184 ; CHECK-NEXT: [[CMP2_PEEL29:%.*]] = icmp ult i32 [[INC_PEEL21]], 4
185 ; CHECK-NEXT: br i1 [[CMP2_PEEL29]], label [[IF_THEN2_PEEL30:%.*]], label [[FOR_INC_PEEL31:%.*]]
186 ; CHECK: if.then2.peel30:
187 ; CHECK-NEXT: call void @f1()
188 ; CHECK-NEXT: br label [[FOR_INC_PEEL31]]
189 ; CHECK: for.inc.peel31:
190 ; CHECK-NEXT: [[INC_PEEL32:%.*]] = add nsw i32 [[INC_PEEL21]], 1
191 ; CHECK-NEXT: [[CMP_PEEL33:%.*]] = icmp slt i32 [[INC_PEEL32]], [[K]]
192 ; CHECK-NEXT: br i1 [[CMP_PEEL33]], label [[FOR_BODY_PEEL_NEXT23:%.*]], label [[FOR_END]]
193 ; Verify that MD_loop metadata is dropped.
194 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
195 ; CHECK: for.body.peel.next23:
196 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT34:%.*]]
197 ; CHECK: for.body.peel.next34:
198 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
199 ; CHECK: for.body.lr.ph.peel.newph:
200 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
202 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL32]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
203 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
205 ; CHECK-NEXT: call void @f1()
206 ; CHECK-NEXT: br label [[IF2:%.*]]
208 ; CHECK-NEXT: call void @f2()
209 ; CHECK-NEXT: br label [[IF2]]
211 ; CHECK-NEXT: br i1 false, label [[IF_THEN2:%.*]], label [[FOR_INC]]
213 ; CHECK-NEXT: call void @f1()
214 ; CHECK-NEXT: br label [[FOR_INC]]
216 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
217 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K]]
218 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop !{{.*}}
219 ; CHECK: for.end.loopexit:
220 ; CHECK-NEXT: br label [[FOR_END]]
222 ; CHECK-NEXT: ret void
228 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
229 %cmp1 = icmp ult i32 %i.05, 2
230 br i1 %cmp1, label %if.then, label %if.else
241 %cmp2 = icmp ult i32 %i.05, 4
242 br i1 %cmp2, label %if.then2, label %for.inc
249 %inc = add nsw i32 %i.05, 1
250 %cmp = icmp slt i32 %inc, %k
251 br i1 %cmp, label %for.body, label %for.end, !llvm.loop !2
259 ; Check that we can peel off iterations that make a condition false.
260 define void @test3(i32 %k) {
261 ; CHECK-LABEL: @test3(
262 ; CHECK-NEXT: for.body.lr.ph:
263 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
264 ; CHECK: for.body.peel.begin:
265 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
266 ; CHECK: for.body.peel:
267 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp ugt i32 0, 2
268 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[IF_ELSE_PEEL:%.*]]
269 ; CHECK: if.else.peel:
270 ; CHECK-NEXT: call void @f2()
271 ; CHECK-NEXT: br label [[FOR_INC_PEEL:%.*]]
272 ; CHECK: if.then.peel:
273 ; CHECK-NEXT: call void @f1()
274 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
275 ; CHECK: for.inc.peel:
276 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i32 0, 1
277 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[INC_PEEL]], [[K:%.*]]
278 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%[^,]*]]
279 ; Verify that MD_loop metadata is dropped.
280 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
281 ; CHECK: for.body.peel.next:
282 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
283 ; CHECK: for.body.peel2:
284 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp ugt i32 [[INC_PEEL]], 2
285 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL5:%.*]], label [[IF_ELSE_PEEL4:%.*]]
286 ; CHECK: if.else.peel4:
287 ; CHECK-NEXT: call void @f2()
288 ; CHECK-NEXT: br label [[FOR_INC_PEEL6:%.*]]
289 ; CHECK: if.then.peel5:
290 ; CHECK-NEXT: call void @f1()
291 ; CHECK-NEXT: br label [[FOR_INC_PEEL6]]
292 ; CHECK: for.inc.peel6:
293 ; CHECK-NEXT: [[INC_PEEL7:%.*]] = add nsw i32 [[INC_PEEL]], 1
294 ; CHECK-NEXT: [[CMP_PEEL8:%.*]] = icmp slt i32 [[INC_PEEL7]], [[K]]
295 ; CHECK-NEXT: br i1 [[CMP_PEEL8]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
296 ; Verify that MD_loop metadata is dropped.
297 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
298 ; CHECK: for.body.peel.next1:
299 ; CHECK-NEXT: br label [[FOR_BODY_PEEL10:%.*]]
300 ; CHECK: for.body.peel10:
301 ; CHECK-NEXT: [[CMP1_PEEL11:%.*]] = icmp ugt i32 [[INC_PEEL7]], 2
302 ; CHECK-NEXT: br i1 [[CMP1_PEEL11]], label [[IF_THEN_PEEL13:%.*]], label [[IF_ELSE_PEEL12:%.*]]
303 ; CHECK: if.else.peel12:
304 ; CHECK-NEXT: call void @f2()
305 ; CHECK-NEXT: br label [[FOR_INC_PEEL14:%.*]]
306 ; CHECK: if.then.peel13:
307 ; CHECK-NEXT: call void @f1()
308 ; CHECK-NEXT: br label [[FOR_INC_PEEL14]]
309 ; CHECK: for.inc.peel14:
310 ; CHECK-NEXT: [[INC_PEEL15:%.*]] = add nsw i32 [[INC_PEEL7]], 1
311 ; CHECK-NEXT: [[CMP_PEEL16:%.*]] = icmp slt i32 [[INC_PEEL15]], [[K]]
312 ; CHECK-NEXT: br i1 [[CMP_PEEL16]], label [[FOR_BODY_PEEL_NEXT9:%.*]], label [[FOR_END]]
313 ; Verify that MD_loop metadata is dropped.
314 ; CHECK-NOT: , !llvm.loop !{{[0-9]*}}
315 ; CHECK: for.body.peel.next9:
316 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT17:%.*]]
317 ; CHECK: for.body.peel.next17:
318 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
319 ; CHECK: for.body.lr.ph.peel.newph:
320 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
322 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL15]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
323 ; CHECK-NEXT: br i1 true, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
325 ; CHECK-NEXT: call void @f1()
326 ; CHECK-NEXT: br label [[FOR_INC]]
328 ; CHECK-NEXT: call void @f2()
329 ; CHECK-NEXT: br label [[FOR_INC]]
331 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
332 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K]]
333 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop !{{.*}}
334 ; CHECK: for.end.loopexit:
335 ; CHECK-NEXT: br label [[FOR_END]]
337 ; CHECK-NEXT: ret void
343 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
344 %cmp1 = icmp ugt i32 %i.05, 2
345 br i1 %cmp1, label %if.then, label %if.else
356 %inc = add nsw i32 %i.05, 1
357 %cmp = icmp slt i32 %inc, %k
358 br i1 %cmp, label %for.body, label %for.end, !llvm.loop !3
366 ; Test that we only peel off iterations if it simplifies a condition in the
367 ; loop body after peeling at most MaxPeelCount iterations.
368 define void @test4(i32 %k) {
369 ; CHECK-LABEL: @test4(
370 ; CHECK-NEXT: for.body.lr.ph:
371 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
373 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
374 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[I_05]], 9999
375 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]]
377 ; CHECK-NEXT: call void @f1()
378 ; CHECK-NEXT: br label [[FOR_INC]]
380 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_05]], 1
381 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K:%.*]]
382 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
384 ; CHECK-NEXT: ret void
390 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
391 %cmp1 = icmp ugt i32 %i.05, 9999
392 br i1 %cmp1, label %if.then, label %for.inc
399 %inc = add nsw i32 %i.05, 1
400 %cmp = icmp slt i32 %inc, %k
401 br i1 %cmp, label %for.body, label %for.end
407 ; In this test, the condition involves 2 AddRecs. Without evaluating both
408 ; AddRecs, we cannot prove that the condition becomes known in the loop body
410 define void @test5(i32 %k) {
411 ; CHECK-LABEL: @test5(
413 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
415 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
416 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ 4, [[ENTRY]] ], [ [[J_INC:%.*]], [[FOR_INC]] ]
417 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i32 [[I_05]], [[J]]
418 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
420 ; CHECK-NEXT: call void @f1()
421 ; CHECK-NEXT: br label [[FOR_INC]]
423 ; CHECK-NEXT: call void @f2()
424 ; CHECK-NEXT: br label [[FOR_INC]]
426 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_05]], 2
427 ; CHECK-NEXT: [[J_INC]] = add nsw i32 [[J]], 1
428 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K:%.*]]
429 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
431 ; CHECK-NEXT: ret void
437 %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
438 %j = phi i32 [ 4, %entry ], [ %j.inc, %for.inc ]
439 %cmp1 = icmp ult i32 %i.05, %j
440 br i1 %cmp1, label %if.then, label %if.else
451 %inc = add nsw i32 %i.05, 2
452 %j.inc = add nsw i32 %j, 1
453 %cmp = icmp slt i32 %inc, %k
454 br i1 %cmp, label %for.body, label %for.end
460 define void @test6(i32 %k) {
461 ; CHECK-LABEL: @test6(
462 ; CHECK-NEXT: for.body.lr.ph:
463 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
464 ; CHECK: for.body.peel.begin:
465 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
466 ; CHECK: for.body.peel:
467 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp ne i32 0, 3
468 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[FOR_INC_PEEL:%.*]]
469 ; CHECK: if.then.peel:
470 ; CHECK-NEXT: call void @f1()
471 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
472 ; CHECK: for.inc.peel:
473 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i32 0, 1
474 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[INC_PEEL]], [[K:%.*]]
475 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%.*]]
476 ; CHECK: for.body.peel.next:
477 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
478 ; CHECK: for.body.peel2:
479 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp ne i32 [[INC_PEEL]], 3
480 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL4:%.*]], label [[FOR_INC_PEEL5:%.*]]
481 ; CHECK: if.then.peel4:
482 ; CHECK-NEXT: call void @f1()
483 ; CHECK-NEXT: br label [[FOR_INC_PEEL5]]
484 ; CHECK: for.inc.peel5:
485 ; CHECK-NEXT: [[INC_PEEL6:%.*]] = add nsw i32 [[INC_PEEL]], 1
486 ; CHECK-NEXT: [[CMP_PEEL7:%.*]] = icmp slt i32 [[INC_PEEL6]], [[K]]
487 ; CHECK-NEXT: br i1 [[CMP_PEEL7]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
488 ; CHECK: for.body.peel.next1:
489 ; CHECK-NEXT: br label [[FOR_BODY_PEEL9:%.*]]
490 ; CHECK: for.body.peel9:
491 ; CHECK-NEXT: [[CMP1_PEEL10:%.*]] = icmp ne i32 [[INC_PEEL6]], 3
492 ; CHECK-NEXT: br i1 [[CMP1_PEEL10]], label [[IF_THEN_PEEL11:%.*]], label [[FOR_INC_PEEL12:%.*]]
493 ; CHECK: if.then.peel11:
494 ; CHECK-NEXT: call void @f1()
495 ; CHECK-NEXT: br label [[FOR_INC_PEEL12]]
496 ; CHECK: for.inc.peel12:
497 ; CHECK-NEXT: [[INC_PEEL13:%.*]] = add nsw i32 [[INC_PEEL6]], 1
498 ; CHECK-NEXT: [[CMP_PEEL14:%.*]] = icmp slt i32 [[INC_PEEL13]], [[K]]
499 ; CHECK-NEXT: br i1 [[CMP_PEEL14]], label [[FOR_BODY_PEEL_NEXT8:%.*]], label [[FOR_END]]
500 ; CHECK: for.body.peel.next8:
501 ; CHECK-NEXT: br label [[FOR_BODY_PEEL16:%.*]]
502 ; CHECK: for.body.peel16:
503 ; CHECK-NEXT: [[CMP1_PEEL17:%.*]] = icmp ne i32 [[INC_PEEL13]], 3
504 ; CHECK-NEXT: br i1 [[CMP1_PEEL17]], label [[IF_THEN_PEEL18:%.*]], label [[FOR_INC_PEEL19:%.*]]
505 ; CHECK: if.then.peel18:
506 ; CHECK-NEXT: call void @f1()
507 ; CHECK-NEXT: br label [[FOR_INC_PEEL19]]
508 ; CHECK: for.inc.peel19:
509 ; CHECK-NEXT: [[INC_PEEL20:%.*]] = add nsw i32 [[INC_PEEL13]], 1
510 ; CHECK-NEXT: [[CMP_PEEL21:%.*]] = icmp slt i32 [[INC_PEEL20]], [[K]]
511 ; CHECK-NEXT: br i1 [[CMP_PEEL21]], label [[FOR_BODY_PEEL_NEXT15:%.*]], label [[FOR_END]]
512 ; CHECK: for.body.peel.next15:
513 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT22:%.*]]
514 ; CHECK: for.body.peel.next22:
515 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
516 ; CHECK: for.body.lr.ph.peel.newph:
517 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
519 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL20]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
520 ; CHECK-NEXT: br i1 true, label [[IF_THEN:%.*]], label [[FOR_INC]]
522 ; CHECK-NEXT: call void @f1()
523 ; CHECK-NEXT: br label [[FOR_INC]]
525 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
526 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K]]
527 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop !6
528 ; CHECK: for.end.loopexit:
529 ; CHECK-NEXT: br label [[FOR_END]]
531 ; CHECK-NEXT: ret void
537 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
538 %cmp1 = icmp ne i32 %i.05, 3
539 br i1 %cmp1, label %if.then, label %for.inc
546 %inc = add nsw i32 %i.05, 1
547 %cmp = icmp slt i32 %inc, %k
548 br i1 %cmp, label %for.body, label %for.end
554 define void @test7(i32 %k) {
555 ; CHECK-LABEL: @test7(
556 ; CHECK-NEXT: for.body.lr.ph:
557 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
558 ; CHECK: for.body.peel.begin:
559 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
560 ; CHECK: for.body.peel:
561 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp eq i32 0, 3
562 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[FOR_INC_PEEL:%.*]]
563 ; CHECK: if.then.peel:
564 ; CHECK-NEXT: call void @f1()
565 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
566 ; CHECK: for.inc.peel:
567 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i32 0, 1
568 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[INC_PEEL]], [[K:%.*]]
569 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%.*]]
570 ; CHECK: for.body.peel.next:
571 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
572 ; CHECK: for.body.peel2:
573 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp eq i32 [[INC_PEEL]], 3
574 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL4:%.*]], label [[FOR_INC_PEEL5:%.*]]
575 ; CHECK: if.then.peel4:
576 ; CHECK-NEXT: call void @f1()
577 ; CHECK-NEXT: br label [[FOR_INC_PEEL5]]
578 ; CHECK: for.inc.peel5:
579 ; CHECK-NEXT: [[INC_PEEL6:%.*]] = add nsw i32 [[INC_PEEL]], 1
580 ; CHECK-NEXT: [[CMP_PEEL7:%.*]] = icmp slt i32 [[INC_PEEL6]], [[K]]
581 ; CHECK-NEXT: br i1 [[CMP_PEEL7]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
582 ; CHECK: for.body.peel.next1:
583 ; CHECK-NEXT: br label [[FOR_BODY_PEEL9:%.*]]
584 ; CHECK: for.body.peel9:
585 ; CHECK-NEXT: [[CMP1_PEEL10:%.*]] = icmp eq i32 [[INC_PEEL6]], 3
586 ; CHECK-NEXT: br i1 [[CMP1_PEEL10]], label [[IF_THEN_PEEL11:%.*]], label [[FOR_INC_PEEL12:%.*]]
587 ; CHECK: if.then.peel11:
588 ; CHECK-NEXT: call void @f1()
589 ; CHECK-NEXT: br label [[FOR_INC_PEEL12]]
590 ; CHECK: for.inc.peel12:
591 ; CHECK-NEXT: [[INC_PEEL13:%.*]] = add nsw i32 [[INC_PEEL6]], 1
592 ; CHECK-NEXT: [[CMP_PEEL14:%.*]] = icmp slt i32 [[INC_PEEL13]], [[K]]
593 ; CHECK-NEXT: br i1 [[CMP_PEEL14]], label [[FOR_BODY_PEEL_NEXT8:%.*]], label [[FOR_END]]
594 ; CHECK: for.body.peel.next8:
595 ; CHECK-NEXT: br label [[FOR_BODY_PEEL16:%.*]]
596 ; CHECK: for.body.peel16:
597 ; CHECK-NEXT: [[CMP1_PEEL17:%.*]] = icmp eq i32 [[INC_PEEL13]], 3
598 ; CHECK-NEXT: br i1 [[CMP1_PEEL17]], label [[IF_THEN_PEEL18:%.*]], label [[FOR_INC_PEEL19:%.*]]
599 ; CHECK: if.then.peel18:
600 ; CHECK-NEXT: call void @f1()
601 ; CHECK-NEXT: br label [[FOR_INC_PEEL19]]
602 ; CHECK: for.inc.peel19:
603 ; CHECK-NEXT: [[INC_PEEL20:%.*]] = add nsw i32 [[INC_PEEL13]], 1
604 ; CHECK-NEXT: [[CMP_PEEL21:%.*]] = icmp slt i32 [[INC_PEEL20]], [[K]]
605 ; CHECK-NEXT: br i1 [[CMP_PEEL21]], label [[FOR_BODY_PEEL_NEXT15:%.*]], label [[FOR_END]]
606 ; CHECK: for.body.peel.next15:
607 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT22:%.*]]
608 ; CHECK: for.body.peel.next22:
609 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
610 ; CHECK: for.body.lr.ph.peel.newph:
611 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
613 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL20]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
614 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[FOR_INC]]
616 ; CHECK-NEXT: call void @f1()
617 ; CHECK-NEXT: br label [[FOR_INC]]
619 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
620 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K]]
621 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop !7
622 ; CHECK: for.end.loopexit:
623 ; CHECK-NEXT: br label [[FOR_END]]
625 ; CHECK-NEXT: ret void
631 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
632 %cmp1 = icmp eq i32 %i.05, 3
633 br i1 %cmp1, label %if.then, label %for.inc
640 %inc = add nsw i32 %i.05, 1
641 %cmp = icmp slt i32 %inc, %k
642 br i1 %cmp, label %for.body, label %for.end
648 define void @test8(i32 %k) {
649 ; CHECK-LABEL: @test8(
650 ; CHECK-NEXT: for.body.lr.ph:
651 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
652 ; CHECK: for.body.peel.begin:
653 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
654 ; CHECK: for.body.peel:
655 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp slt i32 0, 3
656 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[FOR_INC_PEEL:%.*]]
657 ; CHECK: if.then.peel:
658 ; CHECK-NEXT: call void @f1()
659 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
660 ; CHECK: for.inc.peel:
661 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add i32 0, 1
662 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i32 [[INC_PEEL]], [[K:%.*]]
663 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%.*]]
664 ; CHECK: for.body.peel.next:
665 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
666 ; CHECK: for.body.peel2:
667 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp slt i32 [[INC_PEEL]], 3
668 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL4:%.*]], label [[FOR_INC_PEEL5:%.*]]
669 ; CHECK: if.then.peel4:
670 ; CHECK-NEXT: call void @f1()
671 ; CHECK-NEXT: br label [[FOR_INC_PEEL5]]
672 ; CHECK: for.inc.peel5:
673 ; CHECK-NEXT: [[INC_PEEL6:%.*]] = add i32 [[INC_PEEL]], 1
674 ; CHECK-NEXT: [[CMP_PEEL7:%.*]] = icmp slt i32 [[INC_PEEL6]], [[K]]
675 ; CHECK-NEXT: br i1 [[CMP_PEEL7]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
676 ; CHECK: for.body.peel.next1:
677 ; CHECK-NEXT: br label [[FOR_BODY_PEEL9:%.*]]
678 ; CHECK: for.body.peel9:
679 ; CHECK-NEXT: [[CMP1_PEEL10:%.*]] = icmp slt i32 [[INC_PEEL6]], 3
680 ; CHECK-NEXT: br i1 [[CMP1_PEEL10]], label [[IF_THEN_PEEL11:%.*]], label [[FOR_INC_PEEL12:%.*]]
681 ; CHECK: if.then.peel11:
682 ; CHECK-NEXT: call void @f1()
683 ; CHECK-NEXT: br label [[FOR_INC_PEEL12]]
684 ; CHECK: for.inc.peel12:
685 ; CHECK-NEXT: [[INC_PEEL13:%.*]] = add i32 [[INC_PEEL6]], 1
686 ; CHECK-NEXT: [[CMP_PEEL14:%.*]] = icmp slt i32 [[INC_PEEL13]], [[K]]
687 ; CHECK-NEXT: br i1 [[CMP_PEEL14]], label [[FOR_BODY_PEEL_NEXT8:%.*]], label [[FOR_END]]
688 ; CHECK: for.body.peel.next8:
689 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT15:%.*]]
690 ; CHECK: for.body.peel.next15:
691 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
692 ; CHECK: for.body.lr.ph.peel.newph:
693 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
695 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL13]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
696 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[FOR_INC]]
698 ; CHECK-NEXT: call void @f1()
699 ; CHECK-NEXT: br label [[FOR_INC]]
701 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
702 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K]]
703 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop [[LOOP8:![0-9]+]]
704 ; CHECK: for.end.loopexit:
705 ; CHECK-NEXT: br label [[FOR_END]]
707 ; CHECK-NEXT: ret void
713 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
714 %cmp1 = icmp slt i32 %i.05, 3
715 br i1 %cmp1, label %if.then, label %for.inc
722 %inc = add i32 %i.05, 1
723 %cmp = icmp slt i32 %inc, %k
724 br i1 %cmp, label %for.body, label %for.end
729 ; CHECK-NOT: llvm.loop.unroll.disable
731 define void @test_9__peel_first_iter_via_slt_pred(i32 %len) {
732 ; CHECK-LABEL: @test_9__peel_first_iter_via_slt_pred(
734 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[LEN:%.*]], 0
735 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
736 ; CHECK: for.body.preheader:
737 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
738 ; CHECK: for.body.peel.begin:
739 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
740 ; CHECK: for.body.peel:
741 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp slt i32 0, 1
742 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[IF_END_PEEL:%.*]]
743 ; CHECK: if.then.peel:
744 ; CHECK-NEXT: call void @init()
745 ; CHECK-NEXT: br label [[IF_END_PEEL]]
746 ; CHECK: if.end.peel:
747 ; CHECK-NEXT: call void @sink()
748 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nuw nsw i32 0, 1
749 ; CHECK-NEXT: [[EXITCOND_PEEL:%.*]] = icmp eq i32 [[INC_PEEL]], [[LEN]]
750 ; CHECK-NEXT: br i1 [[EXITCOND_PEEL]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY_PEEL_NEXT:%.*]]
751 ; CHECK: for.body.peel.next:
752 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
753 ; CHECK: for.body.peel.next1:
754 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER_PEEL_NEWPH:%.*]]
755 ; CHECK: for.body.preheader.peel.newph:
756 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
757 ; CHECK: for.cond.cleanup.loopexit.loopexit:
758 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
759 ; CHECK: for.cond.cleanup.loopexit:
760 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
761 ; CHECK: for.cond.cleanup:
762 ; CHECK-NEXT: ret void
764 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ [[INC_PEEL]], [[FOR_BODY_PREHEADER_PEEL_NEWPH]] ]
765 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_END]]
767 ; CHECK-NEXT: call void @init()
768 ; CHECK-NEXT: br label [[IF_END]]
770 ; CHECK-NEXT: call void @sink()
771 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
772 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[LEN]]
773 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT_LOOPEXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP9:![0-9]+]]
776 %cmp5 = icmp sgt i32 %len, 0
777 br i1 %cmp5, label %for.body, label %for.cond.cleanup
779 for.cond.cleanup: ; preds = %if.end, %entry
782 for.body: ; preds = %entry, %if.end
783 %i.06 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
784 %cmp1 = icmp slt i32 %i.06, 1
785 br i1 %cmp1, label %if.then, label %if.end
787 if.then: ; preds = %for.body
791 if.end: ; preds = %if.then, %for.body
793 %inc = add nuw nsw i32 %i.06, 1
794 %exitcond = icmp eq i32 %inc, %len
795 br i1 %exitcond, label %for.cond.cleanup, label %for.body
798 define void @test_10__peel_first_iter_via_sgt_pred(i32 %len) {
799 ; CHECK-LABEL: @test_10__peel_first_iter_via_sgt_pred(
801 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[LEN:%.*]], 0
802 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
803 ; CHECK: for.body.preheader:
804 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
805 ; CHECK: for.body.peel.begin:
806 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
807 ; CHECK: for.body.peel:
808 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp sgt i32 0, 0
809 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_END_PEEL:%.*]], label [[IF_THEN_PEEL:%.*]]
810 ; CHECK: if.then.peel:
811 ; CHECK-NEXT: call void @init()
812 ; CHECK-NEXT: br label [[IF_END_PEEL]]
813 ; CHECK: if.end.peel:
814 ; CHECK-NEXT: call void @sink()
815 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nuw nsw i32 0, 1
816 ; CHECK-NEXT: [[EXITCOND_PEEL:%.*]] = icmp eq i32 [[INC_PEEL]], [[LEN]]
817 ; CHECK-NEXT: br i1 [[EXITCOND_PEEL]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY_PEEL_NEXT:%.*]]
818 ; CHECK: for.body.peel.next:
819 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
820 ; CHECK: for.body.peel.next1:
821 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER_PEEL_NEWPH:%.*]]
822 ; CHECK: for.body.preheader.peel.newph:
823 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
824 ; CHECK: for.cond.cleanup.loopexit.loopexit:
825 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
826 ; CHECK: for.cond.cleanup.loopexit:
827 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
828 ; CHECK: for.cond.cleanup:
829 ; CHECK-NEXT: ret void
831 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ [[INC_PEEL]], [[FOR_BODY_PREHEADER_PEEL_NEWPH]] ]
832 ; CHECK-NEXT: br i1 true, label [[IF_END]], label [[IF_THEN:%.*]]
834 ; CHECK-NEXT: call void @init()
835 ; CHECK-NEXT: br label [[IF_END]]
837 ; CHECK-NEXT: call void @sink()
838 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
839 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[LEN]]
840 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT_LOOPEXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP11:![0-9]+]]
843 %cmp5 = icmp sgt i32 %len, 0
844 br i1 %cmp5, label %for.body, label %for.cond.cleanup
846 for.cond.cleanup: ; preds = %if.end, %entry
849 for.body: ; preds = %entry, %if.end
850 %i.06 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
851 %cmp1 = icmp sgt i32 %i.06, 0
852 br i1 %cmp1, label %if.end, label %if.then
854 if.then: ; preds = %for.body
858 if.end: ; preds = %if.then, %for.body
860 %inc = add nuw nsw i32 %i.06, 1
861 %exitcond = icmp eq i32 %inc, %len
862 br i1 %exitcond, label %for.cond.cleanup, label %for.body
865 ; NOTE: here we should only peel the first iteration,
866 ; i.e. all calls to sink() must stay in loop.
867 define void @test11__peel_first_iter_via_eq_pred(i32 %len) {
868 ; CHECK-LABEL: @test11__peel_first_iter_via_eq_pred(
870 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[LEN:%.*]], 0
871 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
872 ; CHECK: for.body.preheader:
873 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
874 ; CHECK: for.body.peel.begin:
875 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
876 ; CHECK: for.body.peel:
877 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp eq i32 0, 0
878 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[IF_END_PEEL:%.*]]
879 ; CHECK: if.then.peel:
880 ; CHECK-NEXT: call void @init()
881 ; CHECK-NEXT: br label [[IF_END_PEEL]]
882 ; CHECK: if.end.peel:
883 ; CHECK-NEXT: call void @sink()
884 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nuw nsw i32 0, 1
885 ; CHECK-NEXT: [[EXITCOND_PEEL:%.*]] = icmp eq i32 [[INC_PEEL]], [[LEN]]
886 ; CHECK-NEXT: br i1 [[EXITCOND_PEEL]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY_PEEL_NEXT:%.*]]
887 ; CHECK: for.body.peel.next:
888 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
889 ; CHECK: for.body.peel.next1:
890 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER_PEEL_NEWPH:%.*]]
891 ; CHECK: for.body.preheader.peel.newph:
892 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
893 ; CHECK: for.cond.cleanup.loopexit.loopexit:
894 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
895 ; CHECK: for.cond.cleanup.loopexit:
896 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
897 ; CHECK: for.cond.cleanup:
898 ; CHECK-NEXT: ret void
900 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ [[INC_PEEL]], [[FOR_BODY_PREHEADER_PEEL_NEWPH]] ]
901 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_END]]
903 ; CHECK-NEXT: call void @init()
904 ; CHECK-NEXT: br label [[IF_END]]
906 ; CHECK-NEXT: call void @sink()
907 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
908 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[LEN]]
909 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT_LOOPEXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP12:![0-9]+]]
912 %cmp5 = icmp sgt i32 %len, 0
913 br i1 %cmp5, label %for.body, label %for.cond.cleanup
915 for.cond.cleanup: ; preds = %if.end, %entry
918 for.body: ; preds = %entry, %if.end
919 %i.06 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
920 %cmp1 = icmp eq i32 %i.06, 0
921 br i1 %cmp1, label %if.then, label %if.end
923 if.then: ; preds = %for.body
927 if.end: ; preds = %if.then, %for.body
929 %inc = add nuw nsw i32 %i.06, 1
930 %exitcond = icmp eq i32 %inc, %len
931 br i1 %exitcond, label %for.cond.cleanup, label %for.body
934 ; NOTE: here we should only peel the first iteration,
935 ; i.e. all calls to sink() must stay in loop.
936 define void @test12__peel_first_iter_via_ne_pred(i32 %len) {
937 ; CHECK-LABEL: @test12__peel_first_iter_via_ne_pred(
939 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[LEN:%.*]], 0
940 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
941 ; CHECK: for.body.preheader:
942 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
943 ; CHECK: for.body.peel.begin:
944 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
945 ; CHECK: for.body.peel:
946 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp ne i32 0, 0
947 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_END_PEEL:%.*]], label [[IF_THEN_PEEL:%.*]]
948 ; CHECK: if.then.peel:
949 ; CHECK-NEXT: call void @init()
950 ; CHECK-NEXT: br label [[IF_END_PEEL]]
951 ; CHECK: if.end.peel:
952 ; CHECK-NEXT: call void @sink()
953 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nuw nsw i32 0, 1
954 ; CHECK-NEXT: [[EXITCOND_PEEL:%.*]] = icmp eq i32 [[INC_PEEL]], [[LEN]]
955 ; CHECK-NEXT: br i1 [[EXITCOND_PEEL]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY_PEEL_NEXT:%.*]]
956 ; CHECK: for.body.peel.next:
957 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
958 ; CHECK: for.body.peel.next1:
959 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER_PEEL_NEWPH:%.*]]
960 ; CHECK: for.body.preheader.peel.newph:
961 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
962 ; CHECK: for.cond.cleanup.loopexit.loopexit:
963 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
964 ; CHECK: for.cond.cleanup.loopexit:
965 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
966 ; CHECK: for.cond.cleanup:
967 ; CHECK-NEXT: ret void
969 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ [[INC_PEEL]], [[FOR_BODY_PREHEADER_PEEL_NEWPH]] ]
970 ; CHECK-NEXT: br i1 true, label [[IF_END]], label [[IF_THEN:%.*]]
972 ; CHECK-NEXT: call void @init()
973 ; CHECK-NEXT: br label [[IF_END]]
975 ; CHECK-NEXT: call void @sink()
976 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
977 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[LEN]]
978 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT_LOOPEXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP13:![0-9]+]]
981 %cmp5 = icmp sgt i32 %len, 0
982 br i1 %cmp5, label %for.body, label %for.cond.cleanup
984 for.cond.cleanup: ; preds = %if.end, %entry
987 for.body: ; preds = %entry, %if.end
988 %i.06 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
989 %cmp1 = icmp ne i32 %i.06, 0
990 br i1 %cmp1, label %if.end, label %if.then
992 if.then: ; preds = %for.body
996 if.end: ; preds = %if.then, %for.body
998 %inc = add nuw nsw i32 %i.06, 1
999 %exitcond = icmp eq i32 %inc, %len
1000 br i1 %exitcond, label %for.cond.cleanup, label %for.body
1003 ; No peeling is profitable here.
1004 define void @test13__ivar_mod2_is_1(i32 %len) {
1005 ; CHECK-LABEL: @test13__ivar_mod2_is_1(
1006 ; CHECK-NEXT: entry:
1007 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[LEN:%.*]], 0
1008 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1009 ; CHECK: for.body.preheader:
1010 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1011 ; CHECK: for.cond.cleanup.loopexit:
1012 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1013 ; CHECK: for.cond.cleanup:
1014 ; CHECK-NEXT: ret void
1016 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1017 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[I_06]], 1
1018 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[AND]], 1
1019 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_END]], label [[IF_THEN:%.*]]
1021 ; CHECK-NEXT: call void @init()
1022 ; CHECK-NEXT: br label [[IF_END]]
1024 ; CHECK-NEXT: call void @sink()
1025 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
1026 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[LEN]]
1027 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
1030 %cmp5 = icmp sgt i32 %len, 0
1031 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1033 for.cond.cleanup: ; preds = %if.end, %entry
1036 for.body: ; preds = %entry, %if.end
1037 %i.06 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
1038 %and = and i32 %i.06, 1
1039 %cmp1 = icmp eq i32 %and, 1
1040 br i1 %cmp1, label %if.end, label %if.then
1042 if.then: ; preds = %for.body
1046 if.end: ; preds = %if.then, %for.body
1048 %inc = add nuw nsw i32 %i.06, 1
1049 %exitcond = icmp eq i32 %inc, %len
1050 br i1 %exitcond, label %for.cond.cleanup, label %for.body
1053 ; No peeling is profitable here.
1054 define void @test14__ivar_mod2_is_0(i32 %len) {
1055 ; CHECK-LABEL: @test14__ivar_mod2_is_0(
1056 ; CHECK-NEXT: entry:
1057 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[LEN:%.*]], 0
1058 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1059 ; CHECK: for.body.preheader:
1060 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1061 ; CHECK: for.cond.cleanup.loopexit:
1062 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1063 ; CHECK: for.cond.cleanup:
1064 ; CHECK-NEXT: ret void
1066 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1067 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[I_06]], 1
1068 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[AND]], 0
1069 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_END]], label [[IF_THEN:%.*]]
1071 ; CHECK-NEXT: call void @init()
1072 ; CHECK-NEXT: br label [[IF_END]]
1074 ; CHECK-NEXT: call void @sink()
1075 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
1076 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[INC]], [[LEN]]
1077 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
1080 %cmp5 = icmp sgt i32 %len, 0
1081 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1083 for.cond.cleanup: ; preds = %if.end, %entry
1086 for.body: ; preds = %entry, %if.end
1087 %i.06 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
1088 %and = and i32 %i.06, 1
1089 %cmp1 = icmp eq i32 %and, 0
1090 br i1 %cmp1, label %if.end, label %if.then
1092 if.then: ; preds = %for.body
1096 if.end: ; preds = %if.then, %for.body
1098 %inc = add nuw nsw i32 %i.06, 1
1099 %exitcond = icmp eq i32 %inc, %len
1100 br i1 %exitcond, label %for.cond.cleanup, label %for.body
1103 ; Similar to @test6, we need to peel one extra iteration, and we can't do that
1104 ; as per the -unroll-peel-max-count=4, so this shouldn't be peeled at all.
1105 define void @test15(i32 %k) {
1106 ; CHECK-LABEL: @test15(
1107 ; CHECK-NEXT: for.body.lr.ph:
1108 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1110 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
1111 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[I_05]], 4
1112 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]]
1114 ; CHECK-NEXT: call void @f1()
1115 ; CHECK-NEXT: br label [[FOR_INC]]
1117 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_05]], 1
1118 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K:%.*]]
1119 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
1121 ; CHECK-NEXT: ret void
1127 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
1128 %cmp1 = icmp ne i32 %i.05, 4
1129 br i1 %cmp1, label %if.then, label %for.inc
1136 %inc = add nsw i32 %i.05, 1
1137 %cmp = icmp slt i32 %inc, %k
1138 br i1 %cmp, label %for.body, label %for.end
1144 ; Similar to @test7, we need to peel one extra iteration, and we can't do that
1145 ; as per the -unroll-peel-max-count=4, so this shouldn't be peeled at all.
1146 define void @test16(i32 %k) {
1147 ; CHECK-LABEL: @test16(
1148 ; CHECK-NEXT: for.body.lr.ph:
1149 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1151 ; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
1152 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[I_05]], 4
1153 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]]
1155 ; CHECK-NEXT: call void @f1()
1156 ; CHECK-NEXT: br label [[FOR_INC]]
1158 ; CHECK-NEXT: [[INC]] = add nsw i32 [[I_05]], 1
1159 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], [[K:%.*]]
1160 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END:%.*]]
1162 ; CHECK-NEXT: ret void
1168 %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
1169 %cmp1 = icmp eq i32 %i.05, 4
1170 br i1 %cmp1, label %if.then, label %for.inc
1177 %inc = add nsw i32 %i.05, 1
1178 %cmp = icmp slt i32 %inc, %k
1179 br i1 %cmp, label %for.body, label %for.end
1185 define void @test17() personality ptr undef{
1186 ; CHECK-LABEL: @test17(
1188 ; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
1189 ; CHECK: loop.peel.begin:
1190 ; CHECK-NEXT: br label [[LOOP_PEEL:%.*]]
1192 ; CHECK-NEXT: invoke void @f1()
1193 ; CHECK-NEXT: to label [[LOOP_PEEL_NEXT:%.*]] unwind label [[EH_UNW_LOOPEXIT_LOOPEXIT_SPLIT_LP:%.*]]
1194 ; CHECK: loop.peel.next:
1195 ; CHECK-NEXT: br label [[LOOP_PEEL_NEXT1:%.*]]
1196 ; CHECK: loop.peel.next1:
1197 ; CHECK-NEXT: br label [[BODY_PEEL_NEWPH:%.*]]
1198 ; CHECK: body.peel.newph:
1199 ; CHECK-NEXT: br label [[LOOP:%.*]]
1201 ; CHECK-NEXT: invoke void @f1()
1202 ; CHECK-NEXT: to label [[LOOP]] unwind label [[EH_UNW_LOOPEXIT_LOOPEXIT:%.*]], !llvm.loop [[LOOP14:![0-9]+]]
1203 ; CHECK: eh.Unw.loopexit.loopexit:
1204 ; CHECK-NEXT: [[LPAD_LOOPEXIT2:%.*]] = landingpad { ptr, i32 }
1205 ; CHECK-NEXT: catch ptr null
1206 ; CHECK-NEXT: br label [[EH_UNW_LOOPEXIT:%.*]]
1207 ; CHECK: eh.Unw.loopexit.loopexit.split-lp:
1208 ; CHECK-NEXT: [[LPAD_LOOPEXIT_SPLIT_LP:%.*]] = landingpad { ptr, i32 }
1209 ; CHECK-NEXT: catch ptr null
1210 ; CHECK-NEXT: br label [[EH_UNW_LOOPEXIT]]
1211 ; CHECK: eh.Unw.loopexit:
1212 ; CHECK-NEXT: ret void
1218 %const = phi i64 [ -33, %loop ], [ -20, %body ]
1220 to label %loop unwind label %eh.Unw.loopexit
1223 %lpad.loopexit = landingpad { ptr, i32 }
1228 ; Testcase reduced from PR48812.
1229 define void @test18(ptr %p) {
1230 ; CHECK-LABEL: @test18(
1232 ; CHECK-NEXT: br label [[LOOP_PEEL_BEGIN:%.*]]
1233 ; CHECK: loop.peel.begin:
1234 ; CHECK-NEXT: br label [[LOOP_PEEL:%.*]]
1236 ; CHECK-NEXT: br label [[LATCH_PEEL:%.*]]
1237 ; CHECK: latch.peel:
1238 ; CHECK-NEXT: [[CONTROL_PEEL:%.*]] = load volatile i32, ptr [[P:%.*]], align 4
1239 ; CHECK-NEXT: switch i32 [[CONTROL_PEEL]], label [[EXIT:%.*]] [
1240 ; CHECK-NEXT: i32 2, label [[LOOP_PEEL_NEXT:%.*]]
1242 ; CHECK: loop.peel.next:
1243 ; CHECK-NEXT: br label [[LOOP_PEEL_NEXT1:%.*]]
1244 ; CHECK: loop.peel.next1:
1245 ; CHECK-NEXT: br label [[INIT_PEEL_NEWPH:%.*]]
1246 ; CHECK: init.peel.newph:
1247 ; CHECK-NEXT: br label [[LOOP:%.*]]
1249 ; CHECK-NEXT: br label [[LATCH:%.*]]
1251 ; CHECK-NEXT: [[CONTROL:%.*]] = load volatile i32, ptr [[P]], align 4
1252 ; CHECK-NEXT: switch i32 [[CONTROL]], label [[EXIT_LOOPEXIT:%.*]] [
1253 ; CHECK-NEXT: i32 2, label [[LOOP]]
1254 ; CHECK-NEXT: ], !llvm.loop [[LOOP15:![0-9]+]]
1255 ; CHECK: exit.loopexit:
1256 ; CHECK-NEXT: br label [[EXIT]]
1258 ; CHECK-NEXT: ret void
1264 %const = phi i32 [ 40, %init ], [ 0, %latch ]
1268 %control = load volatile i32, ptr %p
1269 switch i32 %control, label %exit [
1277 ; Test that we can peel based on a select's condition
1278 define void @test19(i32 %num, i32 %a, i32 %b) {
1279 ; CHECK-LABEL: @test19(
1280 ; CHECK-NEXT: entry:
1281 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[NUM:%.*]], 0
1282 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1283 ; CHECK: for.body.preheader:
1284 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
1285 ; CHECK: for.body.peel.begin:
1286 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
1287 ; CHECK: for.body.peel:
1288 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp eq i32 0, 0
1289 ; CHECK-NEXT: [[COND_PEEL:%.*]] = select i1 [[CMP1_PEEL]], i32 [[A:%.*]], i32 [[B:%.*]]
1290 ; CHECK-NEXT: tail call void @f3(i32 noundef [[COND_PEEL]])
1291 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nuw nsw i32 0, 1
1292 ; CHECK-NEXT: [[EXITCOND_NOT_PEEL:%.*]] = icmp eq i32 [[INC_PEEL]], [[NUM]]
1293 ; CHECK-NEXT: br i1 [[EXITCOND_NOT_PEEL]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY_PEEL_NEXT:%.*]]
1294 ; CHECK: for.body.peel.next:
1295 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
1296 ; CHECK: for.body.peel.next1:
1297 ; CHECK-NEXT: br label [[FOR_BODY_PREHEADER_PEEL_NEWPH:%.*]]
1298 ; CHECK: for.body.preheader.peel.newph:
1299 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1300 ; CHECK: for.cond.cleanup.loopexit.loopexit:
1301 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
1302 ; CHECK: for.cond.cleanup.loopexit:
1303 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1304 ; CHECK: for.cond.cleanup:
1305 ; CHECK-NEXT: ret void
1307 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ [[INC_PEEL]], [[FOR_BODY_PREHEADER_PEEL_NEWPH]] ]
1308 ; CHECK-NEXT: tail call void @f3(i32 noundef [[B]])
1309 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
1310 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[NUM]]
1311 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT_LOOPEXIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP16:![0-9]+]]
1314 %cmp5 = icmp sgt i32 %num, 0
1315 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1317 for.cond.cleanup: ; preds = %for.body, %entry
1320 for.body: ; preds = %entry, %for.body
1321 %i.06 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
1322 %cmp1 = icmp eq i32 %i.06, 0
1323 %cond = select i1 %cmp1, i32 %a, i32 %b
1324 tail call void @f3(i32 noundef %cond) #2
1325 %inc = add nuw nsw i32 %i.06, 1
1326 %exitcond.not = icmp eq i32 %inc, %num
1327 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
1330 ; Test we can peel based on a and's LHS condition
1331 define void @test20(i32 %num, i32 %a, i32 %b) {
1332 ; CHECK-LABEL: @test20(
1333 ; CHECK-NEXT: entry:
1334 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[NUM:%.*]], 0
1335 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1336 ; CHECK: for.body.preheader:
1337 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1338 ; CHECK: for.cond.cleanup.loopexit:
1339 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1340 ; CHECK: for.cond.cleanup:
1341 ; CHECK-NEXT: ret void
1343 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1344 ; CHECK-NEXT: [[REM:%.*]] = and i32 [[I_08]], 1
1345 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[REM]], 0
1346 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[I_08]], 3
1347 ; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[CMP2]], [[CMP1]]
1348 ; CHECK-NEXT: br i1 [[AND_COND]], label [[IF_THEN:%.*]], label [[IF_END]]
1350 ; CHECK-NEXT: tail call void (...) @f1()
1351 ; CHECK-NEXT: br label [[IF_END]]
1353 ; CHECK-NEXT: tail call void (...) @f2()
1354 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
1355 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[NUM]]
1356 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
1359 %cmp5 = icmp sgt i32 %num, 0
1360 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1362 for.cond.cleanup: ; preds = %if.end, %entry
1365 for.body: ; preds = %entry, %if.end
1366 %i.08 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
1367 %rem = and i32 %i.08, 1
1368 %cmp1 = icmp eq i32 %rem, 0
1369 %cmp2 = icmp ult i32 %i.08, 3
1370 %and.cond = and i1 %cmp2, %cmp1
1371 br i1 %and.cond, label %if.then, label %if.end
1373 if.then: ; preds = %for.body
1374 tail call void (...) @f1()
1377 if.end: ; preds = %if.then, %for.body
1378 tail call void (...) @f2()
1379 %inc = add nuw nsw i32 %i.08, 1
1380 %exitcond.not = icmp eq i32 %inc, %num
1381 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
1384 ; Test we can peel based on a and's RHS condition
1385 define void @test21(i32 %num, i32 %a, i32 %b) {
1386 ; CHECK-LABEL: @test21(
1387 ; CHECK-NEXT: entry:
1388 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[NUM:%.*]], 0
1389 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1390 ; CHECK: for.body.preheader:
1391 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1392 ; CHECK: for.cond.cleanup.loopexit:
1393 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1394 ; CHECK: for.cond.cleanup:
1395 ; CHECK-NEXT: ret void
1397 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1398 ; CHECK-NEXT: [[REM:%.*]] = and i32 [[I_08]], 1
1399 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[REM]], 0
1400 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[I_08]], 3
1401 ; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1402 ; CHECK-NEXT: br i1 [[AND_COND]], label [[IF_THEN:%.*]], label [[IF_END]]
1404 ; CHECK-NEXT: tail call void (...) @f1()
1405 ; CHECK-NEXT: br label [[IF_END]]
1407 ; CHECK-NEXT: tail call void (...) @f2()
1408 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
1409 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[NUM]]
1410 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
1413 %cmp5 = icmp sgt i32 %num, 0
1414 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1416 for.cond.cleanup: ; preds = %if.end, %entry
1419 for.body: ; preds = %entry, %if.end
1420 %i.08 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
1421 %rem = and i32 %i.08, 1
1422 %cmp1 = icmp eq i32 %rem, 0
1423 %cmp2 = icmp ult i32 %i.08, 3
1424 %and.cond = and i1 %cmp1, %cmp2
1425 br i1 %and.cond, label %if.then, label %if.end
1427 if.then: ; preds = %for.body
1428 tail call void (...) @f1()
1431 if.end: ; preds = %if.then, %for.body
1432 tail call void (...) @f2()
1433 %inc = add nuw nsw i32 %i.08, 1
1434 %exitcond.not = icmp eq i32 %inc, %num
1435 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
1438 ; Test that we can peel based on a or's LHS condition
1439 define void @test22(i32 %num, i32 %a, i32 %b) {
1440 ; CHECK-LABEL: @test22(
1441 ; CHECK-NEXT: entry:
1442 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[NUM:%.*]], 0
1443 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1444 ; CHECK: for.body.preheader:
1445 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1446 ; CHECK: for.cond.cleanup.loopexit:
1447 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1448 ; CHECK: for.cond.cleanup:
1449 ; CHECK-NEXT: ret void
1451 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1452 ; CHECK-NEXT: [[REM:%.*]] = and i32 [[I_08]], 1
1453 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[REM]], 0
1454 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[I_08]], 3
1455 ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP2]], [[CMP1]]
1456 ; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_THEN:%.*]], label [[IF_END]]
1458 ; CHECK-NEXT: tail call void (i32, ...) @f1(i32 [[A:%.*]])
1459 ; CHECK-NEXT: br label [[IF_END]]
1461 ; CHECK-NEXT: tail call void (...) @f2()
1462 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
1463 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[NUM]]
1464 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
1467 %cmp5 = icmp sgt i32 %num, 0
1468 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1470 for.cond.cleanup: ; preds = %if.end, %entry
1473 for.body: ; preds = %entry, %if.end
1474 %i.08 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
1475 %rem = and i32 %i.08, 1
1476 %cmp1 = icmp eq i32 %rem, 0
1477 %cmp2 = icmp ult i32 %i.08, 3
1478 %or.cond = or i1 %cmp2, %cmp1
1479 br i1 %or.cond, label %if.then, label %if.end
1481 if.then: ; preds = %for.body
1482 tail call void (i32, ...) bitcast (void (...)* @f1 to void (i32, ...)*)(i32 %a)
1485 if.end: ; preds = %for.body, %if.then
1486 tail call void (...) @f2()
1487 %inc = add nuw nsw i32 %i.08, 1
1488 %exitcond.not = icmp eq i32 %inc, %num
1489 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
1492 ; Test that we can peel based on a or's RHS condition
1493 define void @test23(i32 %num, i32 %a, i32 %b) {
1494 ; CHECK-LABEL: @test23(
1495 ; CHECK-NEXT: entry:
1496 ; CHECK-NEXT: [[CMP5:%.*]] = icmp sgt i32 [[NUM:%.*]], 0
1497 ; CHECK-NEXT: br i1 [[CMP5]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1498 ; CHECK: for.body.preheader:
1499 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1500 ; CHECK: for.cond.cleanup.loopexit:
1501 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
1502 ; CHECK: for.cond.cleanup:
1503 ; CHECK-NEXT: ret void
1505 ; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1506 ; CHECK-NEXT: [[REM:%.*]] = and i32 [[I_08]], 1
1507 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[REM]], 0
1508 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i32 [[I_08]], 3
1509 ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP1]], [[CMP2]]
1510 ; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_THEN:%.*]], label [[IF_END]]
1512 ; CHECK-NEXT: tail call void (i32, ...) @f1(i32 [[A:%.*]])
1513 ; CHECK-NEXT: br label [[IF_END]]
1515 ; CHECK-NEXT: tail call void (...) @f2()
1516 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
1517 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[NUM]]
1518 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
1521 %cmp5 = icmp sgt i32 %num, 0
1522 br i1 %cmp5, label %for.body, label %for.cond.cleanup
1524 for.cond.cleanup: ; preds = %if.end, %entry
1527 for.body: ; preds = %entry, %if.end
1528 %i.08 = phi i32 [ %inc, %if.end ], [ 0, %entry ]
1529 %rem = and i32 %i.08, 1
1530 %cmp1 = icmp eq i32 %rem, 0
1531 %cmp2 = icmp ult i32 %i.08, 3
1532 %or.cond = or i1 %cmp1, %cmp2
1533 br i1 %or.cond, label %if.then, label %if.end
1535 if.then: ; preds = %for.body
1536 tail call void (i32, ...) bitcast (void (...)* @f1 to void (i32, ...)*)(i32 %a)
1539 if.end: ; preds = %for.body, %if.then
1540 tail call void (...) @f2()
1541 %inc = add nuw nsw i32 %i.08, 1
1542 %exitcond.not = icmp eq i32 %inc, %num
1543 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
1546 ; Test peeling when the loop is huge, >2^64
1547 define void @test24(i128 %k) {
1548 ; CHECK-LABEL: @test24(
1549 ; CHECK-NEXT: for.body.lr.ph:
1550 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
1551 ; CHECK: for.body.peel.begin:
1552 ; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
1553 ; CHECK: for.body.peel:
1554 ; CHECK-NEXT: [[CMP1_PEEL:%.*]] = icmp ult i128 0, 2
1555 ; CHECK-NEXT: br i1 [[CMP1_PEEL]], label [[IF_THEN_PEEL:%.*]], label [[IF_ELSE_PEEL:%.*]]
1556 ; CHECK: if.else.peel:
1557 ; CHECK-NEXT: call void @f2()
1558 ; CHECK-NEXT: br label [[FOR_INC_PEEL:%.*]]
1559 ; CHECK: if.then.peel:
1560 ; CHECK-NEXT: call void @f1()
1561 ; CHECK-NEXT: br label [[FOR_INC_PEEL]]
1562 ; CHECK: for.inc.peel:
1563 ; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i128 0, 1
1564 ; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp slt i128 [[INC_PEEL]], [[K:%.*]]
1565 ; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%.*]]
1566 ; CHECK: for.body.peel.next:
1567 ; CHECK-NEXT: br label [[FOR_BODY_PEEL2:%.*]]
1568 ; CHECK: for.body.peel2:
1569 ; CHECK-NEXT: [[CMP1_PEEL3:%.*]] = icmp ult i128 [[INC_PEEL]], 2
1570 ; CHECK-NEXT: br i1 [[CMP1_PEEL3]], label [[IF_THEN_PEEL5:%.*]], label [[IF_ELSE_PEEL4:%.*]]
1571 ; CHECK: if.else.peel4:
1572 ; CHECK-NEXT: call void @f2()
1573 ; CHECK-NEXT: br label [[FOR_INC_PEEL6:%.*]]
1574 ; CHECK: if.then.peel5:
1575 ; CHECK-NEXT: call void @f1()
1576 ; CHECK-NEXT: br label [[FOR_INC_PEEL6]]
1577 ; CHECK: for.inc.peel6:
1578 ; CHECK-NEXT: [[INC_PEEL7:%.*]] = add nsw i128 [[INC_PEEL]], 1
1579 ; CHECK-NEXT: [[CMP_PEEL8:%.*]] = icmp slt i128 [[INC_PEEL7]], [[K]]
1580 ; CHECK-NEXT: br i1 [[CMP_PEEL8]], label [[FOR_BODY_PEEL_NEXT1:%.*]], label [[FOR_END]]
1581 ; CHECK: for.body.peel.next1:
1582 ; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT9:%.*]]
1583 ; CHECK: for.body.peel.next9:
1584 ; CHECK-NEXT: br label [[FOR_BODY_LR_PH_PEEL_NEWPH:%.*]]
1585 ; CHECK: for.body.lr.ph.peel.newph:
1586 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1588 ; CHECK-NEXT: [[I_05:%.*]] = phi i128 [ [[INC_PEEL7]], [[FOR_BODY_LR_PH_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
1589 ; CHECK-NEXT: br i1 false, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
1591 ; CHECK-NEXT: call void @f1()
1592 ; CHECK-NEXT: br label [[FOR_INC]]
1594 ; CHECK-NEXT: call void @f2()
1595 ; CHECK-NEXT: br label [[FOR_INC]]
1597 ; CHECK-NEXT: [[INC]] = add nuw nsw i128 [[I_05]], 1
1598 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i128 [[INC]], [[K]]
1599 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop [[LOOP16:![0-9]+]]
1600 ; CHECK: for.end.loopexit:
1601 ; CHECK-NEXT: br label [[FOR_END]]
1603 ; CHECK-NEXT: ret void
1609 %i.05 = phi i128 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
1610 %cmp1 = icmp ult i128 %i.05, 2
1611 br i1 %cmp1, label %if.then, label %if.else
1622 %inc = add nsw i128 %i.05, 1
1623 %cmp = icmp slt i128 %inc, %k
1624 br i1 %cmp, label %for.body, label %for.end, !llvm.loop !1
1630 declare void @init()
1631 declare void @sink()