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