• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -disable-block-placement -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 | FileCheck %s
2; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals -tail-dup-placement=0 -verify-machineinstrs -fast-isel=false -machine-sink-split-probability-threshold=0 -cgp-freq-ratio-to-skip-merge=1000 | FileCheck -check-prefix=OPT %s
3
4; Test the CFG stackifier pass.
5
6; Explicitly disable fast-isel, since it gets implicitly enabled in the
7; optnone test.
8
9target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
10target triple = "wasm32-unknown-unknown"
11
12declare void @something()
13
14; Test that loops are made contiguous, even in the presence of split backedges.
15
16; CHECK-LABEL: test0:
17; CHECK: loop
18; CHECK-NEXT: block
19; CHECK:      i32.lt_s
20; CHECK-NEXT: br_if
21; CHECK-NEXT: return
22; CHECK-NEXT: .LBB0_3:
23; CHECK-NEXT: end_block
24; CHECK-NEXT: i32.const
25; CHECK-NEXT: i32.add
26; CHECK-NEXT: call
27; CHECK-NEXT: br
28; CHECK-NEXT: .LBB0_4:
29; CHECK-NEXT: end_loop
30; OPT-LABEL: test0:
31; OPT: loop
32; OPT:      i32.ge_s
33; OPT-NEXT: br_if
34; OPT-NEXT: i32.const
35; OPT-NEXT: i32.add
36; OPT-NOT: br
37; OPT: call
38; OPT: br 0{{$}}
39; OPT: return{{$}}
40define void @test0(i32 %n) {
41entry:
42  br label %header
43
44header:
45  %i = phi i32 [ 0, %entry ], [ %i.next, %back ]
46  %i.next = add i32 %i, 1
47
48  %c = icmp slt i32 %i.next, %n
49  br i1 %c, label %back, label %exit
50
51exit:
52  ret void
53
54back:
55  call void @something()
56  br label %header
57}
58
59; Same as test0, but the branch condition is reversed.
60
61; CHECK-LABEL: test1:
62; CHECK: loop
63; CHECK-NEXT: block
64; CHECK:      i32.lt_s
65; CHECK-NEXT: br_if
66; CHECK-NEXT: return
67; CHECK-NEXT: .LBB1_3:
68; CHECK-NEXT: end_block
69; CHECK-NEXT: i32.const
70; CHECK-NEXT: i32.add
71; CHECK-NEXT: call
72; CHECK-NEXT: br
73; CHECK-NEXT: .LBB1_4:
74; CHECK-NEXT: end_loop
75; OPT-LABEL: test1:
76; OPT: loop
77; OPT:      i32.ge_s
78; OPT-NEXT: br_if
79; OPT-NEXT: i32.const
80; OPT-NEXT: i32.add
81; OPT-NOT: br
82; OPT: call
83; OPT: br 0{{$}}
84; OPT: return{{$}}
85define void @test1(i32 %n) {
86entry:
87  br label %header
88
89header:
90  %i = phi i32 [ 0, %entry ], [ %i.next, %back ]
91  %i.next = add i32 %i, 1
92
93  %c = icmp sge i32 %i.next, %n
94  br i1 %c, label %exit, label %back
95
96exit:
97  ret void
98
99back:
100  call void @something()
101  br label %header
102}
103
104; Test that a simple loop is handled as expected.
105
106; CHECK-LABEL: test2:
107; CHECK-NOT: local
108; CHECK: block   {{$}}
109; CHECK: br_if 0, {{[^,]+}}{{$}}
110; CHECK: .LBB2_{{[0-9]+}}:
111; CHECK: loop
112; CHECK: br_if 0, $pop{{[0-9]+}}{{$}}
113; CHECK: .LBB2_{{[0-9]+}}:
114; CHECK: end_loop
115; CHECK: end_block
116; CHECK: return{{$}}
117; OPT-LABEL: test2:
118; OPT-NOT: local
119; OPT: block   {{$}}
120; OPT: br_if 0, {{[^,]+}}{{$}}
121; OPT: .LBB2_{{[0-9]+}}:
122; OPT: loop
123; OPT: br_if 0, $pop{{[0-9]+}}{{$}}
124; OPT: .LBB2_{{[0-9]+}}:
125; OPT: end_loop
126; OPT: end_block
127; OPT: return{{$}}
128define void @test2(double* nocapture %p, i32 %n) {
129entry:
130  %cmp.4 = icmp sgt i32 %n, 0
131  br i1 %cmp.4, label %for.body.preheader, label %for.end
132
133for.body.preheader:
134  br label %for.body
135
136for.body:
137  %i.05 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
138  %arrayidx = getelementptr inbounds double, double* %p, i32 %i.05
139  %0 = load double, double* %arrayidx, align 8
140  %mul = fmul double %0, 3.200000e+00
141  store double %mul, double* %arrayidx, align 8
142  %inc = add nuw nsw i32 %i.05, 1
143  %exitcond = icmp eq i32 %inc, %n
144  br i1 %exitcond, label %for.end.loopexit, label %for.body
145
146for.end.loopexit:
147  br label %for.end
148
149for.end:
150  ret void
151}
152
153; CHECK-LABEL: doublediamond:
154; CHECK: block   {{$}}
155; CHECK-NEXT: block   {{$}}
156; CHECK: br_if 0, ${{[^,]+}}{{$}}
157; CHECK: br 1{{$}}
158; CHECK: .LBB3_2:
159; CHECK-NEXT: end_block{{$}}
160; CHECK: block   {{$}}
161; CHECK: br_if 0, ${{[^,]+}}{{$}}
162; CHECK: br 1{{$}}
163; CHECK: .LBB3_4:
164; CHECK-NEXT: end_block{{$}}
165; CHECK: .LBB3_5:
166; CHECK-NEXT: end_block{{$}}
167; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
168; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
169; OPT-LABEL: doublediamond:
170; OPT:      block   {{$}}
171; OPT-NEXT: block   {{$}}
172; OPT-NEXT: block   {{$}}
173; OPT:      br_if 0, ${{[^,]+}}{{$}}
174; OPT:      br_if 1, ${{[^,]+}}{{$}}
175; OPT:      br 2{{$}}
176; OPT-NEXT: .LBB3_3:
177; OPT-NEXT: end_block
178; OPT:      br 1{{$}}
179; OPT-NEXT: .LBB3_4:
180; OPT:      .LBB3_5:
181; OPT-NEXT: end_block
182; OPT:      return $pop{{[0-9]+}}{{$}}
183define i32 @doublediamond(i32 %a, i32 %b, i32* %p) {
184entry:
185  %c = icmp eq i32 %a, 0
186  %d = icmp eq i32 %b, 0
187  store volatile i32 0, i32* %p
188  br i1 %c, label %true, label %false
189true:
190  store volatile i32 1, i32* %p
191  br label %exit
192false:
193  store volatile i32 2, i32* %p
194  br i1 %d, label %ft, label %ff
195ft:
196  store volatile i32 3, i32* %p
197  br label %exit
198ff:
199  store volatile i32 4, i32* %p
200  br label %exit
201exit:
202  store volatile i32 5, i32* %p
203  ret i32 0
204}
205
206; CHECK-LABEL: triangle:
207; CHECK: block   {{$}}
208; CHECK: br_if 0, $1{{$}}
209; CHECK: .LBB4_2:
210; CHECK: return
211; OPT-LABEL: triangle:
212; OPT: block   {{$}}
213; OPT: br_if 0, $1{{$}}
214; OPT: .LBB4_2:
215; OPT: return
216define i32 @triangle(i32* %p, i32 %a) {
217entry:
218  %c = icmp eq i32 %a, 0
219  store volatile i32 0, i32* %p
220  br i1 %c, label %true, label %exit
221true:
222  store volatile i32 1, i32* %p
223  br label %exit
224exit:
225  store volatile i32 2, i32* %p
226  ret i32 0
227}
228
229; CHECK-LABEL: diamond:
230; CHECK: block   {{$}}
231; CHECK: block   {{$}}
232; CHECK: br_if 0, $1{{$}}
233; CHECK: br 1{{$}}
234; CHECK: .LBB5_2:
235; CHECK: .LBB5_3:
236; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
237; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
238; OPT-LABEL: diamond:
239; OPT: block   {{$}}
240; OPT: block   {{$}}
241; OPT: br_if 0, {{[^,]+}}{{$}}
242; OPT: br 1{{$}}
243; OPT: .LBB5_2:
244; OPT: .LBB5_3:
245; OPT: i32.const $push{{[0-9]+}}=, 0{{$}}
246; OPT-NEXT: return $pop{{[0-9]+}}{{$}}
247define i32 @diamond(i32* %p, i32 %a) {
248entry:
249  %c = icmp eq i32 %a, 0
250  store volatile i32 0, i32* %p
251  br i1 %c, label %true, label %false
252true:
253  store volatile i32 1, i32* %p
254  br label %exit
255false:
256  store volatile i32 2, i32* %p
257  br label %exit
258exit:
259  store volatile i32 3, i32* %p
260  ret i32 0
261}
262
263; CHECK-LABEL: single_block:
264; CHECK-NOT: br
265; CHECK: return $pop{{[0-9]+}}{{$}}
266; OPT-LABEL: single_block:
267; OPT-NOT: br
268; OPT: return $pop{{[0-9]+}}{{$}}
269define i32 @single_block(i32* %p) {
270entry:
271  store volatile i32 0, i32* %p
272  ret i32 0
273}
274
275; CHECK-LABEL: minimal_loop:
276; CHECK-NOT: br
277; CHECK: .LBB7_1:
278; CHECK: loop i32
279; CHECK: i32.store 0($0), $pop{{[0-9]+}}{{$}}
280; CHECK: br 0{{$}}
281; CHECK: .LBB7_2:
282; OPT-LABEL: minimal_loop:
283; OPT-NOT: br
284; OPT: .LBB7_1:
285; OPT: loop i32
286; OPT: i32.store 0($0), $pop{{[0-9]+}}{{$}}
287; OPT: br 0{{$}}
288; OPT: .LBB7_2:
289define i32 @minimal_loop(i32* %p) {
290entry:
291  store volatile i32 0, i32* %p
292  br label %loop
293loop:
294  store volatile i32 1, i32* %p
295  br label %loop
296}
297
298; CHECK-LABEL: simple_loop:
299; CHECK-NOT: br
300; CHECK: .LBB8_1:
301; CHECK: loop    {{$}}
302; CHECK: br_if 0, $pop{{[0-9]+}}{{$}}
303; CHECK-NEXT: end_loop{{$}}
304; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
305; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
306; OPT-LABEL: simple_loop:
307; OPT-NOT: br
308; OPT: .LBB8_1:
309; OPT: loop    {{$}}
310; OPT: br_if 0, {{[^,]+}}{{$}}
311; OPT-NEXT: end_loop{{$}}
312; OPT: i32.const $push{{[0-9]+}}=, 0{{$}}
313; OPT-NEXT: return $pop{{[0-9]+}}{{$}}
314define i32 @simple_loop(i32* %p, i32 %a) {
315entry:
316  %c = icmp eq i32 %a, 0
317  store volatile i32 0, i32* %p
318  br label %loop
319loop:
320  store volatile i32 1, i32* %p
321  br i1 %c, label %loop, label %exit
322exit:
323  store volatile i32 2, i32* %p
324  ret i32 0
325}
326
327; CHECK-LABEL: doubletriangle:
328; CHECK: block   {{$}}
329; CHECK: br_if 0, $0{{$}}
330; CHECK: block   {{$}}
331; CHECK: br_if 0, $1{{$}}
332; CHECK: .LBB9_3:
333; CHECK: .LBB9_4:
334; CHECK: return
335; OPT-LABEL: doubletriangle:
336; OPT: block   {{$}}
337; OPT: br_if 0, $0{{$}}
338; OPT: block   {{$}}
339; OPT: br_if 0, $1{{$}}
340; OPT: .LBB9_3:
341; OPT: .LBB9_4:
342; OPT: return
343define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) {
344entry:
345  %c = icmp eq i32 %a, 0
346  %d = icmp eq i32 %b, 0
347  store volatile i32 0, i32* %p
348  br i1 %c, label %true, label %exit
349true:
350  store volatile i32 2, i32* %p
351  br i1 %d, label %tt, label %tf
352tt:
353  store volatile i32 3, i32* %p
354  br label %tf
355tf:
356  store volatile i32 4, i32* %p
357  br label %exit
358exit:
359  store volatile i32 5, i32* %p
360  ret i32 0
361}
362
363; CHECK-LABEL: ifelse_earlyexits:
364; CHECK: block   {{$}}
365; CHECK: block   {{$}}
366; CHECK: br_if 0, $0{{$}}
367; CHECK: br 1{{$}}
368; CHECK: .LBB10_2:
369; CHECK: br_if 0, $1{{$}}
370; CHECK: .LBB10_4:
371; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}}
372; CHECK-NEXT: return $pop{{[0-9]+}}{{$}}
373; OPT-LABEL: ifelse_earlyexits:
374; OPT: block   {{$}}
375; OPT: block   {{$}}
376; OPT: br_if 0, {{[^,]+}}{{$}}
377; OPT: br_if 1, $1{{$}}
378; OPT: br 1{{$}}
379; OPT: .LBB10_3:
380; OPT: .LBB10_4:
381; OPT: i32.const $push{{[0-9]+}}=, 0{{$}}
382; OPT-NEXT: return $pop{{[0-9]+}}{{$}}
383define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) {
384entry:
385  %c = icmp eq i32 %a, 0
386  %d = icmp eq i32 %b, 0
387  store volatile i32 0, i32* %p
388  br i1 %c, label %true, label %false
389true:
390  store volatile i32 1, i32* %p
391  br label %exit
392false:
393  store volatile i32 2, i32* %p
394  br i1 %d, label %ft, label %exit
395ft:
396  store volatile i32 3, i32* %p
397  br label %exit
398exit:
399  store volatile i32 4, i32* %p
400  ret i32 0
401}
402
403; CHECK-LABEL: doublediamond_in_a_loop:
404; CHECK: .LBB11_1:
405; CHECK: loop i32{{$}}
406; CHECK: block   {{$}}
407; CHECK: br_if           0, $0{{$}}
408; CHECK: br              1{{$}}
409; CHECK: .LBB11_3:
410; CHECK: end_block{{$}}
411; CHECK: block   {{$}}
412; CHECK: br_if           0, $1{{$}}
413; CHECK: br              1{{$}}
414; CHECK: .LBB11_5:
415; CHECK: br              0{{$}}
416; CHECK: .LBB11_6:
417; CHECK-NEXT: end_loop{{$}}
418; OPT-LABEL: doublediamond_in_a_loop:
419; OPT:      .LBB11_1:
420; OPT:      loop i32{{$}}
421; OPT:      block   {{$}}
422; OPT:      br_if           0, {{[^,]+}}{{$}}
423; OPT:      block   {{$}}
424; OPT:      br_if           0, {{[^,]+}}{{$}}
425; OPT:      br              2{{$}}
426; OPT-NEXT: .LBB11_4:
427; OPT-NEXT: end_block{{$}}
428; OPT:      br              1{{$}}
429; OPT:      .LBB11_5:
430; OPT-NEXT: end_block{{$}}
431; OPT:      br              0{{$}}
432; OPT:      .LBB11_6:
433; OPT-NEXT: end_loop{{$}}
434define i32 @doublediamond_in_a_loop(i32 %a, i32 %b, i32* %p) {
435entry:
436  br label %header
437header:
438  %c = icmp eq i32 %a, 0
439  %d = icmp eq i32 %b, 0
440  store volatile i32 0, i32* %p
441  br i1 %c, label %true, label %false
442true:
443  store volatile i32 1, i32* %p
444  br label %exit
445false:
446  store volatile i32 2, i32* %p
447  br i1 %d, label %ft, label %ff
448ft:
449  store volatile i32 3, i32* %p
450  br label %exit
451ff:
452  store volatile i32 4, i32* %p
453  br label %exit
454exit:
455  store volatile i32 5, i32* %p
456  br label %header
457}
458
459; Test that nested loops are handled.
460
461; CHECK-LABEL: test3:
462; CHECK: loop
463; CHECK-NEXT: br_if
464; CHECK-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
465; CHECK-NEXT: loop
466; OPT-LABEL: test3:
467; OPT: block
468; OPT: br_if
469; OPT: .LBB{{[0-9]+}}_{{[0-9]+}}:
470; OPT-NEXT: loop
471; OPT-NEXT: block
472; OPT-NEXT: block
473; OPT-NEXT: br_if
474; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
475; OPT-NEXT: loop
476; OPT: br_if
477; OPT-NEXT: br
478; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
479; OPT-NEXT: end_loop
480; OPT-NEXT: end_block
481; OPT-NEXT: unreachable
482; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
483; OPT-NEXT: end_block
484; OPT: br
485; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
486; OPT-NEXT: end_loop
487declare void @bar()
488define void @test3(i32 %w)  {
489entry:
490  br i1 undef, label %outer.ph, label %exit
491
492outer.ph:
493  br label %outer
494
495outer:
496  %tobool = icmp eq i32 undef, 0
497  br i1 %tobool, label %inner, label %unreachable
498
499unreachable:
500  unreachable
501
502inner:
503  %c = icmp eq i32 undef, %w
504  br i1 %c, label %if.end, label %inner
505
506exit:
507  ret void
508
509if.end:
510  call void @bar()
511  br label %outer
512}
513
514; Test switch lowering and block placement.
515
516; CHECK-LABEL: test4:
517; CHECK-NEXT: .param       i32{{$}}
518; CHECK:      block   {{$}}
519; CHECK-NEXT: block   {{$}}
520; CHECK:      br_if       0, $pop{{[0-9]+}}{{$}}
521; CHECK:      br_if       1, $pop{{[0-9]+}}{{$}}
522; CHECK:      br          1{{$}}
523; CHECK-NEXT: .LBB13_3:
524; CHECK-NEXT: end_block{{$}}
525; CHECK-NEXT: block   {{$}}
526; CHECK:      br_if 0, $pop{{[0-9]+}}{{$}}
527; CHECK:      br_if 1, $pop{{[0-9]+}}{{$}}
528; CHECK-NEXT: .LBB13_5:
529; CHECK-NEXT: end_block{{$}}
530; CHECK-NEXT: return{{$}}
531; CHECK-NEXT: .LBB13_6:
532; CHECK-NEXT: end_block{{$}}
533; CHECK-NEXT: return{{$}}
534; OPT-LABEL: test4:
535; OPT-NEXT: .param       i32{{$}}
536; OPT:      block   {{$}}
537; OPT-NEXT: block   {{$}}
538; OPT:      br_if       0, $pop{{[0-9]+}}{{$}}
539; OPT:      br_if       1, $pop{{[0-9]+}}{{$}}
540; OPT:      br          1{{$}}
541; OPT-NEXT: .LBB13_3:
542; OPT-NEXT: end_block{{$}}
543; OPT-NEXT: block   {{$}}
544; OPT:      br_if       0, $pop{{[0-9]+}}{{$}}
545; OPT:      br_if       1, $pop{{[0-9]+}}{{$}}
546; OPT-NEXT: .LBB13_5:
547; OPT-NEXT: end_block{{$}}
548; OPT-NEXT: return{{$}}
549; OPT-NEXT: .LBB13_6:
550; OPT-NEXT: end_block{{$}}
551; OPT-NEXT: return{{$}}
552define void @test4(i32 %t) {
553entry:
554  switch i32 %t, label %default [
555    i32 0, label %bb2
556    i32 2, label %bb2
557    i32 4, label %bb1
558    i32 622, label %bb0
559  ]
560
561bb0:
562  ret void
563
564bb1:
565  ret void
566
567bb2:
568  ret void
569
570default:
571  ret void
572}
573
574; Test a case where the BLOCK needs to be placed before the LOOP in the
575; same basic block.
576
577; CHECK-LABEL: test5:
578; CHECK:       .LBB14_1:
579; CHECK-NEXT:  block   {{$}}
580; CHECK-NEXT:  loop    {{$}}
581; CHECK:       br_if 1, {{[^,]+}}{{$}}
582; CHECK:       br_if 0, {{[^,]+}}{{$}}
583; CHECK-NEXT:  end_loop{{$}}
584; CHECK:       return{{$}}
585; CHECK-NEXT:  .LBB14_4:
586; CHECK:       return{{$}}
587; OPT-LABEL: test5:
588; OPT:       .LBB14_1:
589; OPT-NEXT:  block   {{$}}
590; OPT-NEXT:  loop    {{$}}
591; OPT:       br_if 1, {{[^,]+}}{{$}}
592; OPT:       br_if 0, {{[^,]+}}{{$}}
593; OPT-NEXT:  end_loop{{$}}
594; OPT:       return{{$}}
595; OPT-NEXT:  .LBB14_4:
596; OPT:       return{{$}}
597define void @test5(i1 %p, i1 %q) {
598entry:
599  br label %header
600
601header:
602  store volatile i32 0, i32* null
603  br i1 %p, label %more, label %alt
604
605more:
606  store volatile i32 1, i32* null
607  br i1 %q, label %header, label %return
608
609alt:
610  store volatile i32 2, i32* null
611  ret void
612
613return:
614  store volatile i32 3, i32* null
615  ret void
616}
617
618; Test an interesting case of a loop with multiple exits, which
619; aren't to layout successors of the loop, and one of which is to a successors
620; which has another predecessor.
621
622; CHECK-LABEL: test6:
623; CHECK:       .LBB15_1:
624; CHECK-NEXT:  block   {{$}}
625; CHECK-NEXT:  block   {{$}}
626; CHECK-NEXT:  loop    {{$}}
627; CHECK-NOT:   block
628; CHECK:       br_if 2, {{[^,]+}}{{$}}
629; CHECK-NOT:   block
630; CHECK:       br_if 1, {{[^,]+}}{{$}}
631; CHECK-NOT:   block
632; CHECK:       br_if 0, {{[^,]+}}{{$}}
633; CHECK-NEXT:  end_loop{{$}}
634; CHECK-NOT:   block
635; CHECK:       return{{$}}
636; CHECK-NEXT:  .LBB15_5:
637; CHECK-NEXT:  end_block{{$}}
638; CHECK-NOT:   block
639; CHECK:       .LBB15_6:
640; CHECK-NEXT:  end_block{{$}}
641; CHECK-NOT:   block
642; CHECK:       return{{$}}
643; OPT-LABEL: test6:
644; OPT:       .LBB15_1:
645; OPT-NEXT:  block   {{$}}
646; OPT-NEXT:  block   {{$}}
647; OPT-NEXT:  loop    {{$}}
648; OPT-NOT:   block
649; OPT:       br_if 2, {{[^,]+}}{{$}}
650; OPT-NOT:   block
651; OPT:       br_if 1, {{[^,]+}}{{$}}
652; OPT-NOT:   block
653; OPT:       br_if 0, {{[^,]+}}{{$}}
654; OPT-NEXT:  end_loop{{$}}
655; OPT-NOT:   block
656; OPT:       return{{$}}
657; OPT-NEXT:  .LBB15_5:
658; OPT-NEXT:  end_block{{$}}
659; OPT-NOT:   block
660; OPT:       .LBB15_6:
661; OPT-NEXT:  end_block{{$}}
662; OPT-NOT:   block
663; OPT:       return{{$}}
664define void @test6(i1 %p, i1 %q) {
665entry:
666  br label %header
667
668header:
669  store volatile i32 0, i32* null
670  br i1 %p, label %more, label %second
671
672more:
673  store volatile i32 1, i32* null
674  br i1 %q, label %evenmore, label %first
675
676evenmore:
677  store volatile i32 1, i32* null
678  br i1 %q, label %header, label %return
679
680return:
681  store volatile i32 2, i32* null
682  ret void
683
684first:
685  store volatile i32 3, i32* null
686  br label %second
687
688second:
689  store volatile i32 4, i32* null
690  ret void
691}
692
693; Test a case where there are multiple backedges and multiple loop exits
694; that end in unreachable.
695
696; CHECK-LABEL: test7:
697; CHECK:       .LBB16_1:
698; CHECK-NEXT:  loop    {{$}}
699; CHECK-NOT:   block
700; CHECK:       block   {{$}}
701; CHECK:       br_if 0, {{[^,]+}}{{$}}
702; CHECK-NOT:   block
703; CHECK:       br_if 1, {{[^,]+}}{{$}}
704; CHECK-NOT:   block
705; CHECK:       unreachable
706; CHECK-NEXT:  .LBB16_4:
707; CHECK-NEXT:  end_block{{$}}
708; CHECK-NOT:   block
709; CHECK:       br_if 0, {{[^,]+}}{{$}}
710; CHECK-NEXT:  end_loop{{$}}
711; CHECK-NOT:   block
712; CHECK:       unreachable
713; OPT-LABEL: test7:
714; OPT:       .LBB16_1:
715; OPT-NEXT:  block
716; OPT-NEXT:  loop    {{$}}
717; OPT-NOT:   block
718; OPT:       block   {{$}}
719; OPT-NOT:   block
720; OPT:       br_if 0, {{[^,]+}}{{$}}
721; OPT-NOT:   block
722; OPT:       br_if 1, {{[^,]+}}{{$}}
723; OPT:       br 2{{$}}
724; OPT-NEXT:  .LBB16_3:
725; OPT-NEXT:  end_block
726; OPT-NOT:   block
727; OPT:       br_if 0, {{[^,]+}}{{$}}
728; OPT-NEXT:  end_loop
729; OPT-NOT:   block
730; OPT:       unreachable
731; OPT-NEXT:  .LBB16_5:
732; OPT-NEXT:  end_block
733; OPT-NOT:   block
734; OPT:       unreachable
735define void @test7(i1 %tobool2, i1 %tobool9) {
736entry:
737  store volatile i32 0, i32* null
738  br label %loop
739
740loop:
741  store volatile i32 1, i32* null
742  br i1 %tobool2, label %l1, label %l0
743
744l0:
745  store volatile i32 2, i32* null
746  br i1 %tobool9, label %loop, label %u0
747
748l1:
749  store volatile i32 3, i32* null
750  br i1 %tobool9, label %loop, label %u1
751
752u0:
753  store volatile i32 4, i32* null
754  unreachable
755
756u1:
757  store volatile i32 5, i32* null
758  unreachable
759}
760
761; Test an interesting case using nested loops and switches.
762
763; CHECK-LABEL: test8:
764; CHECK:       .LBB17_1:
765; CHECK-NEXT:  loop i32{{$}}
766; CHECK-NEXT:  i32.const $push{{[^,]+}}, 0{{$}}
767; CHECK-NEXT:  br_if    0, {{[^,]+}}{{$}}
768; CHECK-NEXT:  br       0{{$}}
769; CHECK-NEXT:  .LBB17_2:
770; CHECK-NEXT:  end_loop{{$}}
771; OPT-LABEL: test8:
772; OPT:       .LBB17_1:
773; OPT-NEXT:  loop i32{{$}}
774; OPT-NEXT:  i32.const $push{{[^,]+}}, 0{{$}}
775; OPT-NEXT:  br_if    0, {{[^,]+}}{{$}}
776; OPT-NEXT:  br       0{{$}}
777; OPT-NEXT:  .LBB17_2:
778; OPT-NEXT:  end_loop{{$}}
779define i32 @test8() {
780bb:
781  br label %bb1
782
783bb1:
784  br i1 undef, label %bb2, label %bb3
785
786bb2:
787  switch i8 undef, label %bb1 [
788    i8 44, label %bb2
789  ]
790
791bb3:
792  switch i8 undef, label %bb1 [
793    i8 44, label %bb2
794  ]
795}
796
797; Test an interesting case using nested loops that share a bottom block.
798
799; CHECK-LABEL: test9:
800; CHECK:       .LBB18_1:
801; CHECK-NEXT:  block   {{$}}
802; CHECK-NEXT:  loop    {{$}}
803; CHECK-NOT:   block
804; CHECK:       br_if     1, {{[^,]+}}{{$}}
805; CHECK-NEXT:  .LBB18_2:
806; CHECK-NEXT:  loop    {{$}}
807; CHECK-NOT:   block
808; CHECK:       block   {{$}}
809; CHECK-NOT:   block
810; CHECK:       br_if     0, {{[^,]+}}{{$}}
811; CHECK-NOT:   block
812; CHECK:       br_if     2, {{[^,]+}}{{$}}
813; CHECK-NEXT:  br        1{{$}}
814; CHECK-NEXT:  .LBB18_4:
815; CHECK-NEXT:  end_block{{$}}
816; CHECK-NOT:   block
817; CHECK:       br_if     1, {{[^,]+}}{{$}}
818; CHECK-NEXT:  br        0{{$}}
819; CHECK-NEXT:  .LBB18_5:
820; CHECK-NOT:   block
821; CHECK:       end_block
822; CHECK-NOT:   block
823; CHECK:       return{{$}}
824; OPT-LABEL: test9:
825; OPT:       .LBB18_1:
826; OPT-NEXT:  block   {{$}}
827; OPT-NEXT:  loop    {{$}}
828; OPT-NOT:   block
829; OPT:       br_if     1, {{[^,]+}}{{$}}
830; OPT-NEXT:  .LBB18_2:
831; OPT-NEXT:  loop    {{$}}
832; OPT-NOT:   block
833; OPT:       block   {{$}}
834; OPT-NOT:   block
835; OPT:       br_if     0, {{[^,]+}}{{$}}
836; OPT-NOT:   block
837; OPT:       br_if     1, {{[^,]+}}{{$}}
838; OPT-NEXT:  br        2{{$}}
839; OPT-NEXT:  .LBB18_4:
840; OPT-NEXT:  end_block{{$}}
841; OPT-NOT:   block
842; OPT:       br_if     0, {{[^,]+}}{{$}}
843; OPT-NEXT:  br        1{{$}}
844; OPT-NEXT:  .LBB18_5:
845; OPT-NOT:   block
846; OPT:       end_block
847; OPT-NOT:   block
848; OPT:       return{{$}}
849declare i1 @a()
850define void @test9() {
851entry:
852  store volatile i32 0, i32* null
853  br label %header
854
855header:
856  store volatile i32 1, i32* null
857  %call4 = call i1 @a()
858  br i1 %call4, label %header2, label %end
859
860header2:
861  store volatile i32 2, i32* null
862  %call = call i1 @a()
863  br i1 %call, label %if.then, label %if.else
864
865if.then:
866  store volatile i32 3, i32* null
867  %call3 = call i1 @a()
868  br i1 %call3, label %header2, label %header
869
870if.else:
871  store volatile i32 4, i32* null
872  %call2 = call i1 @a()
873  br i1 %call2, label %header2, label %header
874
875end:
876  store volatile i32 5, i32* null
877  ret void
878}
879
880; Test an interesting case involving nested loops sharing a loop bottom,
881; and loop exits to a block with unreachable.
882
883; CHECK-LABEL: test10:
884; CHECK:       .LBB19_1:
885; CHECK-NEXT:  loop    {{$}}
886; CHECK-NOT:   block
887; CHECK:       br_if    0, {{[^,]+}}{{$}}
888; CHECK:       .LBB19_3:
889; CHECK-NEXT:  block   {{$}}
890; CHECK-NEXT:  loop    {{$}}
891; CHECK-NOT:   block
892; CHECK:       .LBB19_4:
893; CHECK-NEXT:  loop    {{$}}
894; CHECK-NOT:   block
895; CHECK:       br_if    0, {{[^,]+}}{{$}}
896; CHECK-NEXT:  end_loop{{$}}
897; CHECK:       br_if    1, {{[^,]+}}{{$}}
898; CHECK-NOT:   block
899; CHECK:       br_if    0, {{[^,]+}}{{$}}
900; CHECK-NEXT:  end_loop{{$}}
901; CHECK-NOT:   block
902; CHECK:       br_if    1, {{[^,]+}}{{$}}
903; CHECK-NEXT:  return{{$}}
904; CHECK-NEXT:  .LBB19_9:
905; CHECK-NEXT:  end_block{{$}}
906; CHECK-NOT:   block
907; CHECK:       br       0{{$}}
908; CHECK-NEXT:  .LBB19_10:
909; OPT-LABEL: test10:
910; OPT:       .LBB19_1:
911; OPT-NEXT:  loop    {{$}}
912; OPT-NOT:   block
913; OPT:       br_if    0, {{[^,]+}}{{$}}
914; OPT:       .LBB19_3:
915; OPT-NEXT:  block   {{$}}
916; OPT-NEXT:  loop    {{$}}
917; OPT-NOT:   block
918; OPT:       .LBB19_4:
919; OPT-NEXT:  loop    {{$}}
920; OPT-NOT:   block
921; OPT:       br_if    0, {{[^,]+}}{{$}}
922; OPT-NEXT:  end_loop{{$}}
923; OPT:       br_if    1, {{[^,]+}}{{$}}
924; OPT-NOT:   block
925; OPT:       br_if    0, {{[^,]+}}{{$}}
926; OPT-NEXT:  end_loop{{$}}
927; OPT-NOT:   block
928; OPT:       br_if    1, {{[^,]+}}{{$}}
929; OPT-NEXT:  return{{$}}
930; OPT-NEXT:  .LBB19_9:
931; OPT-NEXT:  end_block{{$}}
932; OPT-NOT:   block
933; OPT:       br       0{{$}}
934; OPT-NEXT:  .LBB19_10:
935define void @test10() {
936bb0:
937  br label %bb1
938
939bb1:
940  %tmp = phi i32 [ 2, %bb0 ], [ 3, %bb3 ]
941  %tmp3 = phi i32 [ undef, %bb0 ], [ %tmp11, %bb3 ]
942  %tmp4 = icmp eq i32 %tmp3, 0
943  br i1 %tmp4, label %bb4, label %bb2
944
945bb2:
946  br label %bb3
947
948bb3:
949  %tmp11 = phi i32 [ 1, %bb5 ], [ 0, %bb2 ]
950  br label %bb1
951
952bb4:
953  %tmp6 = phi i32 [ %tmp9, %bb5 ], [ 4, %bb1 ]
954  %tmp7 = phi i32 [ %tmp6, %bb5 ], [ %tmp, %bb1 ]
955  br label %bb5
956
957bb5:
958  %tmp9 = phi i32 [ %tmp6, %bb5 ], [ %tmp7, %bb4 ]
959  switch i32 %tmp9, label %bb2 [
960    i32 0, label %bb5
961    i32 1, label %bb6
962    i32 3, label %bb4
963    i32 4, label %bb3
964  ]
965
966bb6:
967  ret void
968}
969
970; Test a CFG DAG with interesting merging.
971
972; CHECK-LABEL: test11:
973; CHECK:       block   {{$}}
974; CHECK-NEXT:  block   {{$}}
975; CHECK-NEXT:  block   {{$}}
976; CHECK-NEXT:  block   {{$}}
977; CHECK:       br_if        0, {{[^,]+}}{{$}}
978; CHECK-NOT:   block
979; CHECK:       block   {{$}}
980; CHECK-NEXT:  i32.const
981; CHECK-NEXT:  br_if        0, {{[^,]+}}{{$}}
982; CHECK-NOT:   block
983; CHECK:       br_if        2, {{[^,]+}}{{$}}
984; CHECK-NEXT:  .LBB20_3:
985; CHECK-NEXT:  end_block{{$}}
986; CHECK-NOT:   block
987; CHECK:       return{{$}}
988; CHECK-NEXT:  .LBB20_4:
989; CHECK-NEXT:  end_block{{$}}
990; CHECK-NOT:   block
991; CHECK:       br_if        1, {{[^,]+}}{{$}}
992; CHECK-NOT:   block
993; CHECK:       br_if        2, {{[^,]+}}{{$}}
994; CHECK-NEXT:  .LBB20_6:
995; CHECK-NEXT:  end_block{{$}}
996; CHECK-NOT:   block
997; CHECK:       return{{$}}
998; CHECK-NEXT:  .LBB20_7:
999; CHECK-NEXT:  end_block{{$}}
1000; CHECK-NOT:   block
1001; CHECK:       return{{$}}
1002; CHECK-NEXT:  .LBB20_8:
1003; CHECK-NEXT:  end_block{{$}}
1004; CHECK-NOT:   block
1005; CHECK:       return{{$}}
1006; OPT-LABEL: test11:
1007; OPT:       block   {{$}}
1008; OPT-NEXT:  block   {{$}}
1009; OPT:       br_if        0, $pop{{[0-9]+}}{{$}}
1010; OPT-NOT:   block
1011; OPT:       block   {{$}}
1012; OPT-NEXT:  i32.const
1013; OPT-NEXT:  br_if        0, {{[^,]+}}{{$}}
1014; OPT-NOT:   block
1015; OPT:       br_if        2, {{[^,]+}}{{$}}
1016; OPT-NEXT:  .LBB20_3:
1017; OPT-NEXT:  end_block{{$}}
1018; OPT-NOT:   block
1019; OPT:       return{{$}}
1020; OPT-NEXT:  .LBB20_4:
1021; OPT-NEXT:  end_block{{$}}
1022; OPT-NOT:   block
1023; OPT:       block   {{$}}
1024; OPT-NOT:   block
1025; OPT:       br_if        0, $pop{{[0-9]+}}{{$}}
1026; OPT-NOT:   block
1027; OPT:       return{{$}}
1028; OPT-NEXT:  .LBB20_6:
1029; OPT-NEXT:  end_block{{$}}
1030; OPT-NOT:   block
1031; OPT:       br_if        0, $pop{{[0-9]+}}{{$}}
1032; OPT-NOT:   block
1033; OPT:       return{{$}}
1034; OPT-NEXT:  .LBB20_8:
1035; OPT-NEXT:  end_block{{$}}
1036; OPT-NOT:   block
1037; OPT:       return{{$}}
1038define void @test11() {
1039bb0:
1040  store volatile i32 0, i32* null
1041  br i1 undef, label %bb1, label %bb4
1042bb1:
1043  store volatile i32 1, i32* null
1044  br i1 undef, label %bb3, label %bb2
1045bb2:
1046  store volatile i32 2, i32* null
1047  br i1 undef, label %bb3, label %bb7
1048bb3:
1049  store volatile i32 3, i32* null
1050  ret void
1051bb4:
1052  store volatile i32 4, i32* null
1053  br i1 undef, label %bb8, label %bb5
1054bb5:
1055  store volatile i32 5, i32* null
1056  br i1 undef, label %bb6, label %bb7
1057bb6:
1058  store volatile i32 6, i32* null
1059  ret void
1060bb7:
1061  store volatile i32 7, i32* null
1062  ret void
1063bb8:
1064  store volatile i32 8, i32* null
1065  ret void
1066}
1067
1068; CHECK-LABEL: test12:
1069; CHECK:       .LBB21_1:
1070; CHECK-NEXT:  block   {{$}}
1071; CHECK-NEXT:  loop    {{$}}
1072; CHECK-NOT:   block
1073; CHECK:       block   {{$}}
1074; CHECK-NEXT:  block   {{$}}
1075; CHECK:       br_if       0, {{[^,]+}}{{$}}
1076; CHECK-NOT:   block
1077; CHECK:       br_if       1, {{[^,]+}}{{$}}
1078; CHECK-NOT:   block
1079; CHECK:       br_if       1, {{[^,]+}}{{$}}
1080; CHECK-NEXT:  br          3{{$}}
1081; CHECK-NEXT:  .LBB21_4:
1082; CHECK-NEXT:  end_block{{$}}
1083; CHECK-NOT:   block
1084; CHECK:       br_if       0, {{[^,]+}}{{$}}
1085; CHECK-NOT:   block
1086; CHECK:       br_if       2, {{[^,]+}}{{$}}
1087; CHECK-NEXT:  .LBB21_6:
1088; CHECK-NEXT:  end_block{{$}}
1089; CHECK-NOT:   block
1090; CHECK:       br          0{{$}}
1091; CHECK-NEXT:  .LBB21_7:
1092; CHECK-NEXT:  end_loop{{$}}
1093; CHECK-NEXT:  end_block{{$}}
1094; CHECK-NEXT:  return{{$}}
1095; OPT-LABEL: test12:
1096; OPT:       .LBB21_1:
1097; OPT-NEXT:  block   {{$}}
1098; OPT-NEXT:  loop    {{$}}
1099; OPT-NOT:   block
1100; OPT:       block   {{$}}
1101; OPT-NEXT:  block   {{$}}
1102; OPT:       br_if       0, {{[^,]+}}{{$}}
1103; OPT-NOT:   block
1104; OPT:       br_if       1, {{[^,]+}}{{$}}
1105; OPT-NOT:   block
1106; OPT:       br_if       1, {{[^,]+}}{{$}}
1107; OPT-NEXT:  br          3{{$}}
1108; OPT-NEXT:  .LBB21_4:
1109; OPT-NEXT:  end_block{{$}}
1110; OPT-NOT:   block
1111; OPT:       br_if       0, {{[^,]+}}{{$}}
1112; OPT-NOT:   block
1113; OPT:       br_if       2, {{[^,]+}}{{$}}
1114; OPT-NEXT:  .LBB21_6:
1115; OPT-NEXT:  end_block{{$}}
1116; OPT:       br          0{{$}}
1117; OPT-NEXT:  .LBB21_7:
1118; OPT-NEXT:  end_loop{{$}}
1119; OPT-NEXT:  end_block{{$}}
1120; OPT-NEXT:  return{{$}}
1121define void @test12(i8* %arg) {
1122bb:
1123  br label %bb1
1124
1125bb1:
1126  %tmp = phi i32 [ 0, %bb ], [ %tmp5, %bb4 ]
1127  %tmp2 = getelementptr i8, i8* %arg, i32 %tmp
1128  %tmp3 = load i8, i8* %tmp2
1129  switch i8 %tmp3, label %bb7 [
1130    i8 42, label %bb4
1131    i8 76, label %bb4
1132    i8 108, label %bb4
1133    i8 104, label %bb4
1134  ]
1135
1136bb4:
1137  %tmp5 = add i32 %tmp, 1
1138  br label %bb1
1139
1140bb7:
1141  ret void
1142}
1143
1144; A block can be "branched to" from another even if it is also reachable via
1145; fallthrough from the other. This would normally be optimized away, so use
1146; optnone to disable optimizations to test this case.
1147
1148; CHECK-LABEL: test13:
1149; CHECK-NEXT:  block   {{$}}
1150; CHECK-NEXT:  block   {{$}}
1151; CHECK:       br_if 0, $pop0{{$}}
1152; CHECK:       block   {{$}}
1153; CHECK:       br_if 0, $pop3{{$}}
1154; CHECK:       .LBB22_3:
1155; CHECK-NEXT:  end_block{{$}}
1156; CHECK:       br_if 1, $pop{{[0-9]+}}{{$}}
1157; CHECK-NEXT:  br 1{{$}}
1158; CHECK-NEXT:  .LBB22_4:
1159; CHECK-NEXT:  end_block{{$}}
1160; CHECK-NEXT:  return{{$}}
1161; CHECK-NEXT:  .LBB22_5:
1162; CHECK-NEXT:  end_block{{$}}
1163; CHECK-NEXT:  unreachable{{$}}
1164; OPT-LABEL: test13:
1165; OPT-NEXT:  block   {{$}}
1166; OPT-NEXT:  block   {{$}}
1167; OPT:       br_if 0, $pop0{{$}}
1168; OPT:       block   {{$}}
1169; OPT:       br_if 0, $pop3{{$}}
1170; OPT:       .LBB22_3:
1171; OPT-NEXT:  end_block{{$}}
1172; OPT:       br_if 1, $pop{{[0-9]+}}{{$}}
1173; OPT-NEXT:  br 1{{$}}
1174; OPT-NEXT:  .LBB22_4:
1175; OPT-NEXT:  end_block
1176; OPT-NEXT:  return
1177; OPT-NEXT:  .LBB22_5:
1178; OPT-NEXT:  end_block{{$}}
1179; OPT-NEXT:  unreachable{{$}}
1180define void @test13() noinline optnone {
1181bb:
1182  br i1 undef, label %bb5, label %bb2
1183bb1:
1184  unreachable
1185bb2:
1186  br i1 undef, label %bb3, label %bb4
1187bb3:
1188  br label %bb4
1189bb4:
1190  %tmp = phi i1 [ false, %bb2 ], [ false, %bb3 ]
1191  br i1 %tmp, label %bb1, label %bb1
1192bb5:
1193  ret void
1194}
1195
1196; Test a case with a single-block loop that has another loop
1197; as a successor. The end_loop for the first loop should go
1198; before the loop for the second.
1199
1200; CHECK-LABEL: test14:
1201; CHECK-NEXT: .LBB23_1:{{$}}
1202; CHECK-NEXT:     loop    {{$}}
1203; CHECK-NEXT:     i32.const   $push0=, 0{{$}}
1204; CHECK-NEXT:     br_if       0, $pop0{{$}}
1205; CHECK-NEXT:     end_loop{{$}}
1206; CHECK-NEXT: .LBB23_3:{{$}}
1207; CHECK-NEXT:     loop    {{$}}
1208; CHECK-NEXT:     i32.const   $push1=, 0{{$}}
1209; CHECK-NEXT:     br_if       0, $pop1{{$}}
1210; CHECK-NEXT:     end_loop{{$}}
1211; CHECK-NEXT:     return{{$}}
1212define void @test14() {
1213bb:
1214  br label %bb1
1215
1216bb1:
1217  %tmp = bitcast i1 undef to i1
1218  br i1 %tmp, label %bb3, label %bb1
1219
1220bb3:
1221  br label %bb4
1222
1223bb4:
1224  br i1 undef, label %bb7, label %bb48
1225
1226bb7:
1227  br i1 undef, label %bb12, label %bb12
1228
1229bb12:
1230  br i1 undef, label %bb17, label %bb17
1231
1232bb17:
1233  br i1 undef, label %bb22, label %bb22
1234
1235bb22:
1236  br i1 undef, label %bb27, label %bb27
1237
1238bb27:
1239  br i1 undef, label %bb30, label %bb30
1240
1241bb30:
1242  br i1 undef, label %bb35, label %bb35
1243
1244bb35:
1245  br i1 undef, label %bb38, label %bb38
1246
1247bb38:
1248  br i1 undef, label %bb48, label %bb48
1249
1250bb48:
1251  %tmp49 = bitcast i1 undef to i1
1252  br i1 %tmp49, label %bb3, label %bb50
1253
1254bb50:
1255  ret void
1256}
1257
1258; Test that a block boundary which ends one block, begins another block, and
1259; also begins a loop, has the markers placed in the correct order.
1260
1261; CHECK-LABEL: test15:
1262; CHECK:        block
1263; CHECK-NEXT:   block
1264; CHECK:        br_if       0, $pop{{.*}}{{$}}
1265; CHECK:        .LBB24_2:
1266; CHECK-NEXT:   block   {{$}}
1267; CHECK-NEXT:   block   {{$}}
1268; CHECK-NEXT:   loop    {{$}}
1269; CHECK:        br_if       1, $pop{{.*}}{{$}}
1270; CHECK:        br_if       0, ${{.*}}{{$}}
1271; CHECK-NEXT:   br          2{{$}}
1272; CHECK-NEXT:   .LBB24_4:
1273; CHECK-NEXT:   end_loop{{$}}
1274; CHECK:        .LBB24_5:
1275; CHECK-NEXT:   end_block{{$}}
1276; CHECK:        br_if       1, $pop{{.*}}{{$}}
1277; CHECK:        return{{$}}
1278; CHECK:        .LBB24_7:
1279; CHECK-NEXT:   end_block{{$}}
1280; CHECK:        .LBB24_8:
1281; CHECK-NEXT:   end_block{{$}}
1282; CHECK-NEXT:   return{{$}}
1283; OPT-LABEL: test15:
1284; OPT:        block
1285; OPT:        block
1286; OPT-NEXT:   i32.const   $push
1287; OPT-NEXT:   i32.eqz     $push{{.*}}=, $pop{{.*}}{{$}}
1288; OPT-NEXT:   br_if       0, $pop{{.*}}{{$}}
1289; OPT-NEXT:   call        test15_callee1@FUNCTION{{$}}
1290; OPT-NEXT:   br          1{{$}}
1291; OPT-NEXT: .LBB24_2:
1292; OPT-NEXT:   end_block
1293; OPT-NEXT:   i32.const
1294; OPT-NEXT: .LBB24_3:
1295; OPT-NEXT:   block
1296; OPT-NEXT:   block
1297; OPT-NEXT:   loop
1298%0 = type { i8, i32 }
1299declare void @test15_callee0()
1300declare void @test15_callee1()
1301define void @test15() {
1302bb:
1303  %tmp1 = icmp eq i8 1, 0
1304  br i1 %tmp1, label %bb2, label %bb14
1305
1306bb2:
1307  %tmp3 = phi %0** [ %tmp6, %bb5 ], [ null, %bb ]
1308  %tmp4 = icmp eq i32 0, 11
1309  br i1 %tmp4, label %bb5, label %bb8
1310
1311bb5:
1312  %tmp = bitcast i8* null to %0**
1313  %tmp6 = getelementptr %0*, %0** %tmp3, i32 1
1314  %tmp7 = icmp eq %0** %tmp6, null
1315  br i1 %tmp7, label %bb10, label %bb2
1316
1317bb8:
1318  %tmp9 = icmp eq %0** null, undef
1319  br label %bb10
1320
1321bb10:
1322  %tmp11 = phi %0** [ null, %bb8 ], [ %tmp, %bb5 ]
1323  %tmp12 = icmp eq %0** null, %tmp11
1324  br i1 %tmp12, label %bb15, label %bb13
1325
1326bb13:
1327  call void @test15_callee0()
1328  ret void
1329
1330bb14:
1331  call void @test15_callee1()
1332  ret void
1333
1334bb15:
1335  ret void
1336}
1337