1; RUN: opt < %s -S -indvars -verify-scev
2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
3target triple = "x86_64-apple-macosx10.8.0"
4
5define void @test1() nounwind uwtable ssp {
6entry:
7  br i1 undef, label %for.end, label %for.body
8
9for.body:                                         ; preds = %for.body, %entry
10  br i1 false, label %for.end, label %for.body
11
12for.end:                                          ; preds = %for.body, %entry
13  br i1 undef, label %for.end11, label %for.body3
14
15for.body3:                                        ; preds = %for.end
16  unreachable
17
18for.end11:                                        ; preds = %for.end
19  br i1 undef, label %while.body, label %while.end
20
21while.body:                                       ; preds = %for.end11
22  unreachable
23
24while.end:                                        ; preds = %for.end11
25  br i1 undef, label %if.end115, label %for.cond109
26
27for.cond109:                                      ; preds = %while.end
28  unreachable
29
30if.end115:                                        ; preds = %while.end
31  br i1 undef, label %while.body119.lr.ph.lr.ph, label %for.cond612
32
33while.body119.lr.ph.lr.ph:                        ; preds = %if.end115
34  br i1 undef, label %for.cond612, label %if.end123.us
35
36if.end123.us:                                     ; preds = %while.body119.lr.ph.lr.ph
37  br label %for.cond132.us
38
39for.cond132.us:                                   ; preds = %for.cond132.us, %if.end123.us
40  br i1 undef, label %if.then136.us, label %for.cond132.us
41
42if.then136.us:                                    ; preds = %for.cond132.us
43  br i1 undef, label %while.end220, label %while.body211
44
45while.body211:                                    ; preds = %while.body211, %if.then136.us
46  br i1 undef, label %while.end220, label %while.body211
47
48while.end220:                                     ; preds = %while.body211, %if.then136.us
49  br label %for.cond246.outer
50
51for.cond246.outer:                                ; preds = %for.inc558, %for.cond394.preheader, %if.then274, %for.cond404.preheader, %while.end220
52  br label %for.cond246
53
54for.cond246:                                      ; preds = %for.cond372.loopexit, %for.cond246.outer
55  br i1 undef, label %for.end562, label %if.end250
56
57if.end250:                                        ; preds = %for.cond246
58  br i1 undef, label %if.end256, label %for.end562
59
60if.end256:                                        ; preds = %if.end250
61  %cmp272 = icmp eq i32 undef, undef
62  br i1 %cmp272, label %if.then274, label %for.cond404.preheader
63
64for.cond404.preheader:                            ; preds = %if.end256
65  br i1 undef, label %for.cond246.outer, label %for.body409.lr.ph
66
67for.body409.lr.ph:                                ; preds = %for.cond404.preheader
68  br label %for.body409
69
70if.then274:                                       ; preds = %if.end256
71  br i1 undef, label %for.cond246.outer, label %if.end309
72
73if.end309:                                        ; preds = %if.then274
74  br i1 undef, label %for.cond372.loopexit, label %for.body361
75
76for.body361:                                      ; preds = %for.body361, %if.end309
77  br i1 undef, label %for.cond372.loopexit, label %for.body361
78
79for.cond372.loopexit:                             ; preds = %for.body361, %if.end309
80  br i1 undef, label %for.cond394.preheader, label %for.cond246
81
82for.cond394.preheader:                            ; preds = %for.cond372.loopexit
83  br i1 undef, label %for.cond246.outer, label %for.body397
84
85for.body397:                                      ; preds = %for.cond394.preheader
86  unreachable
87
88for.body409:                                      ; preds = %for.inc558, %for.body409.lr.ph
89  %k.029 = phi i32 [ 1, %for.body409.lr.ph ], [ %inc559, %for.inc558 ]
90  br i1 undef, label %if.then412, label %if.else433
91
92if.then412:                                       ; preds = %for.body409
93  br label %if.end440
94
95if.else433:                                       ; preds = %for.body409
96  br label %if.end440
97
98if.end440:                                        ; preds = %if.else433, %if.then412
99  br i1 undef, label %for.inc558, label %if.end461
100
101if.end461:                                        ; preds = %if.end440
102  br i1 undef, label %for.cond528.loopexit, label %for.body517
103
104for.body517:                                      ; preds = %for.body517, %if.end461
105  br i1 undef, label %for.cond528.loopexit, label %for.body517
106
107for.cond528.loopexit:                             ; preds = %for.body517, %if.end461
108  br label %for.inc558
109
110for.inc558:                                       ; preds = %for.cond528.loopexit, %if.end440
111  %inc559 = add nsw i32 %k.029, 1
112  %cmp407 = icmp sgt i32 %inc559, undef
113  br i1 %cmp407, label %for.cond246.outer, label %for.body409
114
115for.end562:                                       ; preds = %if.end250, %for.cond246
116  unreachable
117
118for.cond612:                                      ; preds = %while.body119.lr.ph.lr.ph, %if.end115
119  unreachable
120}
121
122define void @test2() nounwind uwtable ssp {
123entry:
124  br i1 undef, label %for.end, label %for.body
125
126for.body:                                         ; preds = %for.body, %entry
127  br i1 undef, label %for.end, label %for.body
128
129for.end:                                          ; preds = %for.body, %entry
130  br i1 undef, label %for.end11, label %for.body3
131
132for.body3:                                        ; preds = %for.end
133  unreachable
134
135for.end11:                                        ; preds = %for.end
136  br i1 undef, label %while.body, label %while.end
137
138while.body:                                       ; preds = %for.end11
139  unreachable
140
141while.end:                                        ; preds = %for.end11
142  br i1 undef, label %if.end115, label %for.cond109
143
144for.cond109:                                      ; preds = %while.end
145  unreachable
146
147if.end115:                                        ; preds = %while.end
148  br i1 undef, label %while.body119.lr.ph.lr.ph, label %for.cond612
149
150while.body119.lr.ph.lr.ph:                        ; preds = %if.end115
151  br i1 undef, label %for.cond612, label %if.end123.us
152
153if.end123.us:                                     ; preds = %while.body119.lr.ph.lr.ph
154  br label %for.cond132.us
155
156for.cond132.us:                                   ; preds = %for.cond132.us, %if.end123.us
157  br i1 undef, label %if.then136.us, label %for.cond132.us
158
159if.then136.us:                                    ; preds = %for.cond132.us
160  br i1 undef, label %while.end220, label %while.body211
161
162while.body211:                                    ; preds = %while.body211, %if.then136.us
163  br i1 undef, label %while.end220, label %while.body211
164
165while.end220:                                     ; preds = %while.body211, %if.then136.us
166  br label %for.cond246.outer
167
168for.cond246.outer:                                ; preds = %for.inc558, %for.cond394.preheader, %if.then274, %for.cond404.preheader, %while.end220
169  br label %for.cond246
170
171for.cond246:                                      ; preds = %for.cond372.loopexit, %for.cond246.outer
172  br i1 undef, label %for.end562, label %if.end250
173
174if.end250:                                        ; preds = %for.cond246
175  br i1 undef, label %if.end256, label %for.end562
176
177if.end256:                                        ; preds = %if.end250
178  %0 = load i32, i32* undef, align 4
179  br i1 undef, label %if.then274, label %for.cond404.preheader
180
181for.cond404.preheader:                            ; preds = %if.end256
182  %add406 = add i32 0, %0
183  br i1 undef, label %for.cond246.outer, label %for.body409.lr.ph
184
185for.body409.lr.ph:                                ; preds = %for.cond404.preheader
186  br label %for.body409
187
188if.then274:                                       ; preds = %if.end256
189  br i1 undef, label %for.cond246.outer, label %if.end309
190
191if.end309:                                        ; preds = %if.then274
192  br i1 undef, label %for.cond372.loopexit, label %for.body361
193
194for.body361:                                      ; preds = %for.body361, %if.end309
195  br i1 undef, label %for.cond372.loopexit, label %for.body361
196
197for.cond372.loopexit:                             ; preds = %for.body361, %if.end309
198  br i1 undef, label %for.cond394.preheader, label %for.cond246
199
200for.cond394.preheader:                            ; preds = %for.cond372.loopexit
201  br i1 undef, label %for.cond246.outer, label %for.body397
202
203for.body397:                                      ; preds = %for.cond394.preheader
204  unreachable
205
206for.body409:                                      ; preds = %for.inc558, %for.body409.lr.ph
207  %k.029 = phi i32 [ 1, %for.body409.lr.ph ], [ %inc559, %for.inc558 ]
208  br i1 undef, label %if.then412, label %if.else433
209
210if.then412:                                       ; preds = %for.body409
211  br label %if.end440
212
213if.else433:                                       ; preds = %for.body409
214  br label %if.end440
215
216if.end440:                                        ; preds = %if.else433, %if.then412
217  br i1 undef, label %for.inc558, label %if.end461
218
219if.end461:                                        ; preds = %if.end440
220  br i1 undef, label %for.cond528.loopexit, label %for.body517
221
222for.body517:                                      ; preds = %for.body517, %if.end461
223  br i1 undef, label %for.cond528.loopexit, label %for.body517
224
225for.cond528.loopexit:                             ; preds = %for.body517, %if.end461
226  br label %for.inc558
227
228for.inc558:                                       ; preds = %for.cond528.loopexit, %if.end440
229  %inc559 = add nsw i32 %k.029, 1
230  %cmp407 = icmp sgt i32 %inc559, %add406
231  br i1 %cmp407, label %for.cond246.outer, label %for.body409
232
233for.end562:                                       ; preds = %if.end250, %for.cond246
234  unreachable
235
236for.cond612:                                      ; preds = %while.body119.lr.ph.lr.ph, %if.end115
237  unreachable
238}
239
240define void @test3() nounwind uwtable ssp {
241entry:
242  br i1 undef, label %for.end, label %for.body
243
244for.body:                                         ; preds = %for.body, %entry
245  br i1 undef, label %for.end, label %for.body
246
247for.end:                                          ; preds = %for.body, %entry
248  br i1 undef, label %for.end11, label %for.body3
249
250for.body3:                                        ; preds = %for.end
251  unreachable
252
253for.end11:                                        ; preds = %for.end
254  br i1 undef, label %while.body, label %while.end
255
256while.body:                                       ; preds = %for.end11
257  unreachable
258
259while.end:                                        ; preds = %for.end11
260  br i1 undef, label %if.end115, label %for.cond109
261
262for.cond109:                                      ; preds = %while.end
263  unreachable
264
265if.end115:                                        ; preds = %while.end
266  br i1 undef, label %while.body119.lr.ph.lr.ph, label %for.cond612
267
268while.body119.lr.ph.lr.ph:                        ; preds = %if.end115
269  br i1 undef, label %for.cond612, label %if.end123.us
270
271if.end123.us:                                     ; preds = %while.body119.lr.ph.lr.ph
272  br label %for.cond132.us
273
274for.cond132.us:                                   ; preds = %for.cond132.us, %if.end123.us
275  br i1 undef, label %if.then136.us, label %for.cond132.us
276
277if.then136.us:                                    ; preds = %for.cond132.us
278  br i1 undef, label %while.end220, label %while.body211
279
280while.body211:                                    ; preds = %while.body211, %if.then136.us
281  br i1 undef, label %while.end220, label %while.body211
282
283while.end220:                                     ; preds = %while.body211, %if.then136.us
284  br label %for.cond246.outer
285
286for.cond246.outer:                                ; preds = %for.inc558, %for.cond394.preheader, %if.then274, %for.cond404.preheader, %while.end220
287  br label %for.cond246
288
289for.cond246:                                      ; preds = %for.cond372.loopexit, %for.cond246.outer
290  br i1 undef, label %for.end562, label %if.end250
291
292if.end250:                                        ; preds = %for.cond246
293  br i1 undef, label %if.end256, label %for.end562
294
295if.end256:                                        ; preds = %if.end250
296  br i1 undef, label %if.then274, label %for.cond404.preheader
297
298for.cond404.preheader:                            ; preds = %if.end256
299  br i1 undef, label %for.cond246.outer, label %for.body409.lr.ph
300
301for.body409.lr.ph:                                ; preds = %for.cond404.preheader
302  br label %for.body409
303
304if.then274:                                       ; preds = %if.end256
305  br i1 undef, label %for.cond246.outer, label %if.end309
306
307if.end309:                                        ; preds = %if.then274
308  br i1 undef, label %for.cond372.loopexit, label %for.body361
309
310for.body361:                                      ; preds = %for.body361, %if.end309
311  br i1 undef, label %for.cond372.loopexit, label %for.body361
312
313for.cond372.loopexit:                             ; preds = %for.body361, %if.end309
314  br i1 undef, label %for.cond394.preheader, label %for.cond246
315
316for.cond394.preheader:                            ; preds = %for.cond372.loopexit
317  br i1 undef, label %for.cond246.outer, label %for.body397
318
319for.body397:                                      ; preds = %for.cond394.preheader
320  unreachable
321
322for.body409:                                      ; preds = %for.inc558, %for.body409.lr.ph
323  br i1 undef, label %if.then412, label %if.else433
324
325if.then412:                                       ; preds = %for.body409
326  br label %if.end440
327
328if.else433:                                       ; preds = %for.body409
329  br label %if.end440
330
331if.end440:                                        ; preds = %if.else433, %if.then412
332  br i1 undef, label %for.inc558, label %if.end461
333
334if.end461:                                        ; preds = %if.end440
335  br i1 undef, label %for.cond528.loopexit, label %for.body517
336
337for.body517:                                      ; preds = %for.body517, %if.end461
338  br i1 undef, label %for.cond528.loopexit, label %for.body517
339
340for.cond528.loopexit:                             ; preds = %for.body517, %if.end461
341  br label %for.inc558
342
343for.inc558:                                       ; preds = %for.cond528.loopexit, %if.end440
344  br i1 undef, label %for.cond246.outer, label %for.body409
345
346for.end562:                                       ; preds = %if.end250, %for.cond246
347  unreachable
348
349for.cond612:                                      ; preds = %while.body119.lr.ph.lr.ph, %if.end115
350  unreachable
351}
352
353define void @test4() nounwind uwtable ssp {
354entry:
355  br i1 undef, label %if.end8, label %if.else
356
357if.else:                                          ; preds = %entry
358  br label %if.end8
359
360if.end8:                                          ; preds = %if.else, %entry
361  br i1 undef, label %if.end26, label %if.else22
362
363if.else22:                                        ; preds = %if.end8
364  br label %if.end26
365
366if.end26:                                         ; preds = %if.else22, %if.end8
367  br i1 undef, label %if.end35, label %if.else31
368
369if.else31:                                        ; preds = %if.end26
370  br label %if.end35
371
372if.end35:                                         ; preds = %if.else31, %if.end26
373  br i1 undef, label %for.end226, label %for.body.lr.ph
374
375for.body.lr.ph:                                   ; preds = %if.end35
376  br label %for.body48
377
378for.body48:                                       ; preds = %for.inc221, %for.body.lr.ph
379  br i1 undef, label %for.inc221, label %for.body65.lr.ph
380
381for.body65.lr.ph:                                 ; preds = %for.body48
382  %0 = load i32, i32* undef, align 4
383  %1 = sext i32 %0 to i64
384  br label %for.body65.us
385
386for.body65.us:                                    ; preds = %for.inc219.us, %for.body65.lr.ph
387  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc219.us ], [ 1, %for.body65.lr.ph ]
388  br i1 undef, label %for.inc219.us, label %if.end72.us
389
390if.end72.us:                                      ; preds = %for.body65.us
391  br i1 undef, label %if.end93.us, label %if.then76.us
392
393if.then76.us:                                     ; preds = %if.end72.us
394  br label %if.end93.us
395
396if.end93.us:                                      ; preds = %if.then76.us, %if.end72.us
397  br i1 undef, label %if.end110.us, label %for.inc219.us
398
399if.end110.us:                                     ; preds = %if.end93.us
400  br i1 undef, label %for.inc219.us, label %for.body142.us
401
402for.body142.us:                                   ; preds = %for.cond139.loopexit.us, %if.end110.us
403  br label %for.cond152.us
404
405for.cond152.us:                                   ; preds = %for.cond152.us, %for.body142.us
406  br i1 undef, label %for.cond139.loopexit.us, label %for.cond152.us
407
408for.inc219.us:                                    ; preds = %for.cond139.loopexit.us, %if.end110.us, %if.end93.us, %for.body65.us
409  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
410  %cmp64.us = icmp sgt i64 %indvars.iv.next, %1
411  br i1 %cmp64.us, label %for.inc221, label %for.body65.us
412
413for.cond139.loopexit.us:                          ; preds = %for.cond152.us
414  br i1 undef, label %for.inc219.us, label %for.body142.us
415
416for.inc221:                                       ; preds = %for.inc219.us, %for.body48
417  br label %for.body48
418
419for.end226:                                       ; preds = %if.end35
420  ret void
421}
422