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/400/g' %s | llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -enable-ipra=0 -verify-machineinstrs | FileCheck -check-prefixes=GCN,VI,VI-NOBUG %s
4 ; 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
6 ; Make sure to run a GPU with the SGPR allocation bug.
8 ; GCN-LABEL: {{^}}use_vcc:
11 define void @use_vcc() #1 {
12 call void asm sideeffect "", "~{vcc}" () #0
16 ; GCN-LABEL: {{^}}indirect_use_vcc:
17 ; GCN: s_mov_b32 s4, s33
18 ; GCN: v_writelane_b32 v40, s4, 2
19 ; GCN: v_writelane_b32 v40, s30, 0
20 ; GCN: v_writelane_b32 v40, s31, 1
22 ; GCN: v_readlane_b32 s31, v40, 1
23 ; GCN: v_readlane_b32 s30, v40, 0
24 ; GCN: v_readlane_b32 s4, v40, 2
25 ; GCN: s_mov_b32 s33, s4
26 ; GCN: s_setpc_b64 s[30:31]
29 define void @indirect_use_vcc() #1 {
34 ; GCN-LABEL: {{^}}indirect_2level_use_vcc_kernel:
36 ; VI-NOBUG: ; NumSgprs: 40
37 ; VI-BUG: ; NumSgprs: 96
39 define amdgpu_kernel void @indirect_2level_use_vcc_kernel(ptr addrspace(1) %out) #0 {
40 call void @indirect_use_vcc()
44 ; GCN-LABEL: {{^}}use_flat_scratch:
48 define void @use_flat_scratch() #1 {
49 call void asm sideeffect "", "~{flat_scratch}" () #0
53 ; GCN-LABEL: {{^}}indirect_use_flat_scratch:
57 define void @indirect_use_flat_scratch() #1 {
58 call void @use_flat_scratch()
62 ; GCN-LABEL: {{^}}indirect_2level_use_flat_scratch_kernel:
64 ; VI-NOBUG: ; NumSgprs: 40
65 ; VI-BUG: ; NumSgprs: 96
67 define amdgpu_kernel void @indirect_2level_use_flat_scratch_kernel(ptr addrspace(1) %out) #0 {
68 call void @indirect_use_flat_scratch()
72 ; GCN-LABEL: {{^}}use_10_vgpr:
74 define void @use_10_vgpr() #1 {
75 call void asm sideeffect "", "~{v0},~{v1},~{v2},~{v3},~{v4}"() #0
76 call void asm sideeffect "", "~{v5},~{v6},~{v7},~{v8},~{v9}"() #0
80 ; GCN-LABEL: {{^}}indirect_use_10_vgpr:
82 define void @indirect_use_10_vgpr() #0 {
83 call void @use_10_vgpr()
87 ; GCN-LABEL: {{^}}indirect_2_level_use_10_vgpr:
89 define amdgpu_kernel void @indirect_2_level_use_10_vgpr() #0 {
90 call void @indirect_use_10_vgpr()
94 ; GCN-LABEL: {{^}}use_50_vgpr:
96 define void @use_50_vgpr() #1 {
97 call void asm sideeffect "", "~{v49}"() #0
101 ; GCN-LABEL: {{^}}indirect_use_50_vgpr:
102 ; GCN: ; NumVgprs: 50
103 define void @indirect_use_50_vgpr() #0 {
104 call void @use_50_vgpr()
108 ; GCN-LABEL: {{^}}use_80_sgpr:
109 ; GCN: ; NumSgprs: 80
110 define void @use_80_sgpr() #1 {
111 call void asm sideeffect "", "~{s79}"() #0
115 ; GCN-LABEL: {{^}}indirect_use_80_sgpr:
116 ; GCN: ; NumSgprs: 82
117 define void @indirect_use_80_sgpr() #1 {
118 call void @use_80_sgpr()
122 ; GCN-LABEL: {{^}}indirect_2_level_use_80_sgpr:
124 ; VI-NOBUG: ; NumSgprs: 86
125 ; VI-BUG: ; NumSgprs: 96
126 define amdgpu_kernel void @indirect_2_level_use_80_sgpr() #0 {
127 call void @indirect_use_80_sgpr()
132 ; GCN-LABEL: {{^}}use_stack0:
133 ; GCN: ScratchSize: 2052
134 define void @use_stack0() #1 {
135 %alloca = alloca [512 x i32], align 4, addrspace(5)
136 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
140 ; GCN-LABEL: {{^}}use_stack1:
141 ; GCN: ScratchSize: 404
142 define void @use_stack1() #1 {
143 %alloca = alloca [100 x i32], align 4, addrspace(5)
144 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
148 ; GCN-LABEL: {{^}}indirect_use_stack:
149 ; GCN: ScratchSize: 2132
150 define void @indirect_use_stack() #1 {
151 %alloca = alloca [16 x i32], align 4, addrspace(5)
152 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
153 call void @use_stack0()
157 ; GCN-LABEL: {{^}}indirect_2_level_use_stack:
158 ; GCN: ScratchSize: 2132
159 define amdgpu_kernel void @indirect_2_level_use_stack() #0 {
160 call void @indirect_use_stack()
165 ; Should be maximum of callee usage
166 ; GCN-LABEL: {{^}}multi_call_use_use_stack:
167 ; GCN: ScratchSize: 2052
168 define amdgpu_kernel void @multi_call_use_use_stack() #0 {
169 call void @use_stack0()
170 call void @use_stack1()
175 declare void @external() #0
177 ; GCN-LABEL: {{^}}usage_external:
180 ; GCN: ScratchSize: 16384
182 ; GCN-V5-LABEL: {{^}}usage_external:
183 ; GCN-V5: ScratchSize: 0
184 define amdgpu_kernel void @usage_external() #0 {
185 call void @external()
189 declare void @external_recurse() #2
191 ; GCN-LABEL: {{^}}usage_external_recurse:
194 ; GCN: ScratchSize: 16384
196 ; GCN-V5-LABEL: {{^}}usage_external_recurse:
197 ; GCN-V5: ScratchSize: 0
198 define amdgpu_kernel void @usage_external_recurse() #0 {
199 call void @external_recurse()
203 ; GCN-LABEL: {{^}}direct_recursion_use_stack:
204 ; GCN: ScratchSize: 18448{{$}}
206 ; GCN-V5-LABEL: {{^}}direct_recursion_use_stack:
207 ; GCN-V5: ScratchSize: 2064{{$}}
208 define void @direct_recursion_use_stack(i32 %val) #2 {
209 %alloca = alloca [512 x i32], align 4, addrspace(5)
210 call void asm sideeffect "; use $0", "v"(ptr addrspace(5) %alloca) #0
211 %cmp = icmp eq i32 %val, 0
212 br i1 %cmp, label %ret, label %call
215 %val.sub1 = sub i32 %val, 1
216 call void @direct_recursion_use_stack(i32 %val.sub1)
223 ; GCN-LABEL: {{^}}usage_direct_recursion:
224 ; GCN: .amdhsa_private_segment_fixed_size 18448
226 ; GCN-V5-LABEL: {{^}}usage_direct_recursion:
227 ; GCN-V5: .amdhsa_private_segment_fixed_size 2064{{$}}
228 define amdgpu_kernel void @usage_direct_recursion(i32 %n) #0 {
229 call void @direct_recursion_use_stack(i32 %n)
233 ; Make sure there's no assert when a sgpr96 is used.
234 ; GCN-LABEL: {{^}}count_use_sgpr96_external_call
235 ; GCN: ; sgpr96 s[{{[0-9]+}}:{{[0-9]+}}]
237 ; VI-NOBUG: NumSgprs: 86
238 ; VI-BUG: NumSgprs: 96
240 define amdgpu_kernel void @count_use_sgpr96_external_call() {
242 tail call void asm sideeffect "; sgpr96 $0", "s"(<3 x i32> <i32 10, i32 11, i32 12>) #1
243 call void @external()
247 ; Make sure there's no assert when a sgpr160 is used.
248 ; GCN-LABEL: {{^}}count_use_sgpr160_external_call
249 ; GCN: ; sgpr160 s[{{[0-9]+}}:{{[0-9]+}}]
251 ; VI-NOBUG: NumSgprs: 86
252 ; VI-BUG: NumSgprs: 96
254 define amdgpu_kernel void @count_use_sgpr160_external_call() {
256 tail call void asm sideeffect "; sgpr160 $0", "s"(<5 x i32> <i32 10, i32 11, i32 12, i32 13, i32 14>) #1
257 call void @external()
261 ; Make sure there's no assert when a vgpr160 is used.
262 ; GCN-LABEL: {{^}}count_use_vgpr160_external_call
263 ; GCN: ; vgpr160 v[{{[0-9]+}}:{{[0-9]+}}]
265 ; VI-NOBUG: NumSgprs: 86
266 ; VI-BUG: NumSgprs: 96
268 define amdgpu_kernel void @count_use_vgpr160_external_call() {
270 tail call void asm sideeffect "; vgpr160 $0", "v"(<5 x i32> <i32 10, i32 11, i32 12, i32 13, i32 14>) #1
271 call void @external()
275 attributes #0 = { nounwind noinline norecurse }
276 attributes #1 = { nounwind noinline norecurse }
277 attributes #2 = { nounwind noinline }
279 !llvm.module.flags = !{!0}
280 !0 = !{i32 1, !"amdgpu_code_object_version", i32 CODE_OBJECT_VERSION}