blob: c298911504ac3e6eda22562ee07ee0742d02f528 [file] [log] [blame]
Matt Arsenault6bc43d82016-10-06 16:20:41 +00001; RUN: llc -march=amdgcn -verify-machineinstrs -amdgpu-s-branch-bits=4 < %s | FileCheck -check-prefix=GCN %s
2; Restrict maximum branch to between +7 and -8 dwords
3
4; Used to emit an always 4 byte instruction. Inline asm always assumes
5; each instruction is the maximum size.
6declare void @llvm.amdgcn.s.sleep(i32) #0
7
8declare i32 @llvm.amdgcn.workitem.id.x() #1
9
10
11; GCN-LABEL: {{^}}uniform_conditional_max_short_forward_branch:
12; GCN: s_load_dword [[CND:s[0-9]+]]
13; GCN: s_cmp_eq_u32 [[CND]], 0
14; GCN-NEXT: s_cbranch_scc1 [[BB3:BB[0-9]+_[0-9]+]]
15
16
17; GCN-NEXT: ; BB#1: ; %bb2
18; GCN-NEXT: ;;#ASMSTART
19; GCN-NEXT: v_nop_e64
20; GCN-NEXT: v_nop_e64
21; GCN-NEXT: v_nop_e64
22; GCN-NEXT: ;;#ASMEND
23; GCN-NEXT: s_sleep 0
24
25; GCN-NEXT: [[BB3]]: ; %bb3
26; GCN: v_mov_b32_e32 [[V_CND:v[0-9]+]], [[CND]]
27; GCN: buffer_store_dword [[V_CND]]
28; GCN: s_endpgm
29define void @uniform_conditional_max_short_forward_branch(i32 addrspace(1)* %arg, i32 %cnd) #0 {
30bb:
31 %cmp = icmp eq i32 %cnd, 0
32 br i1 %cmp, label %bb3, label %bb2 ; +8 dword branch
33
34bb2:
35; 24 bytes
36 call void asm sideeffect
37 "v_nop_e64
38 v_nop_e64
39 v_nop_e64", ""() #0
40 call void @llvm.amdgcn.s.sleep(i32 0)
41 br label %bb3
42
43bb3:
44 store volatile i32 %cnd, i32 addrspace(1)* %arg
45 ret void
46}
47
48; GCN-LABEL: {{^}}uniform_conditional_min_long_forward_branch:
49; GCN: s_load_dword [[CND:s[0-9]+]]
50; GCN: s_cmp_eq_u32 [[CND]], 0
51; GCN-NEXT: s_cbranch_scc0 [[LONGBB:BB[0-9]+_[0-9]+]]
52
53; GCN-NEXT: [[LONG_JUMP:BB[0-9]+_[0-9]+]]: ; %bb0
54; GCN-NEXT: s_getpc_b64 vcc
55; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[ENDBB:BB[0-9]+_[0-9]+]]-([[LONG_JUMP]]+4)
56; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0
57; GCN-NEXT: s_setpc_b64 vcc
58
59; GCN-NEXT: [[LONGBB]]:
60; GCN-NEXT: ;;#ASMSTART
61; GCN: v_nop_e64
62; GCN: v_nop_e64
63; GCN: v_nop_e64
64; GCN: v_nop_e64
65; GCN-NEXT: ;;#ASMEND
66
67; GCN-NEXT: [[ENDBB]]:
68; GCN: v_mov_b32_e32 [[V_CND:v[0-9]+]], [[CND]]
69; GCN: buffer_store_dword [[V_CND]]
70; GCN: s_endpgm
71define void @uniform_conditional_min_long_forward_branch(i32 addrspace(1)* %arg, i32 %cnd) #0 {
72bb0:
73 %cmp = icmp eq i32 %cnd, 0
74 br i1 %cmp, label %bb3, label %bb2 ; +9 dword branch
75
76bb2:
77; 32 bytes
78 call void asm sideeffect
79 "v_nop_e64
80 v_nop_e64
81 v_nop_e64
82 v_nop_e64", ""() #0
83 br label %bb3
84
85bb3:
86 store volatile i32 %cnd, i32 addrspace(1)* %arg
87 ret void
88}
89
90; GCN-LABEL: {{^}}uniform_conditional_min_long_forward_vcnd_branch:
91; GCN: s_load_dword [[CND:s[0-9]+]]
Matt Arsenault6bc43d82016-10-06 16:20:41 +000092; GCN-DAG: v_mov_b32_e32 [[V_CND:v[0-9]+]], [[CND]]
Matt Arsenaultf530e8b2016-11-07 19:09:33 +000093; GCN-DAG: v_cmp_eq_f32_e64 vcc, [[CND]], 0
94; GCN: s_cbranch_vccz [[LONGBB:BB[0-9]+_[0-9]+]]
Matt Arsenault6bc43d82016-10-06 16:20:41 +000095
96; GCN-NEXT: [[LONG_JUMP:BB[0-9]+_[0-9]+]]: ; %bb0
97; GCN-NEXT: s_getpc_b64 vcc
98; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[ENDBB:BB[0-9]+_[0-9]+]]-([[LONG_JUMP]]+4)
99; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0
100; GCN-NEXT: s_setpc_b64 vcc
101
102; GCN-NEXT: [[LONGBB]]:
103; GCN: v_nop_e64
104; GCN: v_nop_e64
105; GCN: v_nop_e64
106; GCN: v_nop_e64
107
108; GCN: [[ENDBB]]:
109; GCN: buffer_store_dword [[V_CND]]
110; GCN: s_endpgm
111define void @uniform_conditional_min_long_forward_vcnd_branch(float addrspace(1)* %arg, float %cnd) #0 {
112bb0:
113 %cmp = fcmp oeq float %cnd, 0.0
114 br i1 %cmp, label %bb3, label %bb2 ; + 8 dword branch
115
116bb2:
117 call void asm sideeffect " ; 32 bytes
118 v_nop_e64
119 v_nop_e64
120 v_nop_e64
121 v_nop_e64", ""() #0
122 br label %bb3
123
124bb3:
125 store volatile float %cnd, float addrspace(1)* %arg
126 ret void
127}
128
129; GCN-LABEL: {{^}}min_long_forward_vbranch:
130
131; GCN: buffer_load_dword
132; GCN: v_cmp_ne_u32_e32 vcc, 0, v{{[0-9]+}}
133; GCN: s_and_saveexec_b64 [[SAVE:s\[[0-9]+:[0-9]+\]]], vcc
134; GCN: s_xor_b64 [[SAVE]], exec, [[SAVE]]
135
136; GCN: v_nop_e64
137; GCN: v_nop_e64
138; GCN: v_nop_e64
139; GCN: v_nop_e64
140
141; GCN: s_or_b64 exec, exec, [[SAVE]]
142; GCN: buffer_store_dword
143; GCN: s_endpgm
144define void @min_long_forward_vbranch(i32 addrspace(1)* %arg) #0 {
145bb:
146 %tid = call i32 @llvm.amdgcn.workitem.id.x()
147 %tid.ext = zext i32 %tid to i64
148 %gep = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 %tid.ext
149 %load = load volatile i32, i32 addrspace(1)* %gep
150 %cmp = icmp eq i32 %load, 0
151 br i1 %cmp, label %bb3, label %bb2 ; + 8 dword branch
152
153bb2:
154 call void asm sideeffect " ; 32 bytes
155 v_nop_e64
156 v_nop_e64
157 v_nop_e64
158 v_nop_e64", ""() #0
159 br label %bb3
160
161bb3:
162 store volatile i32 %load, i32 addrspace(1)* %gep
163 ret void
164}
165
166; FIXME: Should be able to use s_cbranch_scc0
167; GCN-LABEL: {{^}}long_backward_sbranch:
168; GCN: v_mov_b32_e32 [[LOOPIDX:v[0-9]+]], 0{{$}}
169
170; GCN: [[LOOPBB:BB[0-9]+_[0-9]+]]: ; %bb2
171; GCN-NEXT: ; =>This Inner Loop Header: Depth=1
172; GCN-NEXT: v_add_i32_e32 [[INC:v[0-9]+]], vcc, 1, [[LOOPIDX]]
173; GCN-NEXT: v_cmp_gt_i32_e32 vcc, 10, [[INC]]
174
175; GCN-NEXT: ;;#ASMSTART
176; GCN-NEXT: v_nop_e64
177; GCN-NEXT: v_nop_e64
178; GCN-NEXT: v_nop_e64
179; GCN-NEXT: ;;#ASMEND
180
181; GCN-NEXT: s_and_b64 vcc, exec, vcc
182; GCN-NEXT: s_cbranch_vccz [[ENDBB:BB[0-9]+_[0-9]+]]
183
184; GCN-NEXT: [[LONG_JUMP:BB[0-9]+_[0-9]+]]: ; %bb2
185; GCN-NEXT: ; in Loop: Header=[[LOOPBB]] Depth=1
186; GCN-NEXT: s_getpc_b64 vcc
187; GCN-NEXT: s_sub_u32 vcc_lo, vcc_lo, ([[LONG_JUMP]]+4)-[[LOOPBB]]
188; GCN-NEXT: s_subb_u32 vcc_hi, vcc_hi, 0
189; GCN-NEXT: s_setpc_b64 vcc
190
191; GCN-NEXT: [[ENDBB]]:
192; GCN-NEXT: s_endpgm
193define void @long_backward_sbranch(i32 addrspace(1)* %arg) #0 {
194bb:
195 br label %bb2
196
197bb2:
198 %loop.idx = phi i32 [ 0, %bb ], [ %inc, %bb2 ]
199 ; 24 bytes
200 call void asm sideeffect
201 "v_nop_e64
202 v_nop_e64
203 v_nop_e64", ""() #0
204 %inc = add nsw i32 %loop.idx, 1 ; add cost 4
205 %cmp = icmp slt i32 %inc, 10 ; condition cost = 8
206 br i1 %cmp, label %bb2, label %bb3 ; -
207
208bb3:
209 ret void
210}
211
212; Requires expansion of unconditional branch from %bb2 to %bb4 (and
213; expansion of conditional branch from %bb to %bb3.
214
215; GCN-LABEL: {{^}}uniform_unconditional_min_long_forward_branch:
216; GCN: s_cmp_eq_u32
217; GCN-NEXT: s_cbranch_scc0 [[BB2:BB[0-9]+_[0-9]+]]
218
219; GCN-NEXT: [[LONG_JUMP0:BB[0-9]+_[0-9]+]]: ; %bb0
220; GCN-NEXT: s_getpc_b64 vcc
221; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[BB3:BB[0-9]_[0-9]+]]-([[LONG_JUMP0]]+4)
222; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0{{$}}
223; GCN-NEXT: s_setpc_b64 vcc
224
225; GCN-NEXT: [[BB2]]: ; %bb2
226; GCN: v_mov_b32_e32 [[BB2_K:v[0-9]+]], 17
227; GCN: buffer_store_dword [[BB2_K]]
228; GCN: s_waitcnt vmcnt(0)
229
230; GCN-NEXT: [[LONG_JUMP1:BB[0-9]+_[0-9]+]]: ; %bb2
231; GCN-NEXT: s_getpc_b64 vcc
232; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[BB4:BB[0-9]_[0-9]+]]-([[LONG_JUMP1]]+4)
233; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0{{$}}
234; GCN-NEXT: s_setpc_b64 vcc
235
236; GCN: [[BB3]]: ; %bb3
237; GCN: v_nop_e64
238; GCN: v_nop_e64
239; GCN: v_nop_e64
240; GCN: v_nop_e64
241; GCN: ;;#ASMEND
242
243; GCN-NEXT: [[BB4]]: ; %bb4
244; GCN: v_mov_b32_e32 [[BB4_K:v[0-9]+]], 63
245; GCN: buffer_store_dword [[BB4_K]]
246; GCN-NEXT: s_endpgm
247; GCN-NEXT: .Lfunc_end{{[0-9]+}}:
248define void @uniform_unconditional_min_long_forward_branch(i32 addrspace(1)* %arg, i32 %arg1) {
249bb0:
250 %tmp = icmp ne i32 %arg1, 0
251 br i1 %tmp, label %bb2, label %bb3
252
253bb2:
254 store volatile i32 17, i32 addrspace(1)* undef
255 br label %bb4
256
257bb3:
258 ; 32 byte asm
259 call void asm sideeffect
260 "v_nop_e64
261 v_nop_e64
262 v_nop_e64
263 v_nop_e64", ""() #0
264 br label %bb4
265
266bb4:
267 store volatile i32 63, i32 addrspace(1)* %arg
268 ret void
269}
270
271; GCN-LABEL: {{^}}uniform_unconditional_min_long_backward_branch:
272; GCN-NEXT: ; BB#0: ; %entry
273
274; GCN-NEXT: [[LOOP:BB[0-9]_[0-9]+]]: ; %loop
275; GCN-NEXT: ; =>This Inner Loop Header: Depth=1
276; GCN-NEXT: ;;#ASMSTART
277; GCN-NEXT: v_nop_e64
278; GCN-NEXT: v_nop_e64
279; GCN-NEXT: v_nop_e64
280; GCN-NEXT: v_nop_e64
281; GCN-NEXT: ;;#ASMEND
282
283; GCN-NEXT: [[LONGBB:BB[0-9]+_[0-9]+]]: ; %loop
284; GCN-NEXT: ; in Loop: Header=[[LOOP]] Depth=1
285; GCN-NEXT: s_getpc_b64 vcc
286; GCN-NEXT: s_sub_u32 vcc_lo, vcc_lo, ([[LONGBB]]+4)-[[LOOP]]
287; GCN-NEXT: s_subb_u32 vcc_hi, vcc_hi, 0{{$}}
288; GCN-NEXT: s_setpc_b64 vcc
289; GCN-NEXT .Lfunc_end{{[0-9]+}}:
290define void @uniform_unconditional_min_long_backward_branch(i32 addrspace(1)* %arg, i32 %arg1) {
291entry:
292 br label %loop
293
294loop:
295 ; 32 byte asm
296 call void asm sideeffect
297 "v_nop_e64
298 v_nop_e64
299 v_nop_e64
300 v_nop_e64", ""() #0
301 br label %loop
302}
303
304; Expansion of branch from %bb1 to %bb3 introduces need to expand
305; branch from %bb0 to %bb2
306
307; GCN-LABEL: {{^}}expand_requires_expand:
308; GCN-NEXT: ; BB#0: ; %bb0
309; GCN: s_load_dword
310; GCN: s_cmp_lt_i32 s{{[0-9]+}}, 0{{$}}
311; GCN-NEXT: s_cbranch_scc0 [[BB1:BB[0-9]+_[0-9]+]]
312
313; GCN-NEXT: [[LONGBB0:BB[0-9]+_[0-9]+]]: ; %bb0
314; GCN-NEXT: s_getpc_b64 vcc
315; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[BB2:BB[0-9]_[0-9]+]]-([[LONGBB0]]+4)
316; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0{{$}}
317; GCN-NEXT: s_setpc_b64 vcc
318
319; GCN-NEXT: [[BB1]]: ; %bb1
320; GCN-NEXT: s_load_dword
321; GCN-NEXT: s_waitcnt lgkmcnt(0)
322; GCN-NEXT: s_cmp_eq_u32 s{{[0-9]+}}, 3{{$}}
323; GCN-NEXT: s_cbranch_scc0 [[BB2:BB[0-9]_[0-9]+]]
324
325; GCN-NEXT: [[LONGBB1:BB[0-9]+_[0-9]+]]: ; %bb1
326; GCN-NEXT: s_getpc_b64 vcc
327; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[BB3:BB[0-9]+_[0-9]+]]-([[LONGBB1]]+4)
328; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0{{$}}
329; GCN-NEXT: s_setpc_b64 vcc
330
331; GCN-NEXT: [[BB2]]: ; %bb2
332; GCN-NEXT: ;;#ASMSTART
333; GCN-NEXT: v_nop_e64
334; GCN-NEXT: v_nop_e64
335; GCN-NEXT: v_nop_e64
336; GCN-NEXT: v_nop_e64
337; GCN-NEXT: ;;#ASMEND
338
339; GCN-NEXT: [[BB3]]: ; %bb3
340; GCN-NEXT: s_endpgm
341define void @expand_requires_expand(i32 %cond0) #0 {
342bb0:
343 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x() #0
344 %cmp0 = icmp slt i32 %cond0, 0
345 br i1 %cmp0, label %bb2, label %bb1
346
347bb1:
348 %val = load volatile i32, i32 addrspace(2)* undef
349 %cmp1 = icmp eq i32 %val, 3
350 br i1 %cmp1, label %bb3, label %bb2
351
352bb2:
353 call void asm sideeffect
354 "v_nop_e64
355 v_nop_e64
356 v_nop_e64
357 v_nop_e64", ""() #0
358 br label %bb3
359
360bb3:
361 ret void
362}
363
364; Requires expanding of required skip branch.
365
366; GCN-LABEL: {{^}}uniform_inside_divergent:
367; GCN: v_cmp_gt_u32_e32 vcc, 16, v{{[0-9]+}}
368; GCN-NEXT: s_and_saveexec_b64 [[MASK:s\[[0-9]+:[0-9]+\]]], vcc
369; GCN-NEXT: s_xor_b64 [[MASK1:s\[[0-9]+:[0-9]+\]]], exec, [[MASK]]
370; GCN-NEXT: ; mask branch [[ENDIF:BB[0-9]+_[0-9]+]]
371; GCN-NEXT: s_cbranch_execnz [[IF:BB[0-9]+_[0-9]+]]
372
373; GCN-NEXT: [[LONGBB:BB[0-9]+_[0-9]+]]: ; %entry
374; GCN-NEXT: s_getpc_b64 vcc
375; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[BB2:BB[0-9]_[0-9]+]]-([[LONGBB]]+4)
376; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0{{$}}
377; GCN-NEXT: s_setpc_b64 vcc
378
379; GCN-NEXT: [[IF]]: ; %if
380; GCN: buffer_store_dword
381; GCN: s_cmp_lg_u32
382; GCN: s_cbranch_scc1 [[ENDIF]]
383
384; GCN-NEXT: ; BB#2: ; %if_uniform
385; GCN: buffer_store_dword
386; GCN: s_waitcnt vmcnt(0)
387
388; GCN-NEXT: [[ENDIF]]: ; %endif
389; GCN-NEXT: s_or_b64 exec, exec, [[MASK]]
390; GCN-NEXT: s_endpgm
391define void @uniform_inside_divergent(i32 addrspace(1)* %out, i32 %cond) #0 {
392entry:
393 %tid = call i32 @llvm.amdgcn.workitem.id.x()
394 %d_cmp = icmp ult i32 %tid, 16
395 br i1 %d_cmp, label %if, label %endif
396
397if:
398 store i32 0, i32 addrspace(1)* %out
399 %u_cmp = icmp eq i32 %cond, 0
400 br i1 %u_cmp, label %if_uniform, label %endif
401
402if_uniform:
403 store i32 1, i32 addrspace(1)* %out
404 br label %endif
405
406endif:
407 ret void
408}
409
410; si_mask_branch
411; s_cbranch_execz
412; s_branch
413
414; GCN-LABEL: {{^}}analyze_mask_branch:
415; GCN: v_cmp_lt_f32_e32 vcc
416; GCN-NEXT: s_and_saveexec_b64 [[MASK:s\[[0-9]+:[0-9]+\]]], vcc
417; GCN-NEXT: s_xor_b64 [[MASK]], exec, [[MASK]]
418; GCN-NEXT: ; mask branch [[RET:BB[0-9]+_[0-9]+]]
419; GCN-NEXT: s_cbranch_execz [[BRANCH_SKIP:BB[0-9]+_[0-9]+]]
420; GCN-NEXT: s_branch [[LOOP_BODY:BB[0-9]+_[0-9]+]]
421
422; GCN-NEXT: [[BRANCH_SKIP]]: ; %entry
423; GCN-NEXT: s_getpc_b64 vcc
424; GCN-NEXT: s_add_u32 vcc_lo, vcc_lo, [[RET]]-([[BRANCH_SKIP]]+4)
425; GCN-NEXT: s_addc_u32 vcc_hi, vcc_hi, 0
426; GCN-NEXT: s_setpc_b64 vcc
427
428; GCN-NEXT: [[LOOP_BODY]]: ; %loop_body
429; GCN: v_nop_e64
430; GCN: v_nop_e64
431; GCN: v_nop_e64
432; GCN: v_nop_e64
433; GCN: v_nop_e64
434; GCN: v_nop_e64
435; GCN: ;;#ASMEND
Matt Arsenaultf530e8b2016-11-07 19:09:33 +0000436; GCN-NEXT: s_mov_b64 vcc, -1{{$}}
Matt Arsenault6bc43d82016-10-06 16:20:41 +0000437; GCN-NEXT: s_cbranch_vccz [[RET]]
438
439; GCN-NEXT: [[LONGBB:BB[0-9]+_[0-9]+]]: ; %loop_body
440; GCN-NEXT: ; in Loop: Header=[[LOOP_BODY]] Depth=1
441; GCN-NEXT: s_getpc_b64 vcc
442; GCN-NEXT: s_sub_u32 vcc_lo, vcc_lo, ([[LONGBB]]+4)-[[LOOP_BODY]]
443; GCN-NEXT: s_subb_u32 vcc_hi, vcc_hi, 0
444; GCN-NEXT: s_setpc_b64 vcc
445
446; GCN-NEXT: [[RET]]: ; %Flow
447; GCN-NEXT: s_or_b64 exec, exec, [[MASK]]
448; GCN: buffer_store_dword
449; GCN-NEXT: s_endpgm
450define void @analyze_mask_branch() #0 {
451entry:
452 %reg = call float asm sideeffect "v_mov_b32_e64 $0, 0", "=v"()
453 %cmp0 = fcmp ogt float %reg, 0.000000e+00
454 br i1 %cmp0, label %loop, label %ret
455
456loop:
457 %phi = phi float [ 0.000000e+00, %loop_body ], [ 1.000000e+00, %entry ]
458 call void asm sideeffect
459 "v_nop_e64
460 v_nop_e64", ""() #0
461 %cmp1 = fcmp olt float %phi, 8.0
462 br i1 %cmp1, label %loop_body, label %ret
463
464loop_body:
465 call void asm sideeffect
466 "v_nop_e64
467 v_nop_e64
468 v_nop_e64
469 v_nop_e64", ""() #0
470 br label %loop
471
472ret:
473 store volatile i32 7, i32 addrspace(1)* undef
474 ret void
475}
476
Matt Arsenault44deb792016-11-02 16:18:29 +0000477; GCN-LABEL: {{^}}long_branch_hang:
478; GCN: s_cmp_lt_i32 s{{[0-9]+}}, 6
479; GCN-NEXT: s_cbranch_scc1 [[LONG_BR_0:BB[0-9]+_[0-9]+]]
Matt Arsenaultf530e8b2016-11-07 19:09:33 +0000480; GCN-NEXT: s_branch [[SHORTB:BB[0-9]+_[0-9]+]]
Matt Arsenault44deb792016-11-02 16:18:29 +0000481
Matt Arsenaultf530e8b2016-11-07 19:09:33 +0000482; GCN-NEXT: [[LONG_BR_0]]:
Matt Arsenault44deb792016-11-02 16:18:29 +0000483; GCN: s_add_u32 vcc_lo, vcc_lo, [[LONG_BR_DEST0:BB[0-9]+_[0-9]+]]-(
484; GCN: s_setpc_b64
485
Matt Arsenaultf530e8b2016-11-07 19:09:33 +0000486; GCN: [[SHORTB]]:
Matt Arsenault44deb792016-11-02 16:18:29 +0000487; GCN-DAG: v_cmp_lt_i32
488; GCN-DAG: v_cmp_gt_i32
489; GCN: s_cbranch_vccnz
490
491; GCN: s_setpc_b64
492; GCN: s_setpc_b64
493
Matt Arsenaultf530e8b2016-11-07 19:09:33 +0000494; GCN: [[LONG_BR_DEST0]]
Matt Arsenault44deb792016-11-02 16:18:29 +0000495; GCN: s_cmp_eq_u32
496; GCN-NEXT: s_cbranch_scc0
497; GCN: s_setpc_b64
498
499; GCN: s_endpgm
500define amdgpu_kernel void @long_branch_hang(i32 addrspace(1)* nocapture %arg, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i64 %arg5) #0 {
501bb:
502 %tmp = icmp slt i32 %arg2, 9
503 %tmp6 = icmp eq i32 %arg1, 0
504 %tmp7 = icmp sgt i32 %arg4, 0
505 %tmp8 = icmp sgt i32 %arg4, 5
506 br i1 %tmp8, label %bb9, label %bb13
507
508bb9: ; preds = %bb
509 %tmp10 = and i1 %tmp7, %tmp
510 %tmp11 = icmp slt i32 %arg3, %arg4
511 %tmp12 = or i1 %tmp11, %tmp7
512 br i1 %tmp12, label %bb19, label %bb14
513
514bb13: ; preds = %bb
515 br i1 %tmp6, label %bb19, label %bb14
516
517bb14: ; preds = %bb13, %bb9
518 %tmp15 = icmp slt i32 %arg3, %arg4
519 %tmp16 = or i1 %tmp15, %tmp
520 %tmp17 = and i1 %tmp6, %tmp16
521 %tmp18 = zext i1 %tmp17 to i32
522 br label %bb19
523
524bb19: ; preds = %bb14, %bb13, %bb9
525 %tmp20 = phi i32 [ undef, %bb9 ], [ undef, %bb13 ], [ %tmp18, %bb14 ]
526 %tmp21 = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 %arg5
527 store i32 %tmp20, i32 addrspace(1)* %tmp21, align 4
528 ret void
529}
530
Matt Arsenault6bc43d82016-10-06 16:20:41 +0000531attributes #0 = { nounwind }
532attributes #1 = { nounwind readnone }