blob: f0e5f4471678577f4efc8fc3422cf9f51e9a62da [file] [log] [blame]
Dan Gohman8fe7e862015-12-14 22:51:54 +00001; RUN: llc < %s -asm-verbose=false -disable-block-placement -verify-machineinstrs | FileCheck %s
2; RUN: llc < %s -asm-verbose=false -verify-machineinstrs | FileCheck -check-prefix=OPT %s
Dan Gohman950a13c2015-09-16 16:51:30 +00003
4; Test the CFG stackifier pass.
5
Dan Gohman0c6f5ac2016-01-07 03:19:23 +00006target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
Dan Gohman950a13c2015-09-16 16:51:30 +00007target triple = "wasm32-unknown-unknown"
8
9declare void @something()
10
11; Test that loops are made contiguous, even in the presence of split backedges.
12
Dan Gohmane51c0582015-10-06 00:27:55 +000013; CHECK-LABEL: test0:
14; CHECK: loop
Dan Gohmanf0b165a2015-12-05 03:03:35 +000015; CHECK-NOT: br
Dan Gohman8fe7e862015-12-14 22:51:54 +000016; CHECK: i32.add
17; CHECK-NEXT: i32.ge_s
18; CHECK-NEXT: br_if
Dan Gohmanf0b165a2015-12-05 03:03:35 +000019; CHECK-NOT: br
Dan Gohmane51c0582015-10-06 00:27:55 +000020; CHECK: call
Dan Gohman1d68e80f2016-01-12 19:14:46 +000021; CHECK: br 0{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000022; CHECK: return{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +000023; OPT-LABEL: test0:
24; OPT: loop
Dan Gohmanf0b165a2015-12-05 03:03:35 +000025; OPT-NOT: br
Dan Gohman8fe7e862015-12-14 22:51:54 +000026; OPT: i32.add
27; OPT-NEXT: i32.ge_s
28; OPT-NEXT: br_if
Dan Gohmanf0b165a2015-12-05 03:03:35 +000029; OPT-NOT: br
30; OPT: call
Dan Gohman1d68e80f2016-01-12 19:14:46 +000031; OPT: br 0{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +000032; OPT: return{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +000033define void @test0(i32 %n) {
34entry:
35 br label %header
36
37header:
38 %i = phi i32 [ 0, %entry ], [ %i.next, %back ]
39 %i.next = add i32 %i, 1
40
41 %c = icmp slt i32 %i.next, %n
42 br i1 %c, label %back, label %exit
43
44exit:
45 ret void
46
47back:
48 call void @something()
49 br label %header
50}
51
52; Same as test0, but the branch condition is reversed.
53
Dan Gohmane51c0582015-10-06 00:27:55 +000054; CHECK-LABEL: test1:
55; CHECK: loop
Dan Gohmanf0b165a2015-12-05 03:03:35 +000056; CHECK-NOT: br
Dan Gohman8fe7e862015-12-14 22:51:54 +000057; CHECK: i32.add
58; CHECK-NEXT: i32.ge_s
59; CHECK-NEXT: br_if
Dan Gohmanf0b165a2015-12-05 03:03:35 +000060; CHECK-NOT: br
Dan Gohmane51c0582015-10-06 00:27:55 +000061; CHECK: call
Dan Gohman1d68e80f2016-01-12 19:14:46 +000062; CHECK: br 0{{$}}
Dan Gohmane51c0582015-10-06 00:27:55 +000063; CHECK: return{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +000064; OPT-LABEL: test1:
65; OPT: loop
Dan Gohmanf0b165a2015-12-05 03:03:35 +000066; OPT-NOT: br
Dan Gohman8fe7e862015-12-14 22:51:54 +000067; OPT: i32.add
68; OPT-NEXT: i32.ge_s
69; OPT-NEXT: br_if
Dan Gohmanf0b165a2015-12-05 03:03:35 +000070; OPT-NOT: br
71; OPT: call
Dan Gohman1d68e80f2016-01-12 19:14:46 +000072; OPT: br 0{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +000073; OPT: return{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +000074define void @test1(i32 %n) {
75entry:
76 br label %header
77
78header:
79 %i = phi i32 [ 0, %entry ], [ %i.next, %back ]
80 %i.next = add i32 %i, 1
81
82 %c = icmp sge i32 %i.next, %n
83 br i1 %c, label %exit, label %back
84
85exit:
86 ret void
87
88back:
89 call void @something()
90 br label %header
91}
92
93; Test that a simple loop is handled as expected.
94
Dan Gohmane51c0582015-10-06 00:27:55 +000095; CHECK-LABEL: test2:
Dan Gohman8f59cf72016-01-06 18:29:35 +000096; CHECK-NOT: local
Dan Gohman1d68e80f2016-01-12 19:14:46 +000097; CHECK: block{{$}}
98; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +000099; CHECK: .LBB2_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000100; CHECK: br_if ${{[0-9]+}}, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000101; CHECK: .LBB2_2:
Dan Gohmane51c0582015-10-06 00:27:55 +0000102; CHECK: return{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000103; OPT-LABEL: test2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000104; OPT-NOT: local
105; OPT: block{{$}}
106; OPT: br_if {{[^,]*}}, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000107; OPT: .LBB2_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000108; OPT: br_if ${{[0-9]+}}, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000109; OPT: .LBB2_2:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000110; OPT: return{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000111define void @test2(double* nocapture %p, i32 %n) {
112entry:
113 %cmp.4 = icmp sgt i32 %n, 0
114 br i1 %cmp.4, label %for.body.preheader, label %for.end
115
116for.body.preheader:
117 br label %for.body
118
119for.body:
120 %i.05 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
121 %arrayidx = getelementptr inbounds double, double* %p, i32 %i.05
122 %0 = load double, double* %arrayidx, align 8
123 %mul = fmul double %0, 3.200000e+00
124 store double %mul, double* %arrayidx, align 8
125 %inc = add nuw nsw i32 %i.05, 1
126 %exitcond = icmp eq i32 %inc, %n
127 br i1 %exitcond, label %for.end.loopexit, label %for.body
128
129for.end.loopexit:
130 br label %for.end
131
132for.end:
133 ret void
134}
135
Dan Gohmane51c0582015-10-06 00:27:55 +0000136; CHECK-LABEL: doublediamond:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000137; CHECK: block{{$}}
138; CHECK-NEXT: block{{$}}
139; CHECK: br_if ${{[^,]*}}, 0{{$}}
140; CHECK: br 1{{$}}
141; CHECK: .LBB3_2:
142; CHECK-NEXT: end_block{{$}}
143; CHECK: block{{$}}
144; CHECK: br_if ${{[^,]*}}, 0{{$}}
145; CHECK: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000146; CHECK: .LBB3_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000147; CHECK-NEXT: end_block{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000148; CHECK: .LBB3_5:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000149; CHECK-NEXT: end_block{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000150; CHECK: return ${{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000151; OPT-LABEL: doublediamond:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000152; OPT: block{{$}}
153; OPT-NEXT: block{{$}}
154; OPT: br_if ${{[^,]*}}, 0{{$}}
155; OPT: block{{$}}
156; OPT: br_if ${{[^,]*}}, 0{{$}}
157; OPT: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000158; OPT: .LBB3_4:
159; OPT: .LBB3_5:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000160; OPT: return ${{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000161define i32 @doublediamond(i32 %a, i32 %b, i32* %p) {
162entry:
163 %c = icmp eq i32 %a, 0
164 %d = icmp eq i32 %b, 0
165 store volatile i32 0, i32* %p
166 br i1 %c, label %true, label %false
167true:
168 store volatile i32 1, i32* %p
169 br label %exit
170false:
171 store volatile i32 2, i32* %p
172 br i1 %d, label %ft, label %ff
173ft:
174 store volatile i32 3, i32* %p
175 br label %exit
176ff:
177 store volatile i32 4, i32* %p
178 br label %exit
179exit:
180 store volatile i32 5, i32* %p
181 ret i32 0
182}
183
Dan Gohmane51c0582015-10-06 00:27:55 +0000184; CHECK-LABEL: triangle:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000185; CHECK: block{{$}}
186; CHECK: br_if $1, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000187; CHECK: .LBB4_2:
Dan Gohman4ba48162015-11-18 16:12:01 +0000188; CHECK: return ${{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000189; OPT-LABEL: triangle:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000190; OPT: block{{$}}
191; OPT: br_if $1, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000192; OPT: .LBB4_2:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000193; OPT: return ${{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000194define i32 @triangle(i32* %p, i32 %a) {
195entry:
196 %c = icmp eq i32 %a, 0
197 store volatile i32 0, i32* %p
198 br i1 %c, label %true, label %exit
199true:
200 store volatile i32 1, i32* %p
201 br label %exit
202exit:
203 store volatile i32 2, i32* %p
204 ret i32 0
205}
206
Dan Gohmane51c0582015-10-06 00:27:55 +0000207; CHECK-LABEL: diamond:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000208; CHECK: block{{$}}
209; CHECK: block{{$}}
210; CHECK: br_if $1, 0{{$}}
211; CHECK: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000212; CHECK: .LBB5_2:
213; CHECK: .LBB5_3:
Dan Gohman4ba48162015-11-18 16:12:01 +0000214; CHECK: return ${{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000215; OPT-LABEL: diamond:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000216; OPT: block{{$}}
217; OPT: block{{$}}
218; OPT: br_if {{[^,]*}}, 0{{$}}
219; OPT: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000220; OPT: .LBB5_2:
221; OPT: .LBB5_3:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000222; OPT: return ${{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000223define i32 @diamond(i32* %p, i32 %a) {
224entry:
225 %c = icmp eq i32 %a, 0
226 store volatile i32 0, i32* %p
227 br i1 %c, label %true, label %false
228true:
229 store volatile i32 1, i32* %p
230 br label %exit
231false:
232 store volatile i32 2, i32* %p
233 br label %exit
234exit:
235 store volatile i32 3, i32* %p
236 ret i32 0
237}
238
Dan Gohmane51c0582015-10-06 00:27:55 +0000239; CHECK-LABEL: single_block:
Dan Gohman950a13c2015-09-16 16:51:30 +0000240; CHECK-NOT: br
Dan Gohman81719f82015-11-25 16:55:01 +0000241; CHECK: return $pop{{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000242; OPT-LABEL: single_block:
243; OPT-NOT: br
244; OPT: return $pop{{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000245define i32 @single_block(i32* %p) {
246entry:
247 store volatile i32 0, i32* %p
248 ret i32 0
249}
250
Dan Gohmane51c0582015-10-06 00:27:55 +0000251; CHECK-LABEL: minimal_loop:
Dan Gohman950a13c2015-09-16 16:51:30 +0000252; CHECK-NOT: br
Dan Gohmana4730cf2016-01-07 18:49:53 +0000253; CHECK: .LBB7_1:
Derek Schuff9d779522015-12-05 00:26:39 +0000254; CHECK: i32.store $discard=, 0($0), $pop{{[0-9]+}}{{$}}
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000255; CHECK: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000256; CHECK: .LBB7_2:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000257; OPT-LABEL: minimal_loop:
258; OPT-NOT: br
Dan Gohmana4730cf2016-01-07 18:49:53 +0000259; OPT: .LBB7_1:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000260; OPT: i32.store $discard=, 0($0), $pop{{[0-9]+}}{{$}}
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000261; OPT: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000262; OPT: .LBB7_2:
Dan Gohman950a13c2015-09-16 16:51:30 +0000263define i32 @minimal_loop(i32* %p) {
264entry:
265 store volatile i32 0, i32* %p
266 br label %loop
267loop:
268 store volatile i32 1, i32* %p
269 br label %loop
270}
271
Dan Gohmane51c0582015-10-06 00:27:55 +0000272; CHECK-LABEL: simple_loop:
Dan Gohman950a13c2015-09-16 16:51:30 +0000273; CHECK-NOT: br
Dan Gohmana4730cf2016-01-07 18:49:53 +0000274; CHECK: .LBB8_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000275; CHECK: loop{{$}}
276; CHECK: br_if $pop{{[0-9]+}}, 0{{$}}
277; CHECK-NEXT: end_loop{{$}}
Dan Gohman4ba48162015-11-18 16:12:01 +0000278; CHECK: return ${{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000279; OPT-LABEL: simple_loop:
280; OPT-NOT: br
Dan Gohmana4730cf2016-01-07 18:49:53 +0000281; OPT: .LBB8_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000282; OPT: loop{{$}}
283; OPT: br_if {{[^,]*}}, 0{{$}}
284; OPT-NEXT: end_loop{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000285; OPT: return ${{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000286define i32 @simple_loop(i32* %p, i32 %a) {
287entry:
288 %c = icmp eq i32 %a, 0
289 store volatile i32 0, i32* %p
290 br label %loop
291loop:
292 store volatile i32 1, i32* %p
293 br i1 %c, label %loop, label %exit
294exit:
295 store volatile i32 2, i32* %p
296 ret i32 0
297}
298
Dan Gohmane51c0582015-10-06 00:27:55 +0000299; CHECK-LABEL: doubletriangle:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000300; CHECK: block{{$}}
301; CHECK: br_if $0, 0{{$}}
302; CHECK: block{{$}}
303; CHECK: br_if $1, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000304; CHECK: .LBB9_3:
305; CHECK: .LBB9_4:
Dan Gohman4ba48162015-11-18 16:12:01 +0000306; CHECK: return ${{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000307; OPT-LABEL: doubletriangle:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000308; OPT: block{{$}}
309; OPT: br_if $0, 0{{$}}
310; OPT: block{{$}}
311; OPT: br_if $1, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000312; OPT: .LBB9_3:
313; OPT: .LBB9_4:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000314; OPT: return ${{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000315define i32 @doubletriangle(i32 %a, i32 %b, i32* %p) {
316entry:
317 %c = icmp eq i32 %a, 0
318 %d = icmp eq i32 %b, 0
319 store volatile i32 0, i32* %p
320 br i1 %c, label %true, label %exit
321true:
322 store volatile i32 2, i32* %p
323 br i1 %d, label %tt, label %tf
324tt:
325 store volatile i32 3, i32* %p
326 br label %tf
327tf:
328 store volatile i32 4, i32* %p
329 br label %exit
330exit:
331 store volatile i32 5, i32* %p
332 ret i32 0
333}
334
Dan Gohmane51c0582015-10-06 00:27:55 +0000335; CHECK-LABEL: ifelse_earlyexits:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000336; CHECK: block{{$}}
337; CHECK: block{{$}}
338; CHECK: br_if $0, 0{{$}}
339; CHECK: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000340; CHECK: .LBB10_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000341; CHECK: br_if $1, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000342; CHECK: .LBB10_4:
Dan Gohman4ba48162015-11-18 16:12:01 +0000343; CHECK: return ${{[0-9]+}}{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000344; OPT-LABEL: ifelse_earlyexits:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000345; OPT: block{{$}}
346; OPT: block{{$}}
347; OPT: br_if {{[^,]*}}, 0{{$}}
348; OPT: br_if $1, 1{{$}}
349; OPT: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000350; OPT: .LBB10_3:
351; OPT: .LBB10_4:
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000352; OPT: return ${{[0-9]+}}{{$}}
Dan Gohman950a13c2015-09-16 16:51:30 +0000353define i32 @ifelse_earlyexits(i32 %a, i32 %b, i32* %p) {
354entry:
355 %c = icmp eq i32 %a, 0
356 %d = icmp eq i32 %b, 0
357 store volatile i32 0, i32* %p
358 br i1 %c, label %true, label %false
359true:
360 store volatile i32 1, i32* %p
361 br label %exit
362false:
363 store volatile i32 2, i32* %p
364 br i1 %d, label %ft, label %exit
365ft:
366 store volatile i32 3, i32* %p
367 br label %exit
368exit:
369 store volatile i32 4, i32* %p
370 ret i32 0
371}
Dan Gohmane3e4a5f2015-10-02 21:11:36 +0000372
Dan Gohman32807932015-11-23 16:19:56 +0000373; CHECK-LABEL: doublediamond_in_a_loop:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000374; CHECK: .LBB11_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000375; CHECK: loop{{$}}
376; CHECK: block{{$}}
377; CHECK: block{{$}}
378; CHECK: br_if $0, 0{{$}}
379; CHECK: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000380; CHECK: .LBB11_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000381; CHECK: block{{$}}
382; CHECK: br_if $1, 0{{$}}
383; CHECK: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000384; CHECK: .LBB11_5:
385; CHECK: .LBB11_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000386; CHECK: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000387; CHECK: .LBB11_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000388; CHECK-NEXT: end_loop{{$}}
Dan Gohmanf0b165a2015-12-05 03:03:35 +0000389; OPT-LABEL: doublediamond_in_a_loop:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000390; OPT: .LBB11_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000391; OPT: loop{{$}}
392; OPT: block{{$}}
393; OPT: block{{$}}
394; OPT: br_if {{[^,]*}}, 0{{$}}
395; OPT: block{{$}}
396; OPT: br_if {{[^,]*}}, 0{{$}}
397; OPT: br 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000398; OPT: .LBB11_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000399; OPT-NEXT: end_block{{$}}
400; OPT: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000401; OPT: .LBB11_5:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000402; OPT-NEXT: end_block{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000403; OPT: .LBB11_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000404; OPT-NEXT: end_block{{$}}
405; OPT: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000406; OPT: .LBB11_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000407; OPT-NEXT: end_loop{{$}}
Dan Gohman32807932015-11-23 16:19:56 +0000408define i32 @doublediamond_in_a_loop(i32 %a, i32 %b, i32* %p) {
409entry:
410 br label %header
411header:
412 %c = icmp eq i32 %a, 0
413 %d = icmp eq i32 %b, 0
414 store volatile i32 0, i32* %p
415 br i1 %c, label %true, label %false
416true:
417 store volatile i32 1, i32* %p
418 br label %exit
419false:
420 store volatile i32 2, i32* %p
421 br i1 %d, label %ft, label %ff
422ft:
423 store volatile i32 3, i32* %p
424 br label %exit
425ff:
426 store volatile i32 4, i32* %p
427 br label %exit
428exit:
429 store volatile i32 5, i32* %p
430 br label %header
431}
432
Dan Gohmane3e4a5f2015-10-02 21:11:36 +0000433; Test that nested loops are handled.
434
Dan Gohman8fe7e862015-12-14 22:51:54 +0000435; CHECK-LABEL: test3:
436; CHECK: loop
437; CHECK-NEXT: br_if
Dan Gohmana4730cf2016-01-07 18:49:53 +0000438; CHECK-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000439; CHECK-NEXT: loop
440; OPT-LABEL: test3:
441; OPT: loop
442; OPT-NEXT: br_if
Dan Gohmana4730cf2016-01-07 18:49:53 +0000443; OPT-NEXT: .LBB{{[0-9]+}}_{{[0-9]+}}:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000444; OPT-NEXT: loop
Dan Gohmane3e4a5f2015-10-02 21:11:36 +0000445declare void @bar()
Dan Gohmane3e4a5f2015-10-02 21:11:36 +0000446define void @test3(i32 %w) {
447entry:
448 br i1 undef, label %outer.ph, label %exit
449
450outer.ph:
451 br label %outer
452
453outer:
454 %tobool = icmp eq i32 undef, 0
455 br i1 %tobool, label %inner, label %unreachable
456
457unreachable:
458 unreachable
459
460inner:
461 %c = icmp eq i32 undef, %w
462 br i1 %c, label %if.end, label %inner
463
464exit:
465 ret void
466
467if.end:
468 call void @bar()
469 br label %outer
470}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000471
472; Test switch lowering and block placement.
473
474; CHECK-LABEL: test4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000475; CHECK-NEXT: .param i32{{$}}
476; CHECK: block{{$}}
477; CHECK-NEXT: block{{$}}
478; CHECK-NEXT: block{{$}}
479; CHECK: br_if $pop{{[0-9]*}}, 0{{$}}
480; CHECK-NEXT: block{{$}}
481; CHECK: br_if $pop{{[0-9]*}}, 0{{$}}
482; CHECK: br_if $pop{{[0-9]*}}, 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000483; CHECK-NEXT: .LBB13_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000484; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000485; CHECK-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000486; CHECK-NEXT: .LBB13_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000487; CHECK: br_if $pop{{[0-9]*}}, 1{{$}}
488; CHECK: br_if $pop{{[0-9]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000489; CHECK-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000490; CHECK-NEXT: .LBB13_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000491; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000492; CHECK-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000493; CHECK-NEXT: .LBB13_8:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000494; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000495; CHECK-NEXT: return{{$}}
496; OPT-LABEL: test4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000497; OPT-NEXT: .param i32{{$}}
498; OPT: block{{$}}
499; OPT-NEXT: block{{$}}
500; OPT-NEXT: block{{$}}
501; OPT: br_if $pop{{[0-9]*}}, 0{{$}}
502; OPT-NEXT: block{{$}}
503; OPT: br_if $pop{{[0-9]*}}, 0{{$}}
504; OPT: br_if $pop{{[0-9]*}}, 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000505; OPT-NEXT: .LBB13_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000506; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000507; OPT-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000508; OPT-NEXT: .LBB13_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000509; OPT: br_if $pop{{[0-9]*}}, 1{{$}}
510; OPT: br_if $pop{{[0-9]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000511; OPT-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000512; OPT-NEXT: .LBB13_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000513; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000514; OPT-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000515; OPT-NEXT: .LBB13_8:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000516; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000517; OPT-NEXT: return{{$}}
518define void @test4(i32 %t) {
519entry:
520 switch i32 %t, label %default [
521 i32 0, label %bb2
522 i32 2, label %bb2
523 i32 4, label %bb1
524 i32 622, label %bb0
525 ]
526
527bb0:
528 ret void
529
530bb1:
531 ret void
532
533bb2:
534 ret void
535
536default:
537 ret void
538}
539
540; Test a case where the BLOCK needs to be placed before the LOOP in the
541; same basic block.
542
543; CHECK-LABEL: test5:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000544; CHECK: .LBB14_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000545; CHECK-NEXT: block{{$}}
546; CHECK-NEXT: loop{{$}}
547; CHECK: br_if {{[^,]*}}, 2{{$}}
548; CHECK: br_if {{[^,]*}}, 0{{$}}
549; CHECK-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000550; CHECK: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000551; CHECK-NEXT: .LBB14_4:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000552; CHECK: return{{$}}
553; OPT-LABEL: test5:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000554; OPT: .LBB14_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000555; OPT-NEXT: block{{$}}
556; OPT-NEXT: loop{{$}}
557; OPT: br_if {{[^,]*}}, 2{{$}}
558; OPT: br_if {{[^,]*}}, 0{{$}}
559; OPT-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000560; OPT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000561; OPT-NEXT: .LBB14_4:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000562; OPT: return{{$}}
563define void @test5(i1 %p, i1 %q) {
564entry:
565 br label %header
566
567header:
568 store volatile i32 0, i32* null
569 br i1 %p, label %more, label %alt
570
571more:
572 store volatile i32 1, i32* null
573 br i1 %q, label %header, label %return
574
575alt:
576 store volatile i32 2, i32* null
577 ret void
578
579return:
580 store volatile i32 3, i32* null
581 ret void
582}
583
584; Test an interesting case of a loop with multiple exits, which
585; aren't to layout successors of the loop, and one of which is to a successors
586; which has another predecessor.
587
588; CHECK-LABEL: test6:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000589; CHECK: .LBB15_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000590; CHECK-NEXT: block{{$}}
591; CHECK-NEXT: block{{$}}
592; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000593; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000594; CHECK: br_if {{[^,]*}}, 3{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000595; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000596; CHECK: br_if {{[^,]*}}, 2{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000597; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000598; CHECK: br_if {{[^,]*}}, 0{{$}}
599; CHECK-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000600; CHECK-NOT: block
601; CHECK: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000602; CHECK-NEXT: .LBB15_5:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000603; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000604; CHECK-NOT: block
Dan Gohmana4730cf2016-01-07 18:49:53 +0000605; CHECK: .LBB15_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000606; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000607; CHECK-NOT: block
608; CHECK: return{{$}}
609; OPT-LABEL: test6:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000610; OPT: .LBB15_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000611; OPT-NEXT: block{{$}}
612; OPT-NEXT: block{{$}}
613; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000614; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000615; OPT: br_if {{[^,]*}}, 3{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000616; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000617; OPT: br_if {{[^,]*}}, 2{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000618; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000619; OPT: br_if {{[^,]*}}, 0{{$}}
620; OPT-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000621; OPT-NOT: block
622; OPT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000623; OPT-NEXT: .LBB15_5:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000624; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000625; OPT-NOT: block
Dan Gohmana4730cf2016-01-07 18:49:53 +0000626; OPT: .LBB15_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000627; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000628; OPT-NOT: block
629; OPT: return{{$}}
630define void @test6(i1 %p, i1 %q) {
631entry:
632 br label %header
633
634header:
635 store volatile i32 0, i32* null
636 br i1 %p, label %more, label %second
637
638more:
639 store volatile i32 1, i32* null
640 br i1 %q, label %evenmore, label %first
641
642evenmore:
643 store volatile i32 1, i32* null
644 br i1 %q, label %header, label %return
645
646return:
647 store volatile i32 2, i32* null
648 ret void
649
650first:
651 store volatile i32 3, i32* null
652 br label %second
653
654second:
655 store volatile i32 4, i32* null
656 ret void
657}
658
659; Test a case where there are multiple backedges and multiple loop exits
660; that end in unreachable.
661
662; CHECK-LABEL: test7:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000663; CHECK: .LBB16_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000664; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000665; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000666; CHECK: block{{$}}
667; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000668; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000669; CHECK: br_if {{[^,]*}}, 1{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000670; CHECK-NOT: block
671; CHECK: unreachable
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000672; CHECK-NEXT: .LBB16_4:
673; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000674; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000675; CHECK: br_if {{[^,]*}}, 0{{$}}
676; CHECK-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000677; CHECK-NOT: block
678; CHECK: unreachable
679; OPT-LABEL: test7:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000680; OPT: .LBB16_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000681; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000682; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000683; OPT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000684; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000685; OPT: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000686; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000687; OPT: br_if {{[^,]*}}, 1{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000688; OPT-NOT: block
689; OPT: unreachable
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000690; OPT-NEXT: .LBB16_4:
691; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000692; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000693; OPT: br_if {{[^,]*}}, 0{{$}}
694; OPT-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000695; OPT-NOT: block
696; OPT: unreachable
697define void @test7(i1 %tobool2, i1 %tobool9) {
698entry:
699 store volatile i32 0, i32* null
700 br label %loop
701
702loop:
703 store volatile i32 1, i32* null
704 br i1 %tobool2, label %l1, label %l0
705
706l0:
707 store volatile i32 2, i32* null
708 br i1 %tobool9, label %loop, label %u0
709
710l1:
711 store volatile i32 3, i32* null
712 br i1 %tobool9, label %loop, label %u1
713
714u0:
715 store volatile i32 4, i32* null
716 unreachable
717
718u1:
719 store volatile i32 5, i32* null
720 unreachable
721}
722
723; Test an interesting case using nested loops and switches.
724
725; CHECK-LABEL: test8:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000726; CHECK: .LBB17_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000727; CHECK-NEXT: loop{{$}}
728; CHECK-NEXT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000729; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000730; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000731; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000732; CHECK: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000733; CHECK-NEXT: .LBB17_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000734; CHECK-NEXT: end_block{{$}}
735; CHECK-NEXT: loop{{$}}
736; CHECK-NEXT: br_if {{[^,]*}}, 0{{$}}
737; CHECK-NEXT: br 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000738; CHECK-NEXT: .LBB17_4:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000739; OPT-LABEL: test8:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000740; OPT: .LBB17_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000741; OPT-NEXT: loop{{$}}
742; OPT-NEXT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000743; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000744; OPT: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000745; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000746; OPT: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000747; OPT-NEXT: .LBB17_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000748; OPT-NEXT: end_block{{$}}
749; OPT-NEXT: loop{{$}}
750; OPT-NEXT: br_if {{[^,]*}}, 0{{$}}
751; OPT-NEXT: br 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000752; OPT-NEXT: .LBB17_4:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000753define i32 @test8() {
754bb:
755 br label %bb1
756
757bb1:
758 br i1 undef, label %bb2, label %bb3
759
760bb2:
761 switch i8 undef, label %bb1 [
762 i8 44, label %bb2
763 ]
764
765bb3:
766 switch i8 undef, label %bb1 [
767 i8 44, label %bb2
768 ]
769}
770
771; Test an interesting case using nested loops that share a bottom block.
772
773; CHECK-LABEL: test9:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000774; CHECK: .LBB18_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000775; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000776; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000777; CHECK: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000778; CHECK-NEXT: .LBB18_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000779; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000780; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000781; CHECK: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000782; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000783; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000784; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000785; CHECK: br_if {{[^,]*}}, 1{{$}}
786; CHECK-NEXT: br 3{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000787; CHECK-NEXT: .LBB18_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000788; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000789; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000790; CHECK: br_if {{[^,]*}}, 0{{$}}
791; CHECK-NEXT: br 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000792; CHECK-NEXT: .LBB18_5:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000793; CHECK-NOT: block
794; CHECK: return{{$}}
795; OPT-LABEL: test9:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000796; OPT: .LBB18_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000797; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000798; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000799; OPT: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000800; OPT-NEXT: .LBB18_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000801; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000802; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000803; OPT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000804; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000805; OPT: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000806; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000807; OPT: br_if {{[^,]*}}, 1{{$}}
808; OPT-NEXT: br 3{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000809; OPT-NEXT: .LBB18_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000810; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000811; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000812; OPT: br_if {{[^,]*}}, 0{{$}}
813; OPT-NEXT: br 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000814; OPT-NEXT: .LBB18_5:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000815; OPT-NOT: block
816; OPT: return{{$}}
817declare i1 @a()
818define void @test9() {
819entry:
820 store volatile i32 0, i32* null
821 br label %header
822
823header:
824 store volatile i32 1, i32* null
825 %call4 = call i1 @a()
826 br i1 %call4, label %header2, label %end
827
828header2:
829 store volatile i32 2, i32* null
830 %call = call i1 @a()
831 br i1 %call, label %if.then, label %if.else
832
833if.then:
834 store volatile i32 3, i32* null
835 %call3 = call i1 @a()
836 br i1 %call3, label %header2, label %header
837
838if.else:
839 store volatile i32 4, i32* null
840 %call2 = call i1 @a()
841 br i1 %call2, label %header2, label %header
842
843end:
844 store volatile i32 5, i32* null
845 ret void
846}
847
848; Test an interesting case involving nested loops sharing a loop bottom,
849; and loop exits to a block with unreachable.
850
851; CHECK-LABEL: test10:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000852; CHECK: .LBB19_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000853; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000854; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000855; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000856; CHECK-NEXT: .LBB19_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000857; CHECK-NEXT: block{{$}}
858; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000859; CHECK-NOT: block
Dan Gohmana4730cf2016-01-07 18:49:53 +0000860; CHECK: .LBB19_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000861; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000862; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000863; CHECK: br_if {{[^,]*}}, 5{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000864; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000865; CHECK: tableswitch {{[^,]*}}, 0, 0, 1, 5, 2, 4{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000866; CHECK-NEXT: .LBB19_5:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000867; CHECK-NEXT: end_loop{{$}}
868; CHECK-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000869; CHECK-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000870; CHECK-NEXT: .LBB19_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000871; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000872; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000873; CHECK: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000874; CHECK-NEXT: .LBB19_7:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000875; OPT-LABEL: test10:
Dan Gohmana4730cf2016-01-07 18:49:53 +0000876; OPT: .LBB19_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000877; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000878; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000879; OPT: br_if {{[^,]*}}, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000880; OPT-NEXT: .LBB19_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000881; OPT-NEXT: block{{$}}
882; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000883; OPT-NOT: block
Dan Gohmana4730cf2016-01-07 18:49:53 +0000884; OPT: .LBB19_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000885; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000886; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000887; OPT: br_if {{[^,]*}}, 5{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000888; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000889; OPT: tableswitch {{[^,]*}}, 0, 0, 1, 5, 2, 4{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000890; OPT-NEXT: .LBB19_5:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000891; OPT-NEXT: end_loop{{$}}
892; OPT-NEXT: end_loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000893; OPT-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000894; OPT-NEXT: .LBB19_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000895; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000896; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000897; OPT: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000898; OPT-NEXT: .LBB19_7:
Dan Gohman8fe7e862015-12-14 22:51:54 +0000899define void @test10() {
900bb0:
901 br label %bb1
902
903bb1:
904 %tmp = phi i32 [ 2, %bb0 ], [ 3, %bb3 ]
905 %tmp3 = phi i32 [ undef, %bb0 ], [ %tmp11, %bb3 ]
906 %tmp4 = icmp eq i32 %tmp3, 0
907 br i1 %tmp4, label %bb4, label %bb2
908
909bb2:
910 br label %bb3
911
912bb3:
913 %tmp11 = phi i32 [ 1, %bb5 ], [ 0, %bb2 ]
914 br label %bb1
915
916bb4:
917 %tmp6 = phi i32 [ %tmp9, %bb5 ], [ 4, %bb1 ]
918 %tmp7 = phi i32 [ %tmp6, %bb5 ], [ %tmp, %bb1 ]
919 br label %bb5
920
921bb5:
922 %tmp9 = phi i32 [ %tmp6, %bb5 ], [ %tmp7, %bb4 ]
923 switch i32 %tmp9, label %bb2 [
924 i32 0, label %bb5
925 i32 1, label %bb6
926 i32 3, label %bb4
927 i32 4, label %bb3
928 ]
929
930bb6:
931 ret void
932}
933
934; Test a CFG DAG with interesting merging.
935
936; CHECK-LABEL: test11:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000937; CHECK: block{{$}}
938; CHECK-NEXT: block{{$}}
939; CHECK-NEXT: block{{$}}
940; CHECK-NEXT: block{{$}}
941; CHECK-NEXT: br_if {{[^,]*}}, 0{{$}}
942; CHECK-NEXT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000943; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000944; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000945; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000946; CHECK: br_if {{[^,]*}}, 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000947; CHECK-NEXT: .LBB20_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000948; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000949; CHECK-NOT: block
950; CHECK: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000951; CHECK-NEXT: .LBB20_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000952; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000953; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000954; CHECK: br_if {{[^,]*}}, 2{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000955; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000956; CHECK: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000957; CHECK-NEXT: .LBB20_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000958; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000959; CHECK-NOT: block
960; CHECK: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000961; CHECK-NEXT: .LBB20_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000962; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000963; CHECK-NOT: block
964; CHECK: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000965; CHECK-NEXT: .LBB20_8:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000966; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000967; CHECK-NOT: block
968; CHECK: return{{$}}
969; OPT-LABEL: test11:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000970; OPT: block{{$}}
971; OPT-NEXT: block{{$}}
972; OPT-NEXT: br_if $0, 0{{$}}
973; OPT-NEXT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000974; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000975; OPT: br_if $0, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000976; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000977; OPT: br_if $0, 2{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000978; OPT-NEXT: .LBB20_3:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000979; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000980; OPT-NOT: block
981; OPT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000982; OPT-NEXT: .LBB20_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000983; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000984; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000985; OPT: block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000986; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000987; OPT: br_if $pop9, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000988; OPT-NOT: block
989; OPT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000990; OPT-NEXT: .LBB20_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000991; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000992; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000993; OPT: br_if $0, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000994; OPT-NOT: block
995; OPT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +0000996; OPT-NEXT: .LBB20_8:
Dan Gohman1d68e80f2016-01-12 19:14:46 +0000997; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +0000998; OPT-NOT: block
999; OPT: return{{$}}
1000define void @test11() {
1001bb0:
1002 store volatile i32 0, i32* null
1003 br i1 undef, label %bb1, label %bb4
1004bb1:
1005 store volatile i32 1, i32* null
1006 br i1 undef, label %bb3, label %bb2
1007bb2:
1008 store volatile i32 2, i32* null
1009 br i1 undef, label %bb3, label %bb7
1010bb3:
1011 store volatile i32 3, i32* null
1012 ret void
1013bb4:
1014 store volatile i32 4, i32* null
1015 br i1 undef, label %bb8, label %bb5
1016bb5:
1017 store volatile i32 5, i32* null
1018 br i1 undef, label %bb6, label %bb7
1019bb6:
1020 store volatile i32 6, i32* null
1021 ret void
1022bb7:
1023 store volatile i32 7, i32* null
1024 ret void
1025bb8:
1026 store volatile i32 8, i32* null
1027 ret void
1028}
1029
1030; CHECK-LABEL: test12:
Dan Gohmana4730cf2016-01-07 18:49:53 +00001031; CHECK: .LBB21_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001032; CHECK-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001033; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001034; CHECK: block{{$}}
1035; CHECK-NEXT: block{{$}}
1036; CHECK-NEXT: block{{$}}
1037; CHECK: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001038; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001039; CHECK: br_if {{[^,]*}}, 2{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001040; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001041; CHECK: br_if {{[^,]*}}, 2{{$}}
1042; CHECK-NEXT: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001043; CHECK-NEXT: .LBB21_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001044; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001045; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001046; CHECK: br_if {{[^,]*}}, 1{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001047; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001048; CHECK: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001049; CHECK-NEXT: .LBB21_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001050; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001051; CHECK-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001052; CHECK-NEXT: .LBB21_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001053; CHECK-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001054; CHECK-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001055; CHECK: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001056; CHECK-NEXT: .LBB21_8:
Dan Gohman8fe7e862015-12-14 22:51:54 +00001057; OPT-LABEL: test12:
Dan Gohmana4730cf2016-01-07 18:49:53 +00001058; OPT: .LBB21_1:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001059; OPT-NEXT: loop{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001060; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001061; OPT: block{{$}}
1062; OPT-NEXT: block{{$}}
1063; OPT-NEXT: block{{$}}
1064; OPT: br_if {{[^,]*}}, 0{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001065; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001066; OPT: br_if {{[^,]*}}, 2{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001067; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001068; OPT: br_if {{[^,]*}}, 2{{$}}
1069; OPT-NEXT: br 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001070; OPT-NEXT: .LBB21_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001071; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001072; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001073; OPT: br_if {{[^,]*}}, 1{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001074; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001075; OPT: br_if {{[^,]*}}, 1{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001076; OPT-NEXT: .LBB21_6:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001077; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001078; OPT-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001079; OPT-NEXT: .LBB21_7:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001080; OPT-NEXT: end_block{{$}}
Dan Gohman8fe7e862015-12-14 22:51:54 +00001081; OPT-NOT: block
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001082; OPT: br 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001083; OPT-NEXT: .LBB21_8:
Dan Gohman8fe7e862015-12-14 22:51:54 +00001084define void @test12(i8* %arg) {
1085bb:
1086 br label %bb1
1087
1088bb1:
1089 %tmp = phi i32 [ 0, %bb ], [ %tmp5, %bb4 ]
1090 %tmp2 = getelementptr i8, i8* %arg, i32 %tmp
1091 %tmp3 = load i8, i8* %tmp2
1092 switch i8 %tmp3, label %bb7 [
1093 i8 42, label %bb4
1094 i8 76, label %bb4
1095 i8 108, label %bb4
1096 i8 104, label %bb4
1097 ]
1098
1099bb4:
1100 %tmp5 = add i32 %tmp, 1
1101 br label %bb1
1102
1103bb7:
1104 ret void
1105}
Dan Gohmanb3aa1ec2015-12-16 19:06:41 +00001106
1107; A block can be "branched to" from another even if it is also reachable via
1108; fallthrough from the other. This would normally be optimized away, so use
1109; optnone to disable optimizations to test this case.
1110
1111; CHECK-LABEL: test13:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001112; CHECK-NEXT: local i32{{$}}
1113; CHECK: block{{$}}
1114; CHECK: br_if $pop4, 0{{$}}
Dan Gohmanb3aa1ec2015-12-16 19:06:41 +00001115; CHECK-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001116; CHECK-NEXT: .LBB22_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001117; CHECK-NEXT: end_block{{$}}
1118; CHECK: block{{$}}
1119; CHECK-NEXT: br_if $0, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001120; CHECK: .LBB22_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001121; CHECK-NEXT: end_block{{$}}
1122; CHECK: block{{$}}
1123; CHECK: br_if $pop6, 0{{$}}
1124; CHECK-NEXT: end_block{{$}}
Dan Gohmanb3aa1ec2015-12-16 19:06:41 +00001125; CHECK-NEXT: unreachable{{$}}
1126; OPT-LABEL: test13:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001127; OPT-NEXT: local i32{{$}}
1128; OPT: block{{$}}
1129; OPT: br_if $pop4, 0{{$}}
Dan Gohmanb3aa1ec2015-12-16 19:06:41 +00001130; OPT-NEXT: return{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001131; OPT-NEXT: .LBB22_2:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001132; OPT-NEXT: end_block{{$}}
1133; OPT: block{{$}}
1134; OPT-NEXT: br_if $0, 0{{$}}
Dan Gohmana4730cf2016-01-07 18:49:53 +00001135; OPT: .LBB22_4:
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001136; OPT-NEXT: end_block{{$}}
1137; OPT: block{{$}}
1138; OPT: br_if $pop6, 0{{$}}
1139; OPT-NEXT: end_block{{$}}
Dan Gohmanb3aa1ec2015-12-16 19:06:41 +00001140; OPT-NEXT: unreachable{{$}}
1141define void @test13() noinline optnone {
1142bb:
1143 br i1 undef, label %bb5, label %bb2
1144bb1:
1145 unreachable
1146bb2:
1147 br i1 undef, label %bb3, label %bb4
1148bb3:
1149 br label %bb4
1150bb4:
1151 %tmp = phi i1 [ false, %bb2 ], [ false, %bb3 ]
1152 br i1 %tmp, label %bb1, label %bb1
1153bb5:
1154 ret void
1155}
Dan Gohman1d68e80f2016-01-12 19:14:46 +00001156
1157; Test a case with a single-block loop that has another loop
1158; as a successor. The end_loop for the first loop should go
1159; before the loop for the second.
1160
1161; CHECK-LABEL: test14:
1162; CHECK-NEXT: local i32{{$}}
1163; CHECK-NEXT: i32.const $0=, 0{{$}}
1164; CHECK-NEXT: .LBB23_1:{{$}}
1165; CHECK-NEXT: loop{{$}}
1166; CHECK-NEXT: br_if $0, 0{{$}}
1167; CHECK-NEXT: .LBB23_2:{{$}}
1168; CHECK-NEXT: end_loop{{$}}
1169; CHECK-NEXT: loop{{$}}
1170; CHECK-NEXT: br_if $0, 0{{$}}
1171; CHECK-NEXT: end_loop{{$}}
1172; CHECK-NEXT: return{{$}}
1173define void @test14() {
1174bb:
1175 br label %bb1
1176
1177bb1:
1178 %tmp = bitcast i1 undef to i1
1179 br i1 %tmp, label %bb3, label %bb1
1180
1181bb3:
1182 br label %bb4
1183
1184bb4:
1185 br i1 undef, label %bb7, label %bb48
1186
1187bb7:
1188 br i1 undef, label %bb12, label %bb12
1189
1190bb12:
1191 br i1 undef, label %bb17, label %bb17
1192
1193bb17:
1194 br i1 undef, label %bb22, label %bb22
1195
1196bb22:
1197 br i1 undef, label %bb27, label %bb27
1198
1199bb27:
1200 br i1 undef, label %bb30, label %bb30
1201
1202bb30:
1203 br i1 undef, label %bb35, label %bb35
1204
1205bb35:
1206 br i1 undef, label %bb38, label %bb38
1207
1208bb38:
1209 br i1 undef, label %bb48, label %bb48
1210
1211bb48:
1212 %tmp49 = bitcast i1 undef to i1
1213 br i1 %tmp49, label %bb3, label %bb50
1214
1215bb50:
1216 ret void
1217}