1 ; RUN: sed 's/CODE_OBJECT_VERSION/400/g' %s | llc -mtriple=amdgcn-amd-amdhsa -enable-ipra=0 -verify-machineinstrs | FileCheck -check-prefixes=GCN,CI %s
2 ; RUN: sed 's/CODE_OBJECT_VERSION/500/g' %s | llc -mtriple=amdgcn-amd-amdhsa -enable-ipra=0 -verify-machineinstrs | FileCheck -check-prefixes=GCN-V5 %s
3 ; RUN: sed 's/CODE_OBJECT_VERSION/600/g' %s | llc -mtriple=amdgcn-amd-amdhsa -enable-ipra=0 -verify-machineinstrs | FileCheck -check-prefixes=GCN-V5 %s
4 ; RUN: sed 's/CODE_OBJECT_VERSION/400/g' %s | llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -enable-ipra=0 -verify-machineinstrs | FileCheck -check-prefixes=GCN,VI,VI-NOBUG %s
5 ; RUN: sed 's/CODE_OBJECT_VERSION/400/g' %s | llc -mtriple=amdgcn-amd-amdhsa -mcpu=iceland -enable-ipra=0 -verify-machineinstrs | FileCheck -check-prefixes=GCN,VI,VI-BUG %s
7 ; Make sure to run a GPU with the SGPR allocation bug.
9 ; GCN-LABEL: {{^}}use_vcc:
12 define void @use_vcc() #1 {
13 call void asm sideeffect "", "~{vcc}" () #0
17 ; GCN-LABEL: {{^}}indirect_use_vcc:
18 ; GCN: s_mov_b32 s4, s33
19 ; GCN: v_writelane_b32 v40, s4, 2
20 ; GCN: v_writelane_b32 v40, s30, 0
21 ; GCN: v_writelane_b32 v40, s31, 1
23 ; GCN: v_readlane_b32 s31, v40, 1
24 ; GCN: v_readlane_b32 s30, v40, 0
25 ; GCN: v_readlane_b32 s4, v40, 2
26 ; GCN: s_mov_b32 s33, s4
27 ; GCN: s_setpc_b64 s[30:31]
30 define void @indirect_use_vcc() #1 {
35 ; GCN-LABEL: {{^}}indirect_2level_use_vcc_kernel:
37 ; VI-NOBUG: ; NumSgprs: 40
38 ; VI-BUG: ; NumSgprs: 96
40 define amdgpu_kernel void @indirect_2level_use_vcc_kernel(ptr addrspace(1) %out) #0 {
41 call void @indirect_use_vcc()
45 ; GCN-LABEL: {{^}}use_flat_scratch:
49 define void @use_flat_scratch() #1 {
50 call void asm sideeffect "", "~{flat_scratch}" () #0
54 ; GCN-LABEL: {{^}}indirect_use_flat_scratch:
58 define void @indirect_use_flat_scratch() #1 {
59 call void @use_flat_scratch()
63 ; GCN-LABEL: {{^}}indirect_2level_use_flat_scratch_kernel:
65 ; VI-NOBUG: ; NumSgprs: 40
66 ; VI-BUG: ; NumSgprs: 96
68 define amdgpu_kernel void @indirect_2level_use_flat_scratch_kernel(ptr addrspace(1) %out) #0 {
69 call void @indirect_use_flat_scratch()
73 ; GCN-LABEL: {{^}}use_10_vgpr:
75 define void @use_10_vgpr() #1 {
76 call void asm sideeffect "", "~{v0},~{v1},~{v2},~{v3},~{v4}"() #0
77 call void asm sideeffect "", "~{v5},~{v6},~{v7},~{v8},~{v9}"() #0
81 ; GCN-LABEL: {{^}}indirect_use_10_vgpr:
83 define void @indirect_use_10_vgpr() #0 {
84 call void @use_10_vgpr()
88 ; GCN-LABEL: {{^}}indirect_2_level_use_10_vgpr:
90 define amdgpu_kernel void @indirect_2_level_use_10_vgpr() #0 {
91 call void @indirect_use_10_vgpr()
95 ; GCN-LABEL: {{^}}use_50_vgpr:
97 define void @use_50_vgpr() #1 {
98 call void asm sideeffect "", "~{v49}"() #0
102 ; GCN-LABEL: {{^}}indirect_use_50_vgpr:
103 ; GCN: ; NumVgprs: 50
104 define void @indirect_use_50_vgpr() #0 {
105 call void @use_50_vgpr()
109 ; GCN-LABEL: {{^}}use_80_sgpr:
110 ; GCN: ; NumSgprs: 80
111 define void @use_80_sgpr() #1 {
112 call void asm sideeffect "", "~{s79}"() #0
116 ; GCN-LABEL: {{^}}indirect_use_80_sgpr:
117 ; GCN: ; NumSgprs: 82
118 define void @indirect_use_80_sgpr() #1 {
119 call void @use_80_sgpr()
123 ; GCN-LABEL: {{^}}indirect_2_level_use_80_sgpr:
125 ; VI-NOBUG: ; NumSgprs: 86
126 ; VI-BUG: ; NumSgprs: 96
127 define amdgpu_kernel void @indirect_2_level_use_80_sgpr() #0 {
128 call void @indirect_use_80_sgpr()
133 ; GCN-LABEL: {{^}}use_stack0:
134 ; GCN: ScratchSize: 2052
135 define void @use_stack0() #1 {
136 %alloca = alloca [512 x i32], align 4, addrspace(5)
137 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
141 ; GCN-LABEL: {{^}}use_stack1:
142 ; GCN: ScratchSize: 404
143 define void @use_stack1() #1 {
144 %alloca = alloca [100 x i32], align 4, addrspace(5)
145 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
149 ; GCN-LABEL: {{^}}indirect_use_stack:
150 ; GCN: ScratchSize: 2132
151 define void @indirect_use_stack() #1 {
152 %alloca = alloca [16 x i32], align 4, addrspace(5)
153 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
154 call void @use_stack0()
158 ; GCN-LABEL: {{^}}indirect_2_level_use_stack:
159 ; GCN: ScratchSize: 2132
160 define amdgpu_kernel void @indirect_2_level_use_stack() #0 {
161 call void @indirect_use_stack()
166 ; Should be maximum of callee usage
167 ; GCN-LABEL: {{^}}multi_call_use_use_stack:
168 ; GCN: ScratchSize: 2052
169 define amdgpu_kernel void @multi_call_use_use_stack() #0 {
170 call void @use_stack0()
171 call void @use_stack1()
176 declare void @external() #0
178 ; GCN-LABEL: {{^}}usage_external:
181 ; GCN: ScratchSize: 16384
183 ; GCN-V5-LABEL: {{^}}usage_external:
184 ; GCN-V5: ScratchSize: 0
185 define amdgpu_kernel void @usage_external() #0 {
186 call void @external()
190 declare void @external_recurse() #2
192 ; GCN-LABEL: {{^}}usage_external_recurse:
195 ; GCN: ScratchSize: 16384
197 ; GCN-V5-LABEL: {{^}}usage_external_recurse:
198 ; GCN-V5: ScratchSize: 0
199 define amdgpu_kernel void @usage_external_recurse() #0 {
200 call void @external_recurse()
204 ; GCN-LABEL: {{^}}direct_recursion_use_stack:
205 ; GCN: ScratchSize: 18448{{$}}
207 ; GCN-V5-LABEL: {{^}}direct_recursion_use_stack:
208 ; GCN-V5: ScratchSize: 2064{{$}}
209 define void @direct_recursion_use_stack(i32 %val) #2 {
210 %alloca = alloca [512 x i32], align 4, addrspace(5)
211 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
212 %cmp = icmp eq i32 %val, 0
213 br i1 %cmp, label %ret, label %call
216 %val.sub1 = sub i32 %val, 1
217 call void @direct_recursion_use_stack(i32 %val.sub1)
224 ; GCN-LABEL: {{^}}usage_direct_recursion:
225 ; GCN: .amdhsa_private_segment_fixed_size 18448
227 ; GCN-V5-LABEL: {{^}}usage_direct_recursion:
228 ; GCN-V5: .amdhsa_private_segment_fixed_size 2064{{$}}
229 define amdgpu_kernel void @usage_direct_recursion(i32 %n) #0 {
230 call void @direct_recursion_use_stack(i32 %n)
234 ; Make sure there's no assert when a sgpr96 is used.
235 ; GCN-LABEL: {{^}}count_use_sgpr96_external_call
236 ; GCN: ; sgpr96 s[{{[0-9]+}}:{{[0-9]+}}]
238 ; VI-NOBUG: NumSgprs: 86
239 ; VI-BUG: NumSgprs: 96
241 define amdgpu_kernel void @count_use_sgpr96_external_call() {
243 tail call void asm sideeffect "; sgpr96 $0", "s"(<3 x i32> <i32 10, i32 11, i32 12>) #1
244 call void @external()
248 ; Make sure there's no assert when a sgpr160 is used.
249 ; GCN-LABEL: {{^}}count_use_sgpr160_external_call
250 ; GCN: ; sgpr160 s[{{[0-9]+}}:{{[0-9]+}}]
252 ; VI-NOBUG: NumSgprs: 86
253 ; VI-BUG: NumSgprs: 96
255 define amdgpu_kernel void @count_use_sgpr160_external_call() {
257 tail call void asm sideeffect "; sgpr160 $0", "s"(<5 x i32> <i32 10, i32 11, i32 12, i32 13, i32 14>) #1
258 call void @external()
262 ; Make sure there's no assert when a vgpr160 is used.
263 ; GCN-LABEL: {{^}}count_use_vgpr160_external_call
264 ; GCN: ; vgpr160 v[{{[0-9]+}}:{{[0-9]+}}]
266 ; VI-NOBUG: NumSgprs: 86
267 ; VI-BUG: NumSgprs: 96
269 define amdgpu_kernel void @count_use_vgpr160_external_call() {
271 tail call void asm sideeffect "; vgpr160 $0", "v"(<5 x i32> <i32 10, i32 11, i32 12, i32 13, i32 14>) #1
272 call void @external()
276 attributes #0 = { nounwind noinline norecurse "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" }
277 attributes #1 = { nounwind noinline norecurse "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" }
278 attributes #2 = { nounwind noinline }
280 !llvm.module.flags = !{!0}
281 !0 = !{i32 1, !"amdhsa_code_object_version", i32 CODE_OBJECT_VERSION}