1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -aa-pipeline=basic-aa -passes=indvars,indvars -S -verify-loop-lcssa %s | FileCheck %s
4 ; Make sure SCEVExpander does not crash and introduce unnecessary LCSSA PHI nodes.
5 ; The tests are a collection of cases with crashes when preserving LCSSA PHI
6 ; nodes directly in SCEVExpander.
8 declare i1 @cond() readnone
10 define void @test1(i8 %x, ptr %ptr) {
11 ; CHECK-LABEL: @test1(
13 ; CHECK-NEXT: br label [[LAND_LHS_TRUE:%.*]]
14 ; CHECK: land.lhs.true:
15 ; CHECK-NEXT: br label [[WHILE_COND22:%.*]]
16 ; CHECK: while.cond22:
17 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
18 ; CHECK-NEXT: br i1 [[C_1]], label [[WHILE_COND22]], label [[WHILE_COND29_PREHEADER:%.*]]
19 ; CHECK: while.cond29.preheader:
20 ; CHECK-NEXT: br label [[WHILE_BODY35:%.*]]
21 ; CHECK: while.body35:
22 ; CHECK-NEXT: [[I_1107:%.*]] = phi i32 [ [[I_9:%.*]], [[IF_END224:%.*]] ], [ 0, [[WHILE_COND29_PREHEADER]] ]
23 ; CHECK-NEXT: br label [[WHILE_COND192:%.*]]
24 ; CHECK: while.cond192:
25 ; CHECK-NEXT: switch i8 [[X:%.*]], label [[WHILE_BODY205:%.*]] [
26 ; CHECK-NEXT: i8 59, label [[WHILE_COND215_PREHEADER:%.*]]
27 ; CHECK-NEXT: i8 10, label [[IF_END224_LOOPEXIT1:%.*]]
29 ; CHECK: while.cond215.preheader:
30 ; CHECK-NEXT: br label [[WHILE_COND215:%.*]]
31 ; CHECK: while.body205:
32 ; CHECK-NEXT: br label [[WHILE_COND192]]
33 ; CHECK: while.cond215:
34 ; CHECK-NEXT: [[I_8_IN:%.*]] = phi i32 [ [[I_8:%.*]], [[WHILE_COND215]] ], [ [[I_1107]], [[WHILE_COND215_PREHEADER]] ]
35 ; CHECK-NEXT: [[I_8]] = add nsw i32 [[I_8_IN]], 1
36 ; CHECK-NEXT: [[IDXPROM216:%.*]] = sext i32 [[I_8]] to i64
37 ; CHECK-NEXT: [[ARRAYIDX217:%.*]] = getelementptr inbounds [512 x i8], ptr [[PTR:%.*]], i64 0, i64 [[IDXPROM216]]
38 ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond()
39 ; CHECK-NEXT: br i1 [[C_2]], label [[WHILE_COND215]], label [[IF_END224_LOOPEXIT:%.*]]
40 ; CHECK: if.end224.loopexit:
41 ; CHECK-NEXT: [[I_8_LCSSA:%.*]] = phi i32 [ [[I_8]], [[WHILE_COND215]] ]
42 ; CHECK-NEXT: br label [[IF_END224]]
43 ; CHECK: if.end224.loopexit1:
44 ; CHECK-NEXT: br label [[IF_END224]]
46 ; CHECK-NEXT: [[I_9]] = phi i32 [ [[I_8_LCSSA]], [[IF_END224_LOOPEXIT]] ], [ [[I_1107]], [[IF_END224_LOOPEXIT1]] ]
47 ; CHECK-NEXT: [[C_3:%.*]] = call i1 @cond()
48 ; CHECK-NEXT: br i1 [[C_3]], label [[WHILE_END225:%.*]], label [[WHILE_BODY35]]
49 ; CHECK: while.end225:
50 ; CHECK-NEXT: br label [[LAND_LHS_TRUE]]
53 br label %land.lhs.true
55 land.lhs.true: ; preds = %while.end225, %entry
56 br label %while.cond22
58 while.cond22: ; preds = %while.cond22, %land.lhs.true
59 %c.1 = call i1 @cond()
60 br i1 %c.1, label %while.cond22, label %while.cond29.preheader
62 while.cond29.preheader: ; preds = %while.cond22
63 br label %while.body35
65 while.body35: ; preds = %if.end224, %while.cond29.preheader
66 %i.1107 = phi i32 [ %i.9, %if.end224 ], [ 0, %while.cond29.preheader ]
67 br label %while.cond192
69 while.cond192: ; preds = %while.body205, %while.body35
70 %i.7 = phi i32 [ %i.1107, %while.body35 ], [ %inc206, %while.body205 ]
71 switch i8 %x, label %while.body205 [
72 i8 59, label %while.cond215
73 i8 10, label %if.end224
76 while.body205: ; preds = %while.cond192
77 %inc206 = add nsw i32 %i.7, 1
78 br label %while.cond192
80 while.cond215: ; preds = %while.cond215, %while.cond192
81 %i.8.in = phi i32 [ %i.8, %while.cond215 ], [ %i.7, %while.cond192 ]
82 %i.8 = add nsw i32 %i.8.in, 1
83 %idxprom216 = sext i32 %i.8 to i64
84 %arrayidx217 = getelementptr inbounds [512 x i8], ptr %ptr, i64 0, i64 %idxprom216
85 %c.2 = call i1 @cond()
86 br i1 %c.2, label %while.cond215, label %if.end224
88 if.end224: ; preds = %while.cond215, %while.cond192
89 %i.9 = phi i32 [ %i.8, %while.cond215 ], [ %i.7, %while.cond192 ]
90 %c.3 = call i1 @cond()
91 br i1 %c.3, label %while.end225, label %while.body35
93 while.end225: ; preds = %if.end224
94 br label %land.lhs.true
97 define void @test2(i16 %x) {
98 ; CHECK-LABEL: @test2(
100 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
101 ; CHECK-NEXT: br i1 [[C_1]], label [[FOR_COND_PREHEADER:%.*]], label [[RETURN:%.*]]
102 ; CHECK: for.cond.preheader:
103 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
105 ; CHECK-NEXT: switch i16 [[X:%.*]], label [[RETURN_LOOPEXIT1:%.*]] [
106 ; CHECK-NEXT: i16 41, label [[FOR_END:%.*]]
107 ; CHECK-NEXT: i16 43, label [[FOR_COND]]
110 ; CHECK-NEXT: [[I_0_LCSSA2:%.*]] = phi i32 [ 0, [[FOR_COND]] ]
111 ; CHECK-NEXT: [[CMP8243:%.*]] = icmp sgt i32 [[I_0_LCSSA2]], 0
112 ; CHECK-NEXT: br i1 [[CMP8243]], label [[FOR_BODY84_PREHEADER:%.*]], label [[RETURN]]
113 ; CHECK: for.body84.preheader:
114 ; CHECK-NEXT: br label [[FOR_BODY84:%.*]]
116 ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond()
117 ; CHECK-NEXT: br i1 [[C_2]], label [[IF_END106:%.*]], label [[RETURN_LOOPEXIT:%.*]]
119 ; CHECK-NEXT: br i1 false, label [[FOR_BODY84]], label [[RETURN_LOOPEXIT]]
120 ; CHECK: return.loopexit:
121 ; CHECK-NEXT: br label [[RETURN]]
122 ; CHECK: return.loopexit1:
123 ; CHECK-NEXT: br label [[RETURN]]
125 ; CHECK-NEXT: ret void
128 %c.1 = call i1 @cond()
129 br i1 %c.1, label %for.cond, label %return
131 for.cond: ; preds = %for.cond, %entry
132 %i.0 = phi i32 [ %sub, %for.cond ], [ 0, %entry ]
133 %sub = add nsw i32 %i.0, -1
134 switch i16 %x, label %return [
135 i16 41, label %for.end
136 i16 43, label %for.cond
139 for.end: ; preds = %for.cond
140 %cmp8243 = icmp sgt i32 %i.0, 0
141 br i1 %cmp8243, label %for.body84, label %return
143 for.body84: ; preds = %if.end106, %for.end
144 %i.144 = phi i32 [ %inc, %if.end106 ], [ 0, %for.end ]
145 %c.2 = call i1 @cond()
146 br i1 %c.2, label %if.end106, label %return
148 if.end106: ; preds = %for.body84
149 %inc = add nuw nsw i32 %i.144, 1
150 %cmp82 = icmp slt i32 %inc, %i.0
151 br i1 %cmp82, label %for.body84, label %return
153 return: ; preds = %if.end106, %for.body84, %for.end, %for.cond, %entry
157 declare i32 @get.i32() readnone
159 define void @test3(ptr %ptr) {
160 ; CHECK-LABEL: @test3(
162 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
164 ; CHECK-NEXT: br label [[FOR_BODY1208:%.*]]
165 ; CHECK: for.body1208:
166 ; CHECK-NEXT: [[M_0804:%.*]] = phi i32 [ 1, [[WHILE_BODY]] ], [ [[INC1499:%.*]], [[FOR_INC1498:%.*]] ]
167 ; CHECK-NEXT: [[V:%.*]] = call i32 @get.i32()
168 ; CHECK-NEXT: [[CMP1358:%.*]] = icmp eq i32 [[V]], 0
169 ; CHECK-NEXT: br i1 [[CMP1358]], label [[IF_THEN1360:%.*]], label [[FOR_INC1498]]
170 ; CHECK: if.then1360:
171 ; CHECK-NEXT: [[M_0804_LCSSA:%.*]] = phi i32 [ [[M_0804]], [[FOR_BODY1208]] ]
172 ; CHECK-NEXT: br label [[FOR_COND1390:%.*]]
173 ; CHECK: for.cond1390:
174 ; CHECK-NEXT: [[M_2_IN:%.*]] = phi i32 [ [[M_0804_LCSSA]], [[IF_THEN1360]] ], [ 0, [[FOR_BODY1394:%.*]] ]
175 ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond()
176 ; CHECK-NEXT: br i1 [[C_2]], label [[FOR_BODY1394]], label [[FOR_END1469:%.*]]
177 ; CHECK: for.body1394:
178 ; CHECK-NEXT: br label [[FOR_COND1390]]
179 ; CHECK: for.end1469:
180 ; CHECK-NEXT: [[M_2_IN_LCSSA:%.*]] = phi i32 [ [[M_2_IN]], [[FOR_COND1390]] ]
181 ; CHECK-NEXT: store i32 [[M_2_IN_LCSSA]], ptr [[PTR:%.*]], align 4
182 ; CHECK-NEXT: br label [[WHILE_BODY]]
183 ; CHECK: for.inc1498:
184 ; CHECK-NEXT: [[INC1499]] = add nuw nsw i32 [[M_0804]], 1
185 ; CHECK-NEXT: br label [[FOR_BODY1208]]
190 while.body: ; preds = %for.end1469, %entry
191 br label %for.body1208
193 for.body1208: ; preds = %for.inc1498, %while.body
194 %m.0804 = phi i32 [ 1, %while.body ], [ %inc1499, %for.inc1498 ]
195 %v = call i32 @get.i32()
196 %cmp1358 = icmp eq i32 %v, 0
197 br i1 %cmp1358, label %if.then1360, label %for.inc1498
199 if.then1360: ; preds = %for.body1208
200 br label %for.cond1390
202 for.cond1390: ; preds = %for.body1394, %if.then1360
203 %m.2.in = phi i32 [ %m.0804, %if.then1360 ], [ 0, %for.body1394 ]
204 %c.2 = call i1 @cond()
205 br i1 %c.2, label %for.body1394, label %for.end1469
207 for.body1394: ; preds = %for.cond1390
208 br label %for.cond1390
210 for.end1469: ; preds = %for.cond1390
211 store i32 %m.2.in, ptr %ptr, align 4
214 for.inc1498: ; preds = %for.body1208
215 %inc1499 = add nuw nsw i32 %m.0804, 1
216 br label %for.body1208
219 define void @test4(ptr %ptr) {
220 ; CHECK-LABEL: @test4(
222 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
224 ; CHECK-NEXT: br label [[FOR_COND1204_PREHEADER:%.*]]
225 ; CHECK: for.cond1204.preheader:
226 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
227 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN1504:%.*]], label [[FOR_BODY1208_LR_PH:%.*]]
228 ; CHECK: for.body1208.lr.ph:
229 ; CHECK-NEXT: br label [[FOR_BODY1208:%.*]]
230 ; CHECK: for.body1208:
231 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ 0, [[FOR_BODY1208_LR_PH]] ], [ [[TMP1:%.*]], [[FOR_INC1498:%.*]] ]
232 ; CHECK-NEXT: [[M_0804:%.*]] = phi i32 [ 1, [[FOR_BODY1208_LR_PH]] ], [ [[INC1499:%.*]], [[FOR_INC1498]] ]
233 ; CHECK-NEXT: [[IDXPROM1212:%.*]] = zext i32 [[M_0804]] to i64
234 ; CHECK-NEXT: [[V:%.*]] = call i32 @get.i32()
235 ; CHECK-NEXT: [[CMP1215:%.*]] = icmp eq i32 0, [[V]]
236 ; CHECK-NEXT: [[YPOS1223:%.*]] = getelementptr inbounds i32, ptr [[PTR:%.*]], i64 [[IDXPROM1212]]
237 ; CHECK-NEXT: br i1 [[CMP1215]], label [[IF_THEN1217:%.*]], label [[IF_ELSE1351:%.*]]
238 ; CHECK: if.then1217:
239 ; CHECK-NEXT: [[M_0804_LCSSA:%.*]] = phi i32 [ [[M_0804]], [[FOR_BODY1208]] ]
240 ; CHECK-NEXT: br label [[FOR_COND1247:%.*]]
241 ; CHECK: for.cond1247:
242 ; CHECK-NEXT: [[M_1_IN:%.*]] = phi i32 [ [[M_0804_LCSSA]], [[IF_THEN1217]] ], [ [[M_1:%.*]], [[IF_THEN1260:%.*]] ]
243 ; CHECK-NEXT: [[M_1]] = add nuw nsw i32 [[M_1_IN]], 1
244 ; CHECK-NEXT: br label [[FOR_BODY1251:%.*]]
245 ; CHECK: for.body1251:
246 ; CHECK-NEXT: [[IDXPROM1255:%.*]] = zext i32 [[M_1]] to i64
247 ; CHECK-NEXT: [[XPOS1257:%.*]] = getelementptr inbounds i32, ptr [[PTR]], i64 [[IDXPROM1255]]
248 ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond()
249 ; CHECK-NEXT: br i1 [[C_2]], label [[IF_THEN1260]], label [[FOR_END1326:%.*]]
250 ; CHECK: if.then1260:
251 ; CHECK-NEXT: br label [[FOR_COND1247]]
252 ; CHECK: for.end1326:
253 ; CHECK-NEXT: br label [[IF_END1824:%.*]]
254 ; CHECK: if.else1351:
255 ; CHECK-NEXT: [[V_2:%.*]] = call i32 @get.i32()
256 ; CHECK-NEXT: [[CMP1358:%.*]] = icmp eq i32 [[V_2]], 0
257 ; CHECK-NEXT: br i1 [[CMP1358]], label [[IF_THEN1360:%.*]], label [[FOR_INC1498]]
258 ; CHECK: if.then1360:
259 ; CHECK-NEXT: [[DOTLCSSA2:%.*]] = phi i32 [ [[TMP0]], [[IF_ELSE1351]] ]
260 ; CHECK-NEXT: [[M_0804_LCSSA1:%.*]] = phi i32 [ [[M_0804]], [[IF_ELSE1351]] ]
261 ; CHECK-NEXT: [[CMP1392:%.*]] = icmp slt i32 [[M_0804_LCSSA1]], [[DOTLCSSA2]]
262 ; CHECK-NEXT: unreachable
263 ; CHECK: for.inc1498:
264 ; CHECK-NEXT: [[INC1499]] = add nuw nsw i32 [[M_0804]], 1
265 ; CHECK-NEXT: [[TMP1]] = load i32, ptr [[PTR]], align 8
266 ; CHECK-NEXT: br label [[FOR_BODY1208]]
267 ; CHECK: if.then1504:
268 ; CHECK-NEXT: unreachable
270 ; CHECK-NEXT: br label [[WHILE_BODY]]
275 while.body: ; preds = %if.end1824, %entry
276 br label %for.cond1204.preheader
278 for.cond1204.preheader: ; preds = %while.body
279 %c.1 = call i1 @cond()
280 br i1 %c.1, label %if.then1504, label %for.body1208.lr.ph
282 for.body1208.lr.ph: ; preds = %for.cond1204.preheader
283 br label %for.body1208
285 for.body1208: ; preds = %for.inc1498, %for.body1208.lr.ph
286 %0 = phi i32 [ 0, %for.body1208.lr.ph ], [ %1, %for.inc1498 ]
287 %m.0804 = phi i32 [ 1, %for.body1208.lr.ph ], [ %inc1499, %for.inc1498 ]
288 %idxprom1212 = zext i32 %m.0804 to i64
289 %v = call i32 @get.i32()
290 %cmp1215 = icmp eq i32 0, %v
291 %ypos1223 = getelementptr inbounds i32, ptr %ptr , i64 %idxprom1212
292 br i1 %cmp1215, label %if.then1217, label %if.else1351
294 if.then1217: ; preds = %for.body1208
295 br label %for.cond1247
297 for.cond1247: ; preds = %if.then1260, %if.then1217
298 %m.1.in = phi i32 [ %m.0804, %if.then1217 ], [ %m.1, %if.then1260 ]
299 %m.1 = add nuw nsw i32 %m.1.in, 1
300 %cmp1249 = icmp slt i32 %m.1.in, %0
301 br label %for.body1251
303 for.body1251: ; preds = %for.cond1247
304 %idxprom1255 = zext i32 %m.1 to i64
305 %xpos1257 = getelementptr inbounds i32, ptr %ptr, i64 %idxprom1255
306 %c.2 = call i1 @cond()
307 br i1 %c.2, label %if.then1260, label %for.end1326
309 if.then1260: ; preds = %for.body1251
310 br label %for.cond1247
312 for.end1326: ; preds = %for.body1251
315 if.else1351: ; preds = %for.body1208
316 %v.2 = call i32 @get.i32()
317 %cmp1358 = icmp eq i32 %v.2, 0
318 br i1 %cmp1358, label %if.then1360, label %for.inc1498
320 if.then1360: ; preds = %if.else1351
321 %cmp1392 = icmp slt i32 %m.0804, %0
324 for.inc1498: ; preds = %if.else1351
325 %inc1499 = add nuw nsw i32 %m.0804, 1
326 %1 = load i32, ptr %ptr, align 8
327 br label %for.body1208
329 if.then1504: ; preds = %for.cond1204.preheader
332 if.end1824: ; preds = %for.end1326
336 define void @test5(ptr %header, i32 %conv, i8 %n) {
337 ; CHECK-LABEL: @test5(
339 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
341 ; CHECK-NEXT: br label [[FOR_INNER:%.*]]
343 ; CHECK-NEXT: [[I_0_I:%.*]] = phi i32 [ 0, [[FOR_BODY]] ], [ [[INC_I:%.*]], [[FOR_INNER]] ]
344 ; CHECK-NEXT: [[INC_I]] = add nuw nsw i32 [[I_0_I]], 1
345 ; CHECK-NEXT: [[CMP7_I:%.*]] = icmp slt i8 [[N:%.*]], 0
346 ; CHECK-NEXT: br i1 [[CMP7_I]], label [[FOR_INNER]], label [[FOR_INNER_EXIT:%.*]]
347 ; CHECK: for.inner.exit:
348 ; CHECK-NEXT: [[INC_I_LCSSA:%.*]] = phi i32 [ [[INC_I]], [[FOR_INNER]] ]
349 ; CHECK-NEXT: br label [[FOR_INNER_2:%.*]]
350 ; CHECK: for.inner.2:
351 ; CHECK-NEXT: [[I_0_I1:%.*]] = phi i32 [ 0, [[FOR_INNER_EXIT]] ], [ [[INC_I3:%.*]], [[FOR_INNER_2]] ]
352 ; CHECK-NEXT: [[INC_I3]] = add nuw nsw i32 [[I_0_I1]], 1
353 ; CHECK-NEXT: [[CMP7_I4:%.*]] = icmp slt i8 [[N]], 0
354 ; CHECK-NEXT: br i1 [[CMP7_I4]], label [[FOR_INNER_2]], label [[FOR_INC:%.*]]
356 ; CHECK-NEXT: [[INC_I3_LCSSA:%.*]] = phi i32 [ [[INC_I3]], [[FOR_INNER_2]] ]
357 ; CHECK-NEXT: [[ADD85:%.*]] = add i32 [[INC_I_LCSSA]], [[INC_I3_LCSSA]]
358 ; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[WHILE_COND_PREHEADER:%.*]]
359 ; CHECK: while.cond.preheader:
360 ; CHECK-NEXT: [[ADD85_LCSSA:%.*]] = phi i32 [ [[ADD85]], [[FOR_INC]] ]
361 ; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[CONV:%.*]], 2
362 ; CHECK-NEXT: br label [[WHILE_COND:%.*]]
364 ; CHECK-NEXT: [[POS_8:%.*]] = phi i32 [ [[INC114:%.*]], [[WHILE_BODY:%.*]] ], [ [[ADD85_LCSSA]], [[WHILE_COND_PREHEADER]] ]
365 ; CHECK-NEXT: [[CMP112:%.*]] = icmp ult i32 [[POS_8]], [[SHL]]
366 ; CHECK-NEXT: br i1 [[CMP112]], label [[WHILE_BODY]], label [[CLEANUP122:%.*]]
368 ; CHECK-NEXT: [[INC114]] = add nuw i32 [[POS_8]], 1
369 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
370 ; CHECK-NEXT: br i1 [[C_1]], label [[WHILE_COND]], label [[CLEANUP122]]
372 ; CHECK-NEXT: ret void
375 %shl = shl nuw nsw i32 %conv, 2
378 for.body: ; preds = %entry, %for.inc
379 %pos.42 = phi i32 [ 0, %entry ], [ %add85, %for.inc ]
382 for.inner: ; preds = %for.body.i, %for.body
383 %i.0.i = phi i32 [ 0, %for.body ], [ %inc.i, %for.inner ]
384 %inc.i = add nuw nsw i32 %i.0.i, 1
385 %cmp7.i = icmp slt i8 %n, 0
386 br i1 %cmp7.i, label %for.inner, label %for.inner.exit
388 for.inner.exit: ; preds = %for.body.i
389 %add71 = add i32 %pos.42, %inc.i
390 br label %for.inner.2
392 for.inner.2: ; preds = %for.body.i6, %cleanup.cont74
393 %i.0.i1 = phi i32 [ 0, %for.inner.exit ], [ %inc.i3, %for.inner.2]
394 %inc.i3 = add nuw nsw i32 %i.0.i1, 1
395 %cmp7.i4 = icmp slt i8 %n, 0
396 br i1 %cmp7.i4, label %for.inner.2, label %for.inc
398 for.inc: ; preds = %for.body.i6
399 %add85 = add i32 %add71, %inc.i3
400 br i1 false, label %for.body, label %while.cond.preheader
402 while.cond.preheader: ; preds = %for.inc
405 while.cond: ; preds = %while.cond.preheader, %while.body
406 %pos.8 = phi i32 [ %inc114, %while.body ], [ %add85, %while.cond.preheader ]
407 %cmp112 = icmp ult i32 %pos.8, %shl
408 br i1 %cmp112, label %while.body, label %cleanup122
410 while.body: ; preds = %while.cond
411 %inc114 = add nuw i32 %pos.8, 1
412 %c.1 = call i1 @cond()
413 br i1 %c.1, label %while.cond, label %cleanup122
415 cleanup122: ; preds = %while.body, %while.cond
419 define void @test6(i8 %x) {
420 ; CHECK-LABEL: @test6(
422 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
423 ; CHECK-NEXT: br i1 [[C_1]], label [[LAND_RHS:%.*]], label [[WHILE_END316:%.*]]
425 ; CHECK-NEXT: br label [[WHILE_BODY35:%.*]]
426 ; CHECK: while.body35:
427 ; CHECK-NEXT: br label [[WHILE_COND192:%.*]]
428 ; CHECK: while.cond192:
429 ; CHECK-NEXT: switch i8 [[X:%.*]], label [[WHILE_BODY205:%.*]] [
430 ; CHECK-NEXT: i8 59, label [[WHILE_COND215_PREHEADER:%.*]]
431 ; CHECK-NEXT: i8 10, label [[IF_END224:%.*]]
433 ; CHECK: while.cond215.preheader:
434 ; CHECK-NEXT: [[I_7_LCSSA:%.*]] = phi i32 [ 0, [[WHILE_COND192]] ]
435 ; CHECK-NEXT: br label [[WHILE_COND215:%.*]]
436 ; CHECK: while.body205:
437 ; CHECK-NEXT: br label [[WHILE_COND192]]
438 ; CHECK: while.cond215:
439 ; CHECK-NEXT: [[I_8_IN:%.*]] = phi i32 [ [[I_8:%.*]], [[WHILE_COND215]] ], [ [[I_7_LCSSA]], [[WHILE_COND215_PREHEADER]] ]
440 ; CHECK-NEXT: [[I_8]] = add nuw nsw i32 [[I_8_IN]], 1
441 ; CHECK-NEXT: [[IDXPROM216:%.*]] = sext i32 [[I_8]] to i64
442 ; CHECK-NEXT: [[ARRAYIDX217:%.*]] = getelementptr inbounds [512 x i8], ptr null, i64 0, i64 [[IDXPROM216]]
443 ; CHECK-NEXT: br label [[WHILE_COND215]]
445 ; CHECK-NEXT: [[C_2:%.*]] = call i1 @cond()
446 ; CHECK-NEXT: br i1 [[C_2]], label [[WHILE_END225:%.*]], label [[WHILE_BODY35]]
447 ; CHECK: while.end225:
448 ; CHECK-NEXT: unreachable
449 ; CHECK: while.end316:
450 ; CHECK-NEXT: ret void
453 %c.1 = call i1 @cond()
454 br i1 %c.1, label %land.rhs, label %while.end316
456 land.rhs: ; preds = %entry
457 br label %while.body35
459 while.body35: ; preds = %if.end224, %land.rhs
460 br label %while.cond192
462 while.cond192: ; preds = %while.body205, %while.body35
463 %i.7 = phi i32 [ 0, %while.body35 ], [ %inc206, %while.body205 ]
464 switch i8 %x, label %while.body205 [
465 i8 59, label %while.cond215
466 i8 10, label %if.end224
469 while.body205: ; preds = %while.cond192
470 %inc206 = add nsw i32 %i.7, 1
471 br label %while.cond192
473 while.cond215: ; preds = %while.cond215, %while.cond192
474 %i.8.in = phi i32 [ %i.8, %while.cond215 ], [ %i.7, %while.cond192 ]
475 %i.8 = add nsw i32 %i.8.in, 1
476 %idxprom216 = sext i32 %i.8 to i64
477 %arrayidx217 = getelementptr inbounds [512 x i8], ptr null, i64 0, i64 %idxprom216
478 br label %while.cond215
480 if.end224: ; preds = %while.cond192
481 %c.2 = call i1 @cond()
482 br i1 %c.2, label %while.end225, label %while.body35
484 while.end225: ; preds = %if.end224
487 while.end316: ; preds = %entry
491 define void @test7(ptr %ptr) {
492 ; CHECK-LABEL: @test7(
494 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
496 ; CHECK-NEXT: br label [[FOR_BODY1208:%.*]]
497 ; CHECK: for.body1208:
498 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ undef, [[WHILE_BODY]] ], [ [[TMP1:%.*]], [[FOR_INC1498:%.*]] ]
499 ; CHECK-NEXT: [[M_048:%.*]] = phi i32 [ 1, [[WHILE_BODY]] ], [ [[INC1499:%.*]], [[FOR_INC1498]] ]
500 ; CHECK-NEXT: [[IDXPROM1212:%.*]] = zext i32 [[M_048]] to i64
501 ; CHECK-NEXT: [[XPOS1214:%.*]] = getelementptr inbounds i32, ptr [[PTR:%.*]], i64 [[IDXPROM1212]]
502 ; CHECK-NEXT: [[V_1:%.*]] = call i32 @get.i32()
503 ; CHECK-NEXT: [[CMP1215:%.*]] = icmp eq i32 0, [[V_1]]
504 ; CHECK-NEXT: br i1 [[CMP1215]], label [[IF_THEN1217:%.*]], label [[IF_ELSE1351:%.*]]
505 ; CHECK: if.then1217:
506 ; CHECK-NEXT: [[DOTLCSSA:%.*]] = phi i32 [ [[TMP0]], [[FOR_BODY1208]] ]
507 ; CHECK-NEXT: [[M_048_LCSSA:%.*]] = phi i32 [ [[M_048]], [[FOR_BODY1208]] ]
508 ; CHECK-NEXT: [[CMP1249_NOT_NOT:%.*]] = icmp slt i32 [[M_048_LCSSA]], [[DOTLCSSA]]
509 ; CHECK-NEXT: unreachable
510 ; CHECK: if.else1351:
511 ; CHECK-NEXT: [[CMP1358:%.*]] = icmp eq i32 0, undef
512 ; CHECK-NEXT: br i1 [[CMP1358]], label [[IF_THEN1360:%.*]], label [[FOR_INC1498]]
513 ; CHECK: if.then1360:
514 ; CHECK-NEXT: [[M_048_LCSSA1:%.*]] = phi i32 [ [[M_048]], [[IF_ELSE1351]] ]
515 ; CHECK-NEXT: br label [[FOR_COND1390:%.*]]
516 ; CHECK: for.cond1390:
517 ; CHECK-NEXT: [[M_2_IN:%.*]] = phi i32 [ [[M_048_LCSSA1]], [[IF_THEN1360]] ], [ [[M_2:%.*]], [[IF_THEN1403:%.*]] ]
518 ; CHECK-NEXT: [[M_2]] = add nuw nsw i32 [[M_2_IN]], 1
519 ; CHECK-NEXT: [[IDXPROM1398:%.*]] = zext i32 [[M_2]] to i64
520 ; CHECK-NEXT: br label [[IF_THEN1403]]
521 ; CHECK: if.then1403:
522 ; CHECK-NEXT: [[XPOS1409:%.*]] = getelementptr inbounds i32, ptr [[PTR]], i64 [[IDXPROM1398]]
523 ; CHECK-NEXT: [[C_1:%.*]] = call i1 @cond()
524 ; CHECK-NEXT: br i1 [[C_1]], label [[FOR_COND1390]], label [[FOR_END1469:%.*]]
525 ; CHECK: for.end1469:
526 ; CHECK-NEXT: br label [[IF_END1824:%.*]]
527 ; CHECK: for.inc1498:
528 ; CHECK-NEXT: [[INC1499]] = add nuw nsw i32 [[M_048]], 1
529 ; CHECK-NEXT: [[TMP1]] = load i32, ptr undef, align 8
530 ; CHECK-NEXT: br label [[FOR_BODY1208]]
532 ; CHECK-NEXT: br label [[WHILE_BODY]]
537 while.body: ; preds = %if.end1824, %entry
538 br label %for.body1208
540 for.body1208: ; preds = %for.inc1498, %while.body
541 %0 = phi i32 [ undef, %while.body ], [ %1, %for.inc1498 ]
542 %m.048 = phi i32 [ 1, %while.body ], [ %inc1499, %for.inc1498 ]
543 %idxprom1212 = zext i32 %m.048 to i64
544 %xpos1214 = getelementptr inbounds i32, ptr %ptr, i64 %idxprom1212
545 %v.1 = call i32 @get.i32()
546 %cmp1215 = icmp eq i32 0, %v.1
547 br i1 %cmp1215, label %if.then1217, label %if.else1351
549 if.then1217: ; preds = %for.body1208
550 %cmp1249.not.not = icmp slt i32 %m.048, %0
553 if.else1351: ; preds = %for.body1208
554 %cmp1358 = icmp eq i32 0, undef
555 br i1 %cmp1358, label %if.then1360, label %for.inc1498
557 if.then1360: ; preds = %if.else1351
558 br label %for.cond1390
560 for.cond1390: ; preds = %if.then1403, %if.then1360
561 %m.2.in = phi i32 [ %m.048, %if.then1360 ], [ %m.2, %if.then1403 ]
562 %m.2 = add nuw nsw i32 %m.2.in, 1
563 %cmp1392.not.not = icmp slt i32 %m.2.in, %0
564 %idxprom1398 = zext i32 %m.2 to i64
565 br label %if.then1403
567 if.then1403: ; preds = %for.cond1390
568 %xpos1409 = getelementptr inbounds i32, ptr %ptr, i64 %idxprom1398
569 %c.1 = call i1 @cond()
570 br i1 %c.1, label %for.cond1390, label %for.end1469
572 for.end1469: ; preds = %if.then1403
575 for.inc1498: ; preds = %if.else1351
576 %inc1499 = add nuw nsw i32 %m.048, 1
577 %1 = load i32, ptr undef, align 8
578 br label %for.body1208
580 if.end1824: ; preds = %for.end1469