[PowerPC] Generate Power9 extswsli extend sign and shift immediate instruction
[llvm-core.git] / test / CodeGen / AMDGPU / call-graph-register-usage.ll
blob21c69d9bee7d0eeb2b69ba366379cd1015d8bca5
1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,CI %s
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,VI,VI-NOBUG %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=iceland -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,VI,VI-BUG %s
5 ; Make sure to run a GPU with the SGPR allocation bug.
7 ; GCN-LABEL: {{^}}use_vcc:
8 ; GCN: ; NumSgprs: 34
9 ; GCN: ; NumVgprs: 0
10 define void @use_vcc() #1 {
11   call void asm sideeffect "", "~{vcc}" () #0
12   ret void
15 ; GCN-LABEL: {{^}}indirect_use_vcc:
16 ; GCN: v_writelane_b32 v32, s33, 0
17 ; GCN: v_writelane_b32 v32, s34, 1
18 ; GCN: v_writelane_b32 v32, s35, 2
19 ; GCN: s_swappc_b64
20 ; GCN: v_readlane_b32 s35, v32, 2
21 ; GCN: v_readlane_b32 s34, v32, 1
22 ; GCN: v_readlane_b32 s33, v32, 0
23 ; GCN: ; NumSgprs: 38
24 ; GCN: ; NumVgprs: 33
25 define void @indirect_use_vcc() #1 {
26   call void @use_vcc()
27   ret void
30 ; GCN-LABEL: {{^}}indirect_2level_use_vcc_kernel:
31 ; GCN: is_dynamic_callstack = 0
32 ; CI: ; NumSgprs: 40
33 ; VI-NOBUG: ; NumSgprs: 42
34 ; VI-BUG: ; NumSgprs: 96
35 ; GCN: ; NumVgprs: 33
36 define amdgpu_kernel void @indirect_2level_use_vcc_kernel(i32 addrspace(1)* %out) #0 {
37   call void @indirect_use_vcc()
38   ret void
41 ; GCN-LABEL: {{^}}use_flat_scratch:
42 ; CI: ; NumSgprs: 36
43 ; VI: ; NumSgprs: 38
44 ; GCN: ; NumVgprs: 0
45 define void @use_flat_scratch() #1 {
46   call void asm sideeffect "", "~{flat_scratch}" () #0
47   ret void
50 ; GCN-LABEL: {{^}}indirect_use_flat_scratch:
51 ; CI: ; NumSgprs: 40
52 ; VI: ; NumSgprs: 42
53 ; GCN: ; NumVgprs: 33
54 define void @indirect_use_flat_scratch() #1 {
55   call void @use_flat_scratch()
56   ret void
59 ; GCN-LABEL: {{^}}indirect_2level_use_flat_scratch_kernel:
60 ; GCN: is_dynamic_callstack = 0
61 ; CI: ; NumSgprs: 40
62 ; VI-NOBUG: ; NumSgprs: 42
63 ; VI-BUG: ; NumSgprs: 96
64 ; GCN: ; NumVgprs: 33
65 define amdgpu_kernel void @indirect_2level_use_flat_scratch_kernel(i32 addrspace(1)* %out) #0 {
66   call void @indirect_use_flat_scratch()
67   ret void
70 ; GCN-LABEL: {{^}}use_10_vgpr:
71 ; GCN: ; NumVgprs: 10
72 define void @use_10_vgpr() #1 {
73   call void asm sideeffect "", "~{v0},~{v1},~{v2},~{v3},~{v4}"() #0
74   call void asm sideeffect "", "~{v5},~{v6},~{v7},~{v8},~{v9}"() #0
75   ret void
78 ; GCN-LABEL: {{^}}indirect_use_10_vgpr:
79 ; GCN: ; NumVgprs: 33
80 define void @indirect_use_10_vgpr() #0 {
81   call void @use_10_vgpr()
82   ret void
85 ; GCN-LABEL: {{^}}indirect_2_level_use_10_vgpr:
86 ; GCN: is_dynamic_callstack = 0
87 ; GCN: ; NumVgprs: 10
88 define amdgpu_kernel void @indirect_2_level_use_10_vgpr() #0 {
89   call void @indirect_use_10_vgpr()
90   ret void
93 ; GCN-LABEL: {{^}}use_40_vgpr:
94 ; GCN: ; NumVgprs: 40
95 define void @use_40_vgpr() #1 {
96   call void asm sideeffect "", "~{v39}"() #0
97   ret void
100 ; GCN-LABEL: {{^}}indirect_use_40_vgpr:
101 ; GCN: ; NumVgprs: 40
102 define void @indirect_use_40_vgpr() #0 {
103   call void @use_40_vgpr()
104   ret void
107 ; GCN-LABEL: {{^}}use_80_sgpr:
108 ; GCN: ; NumSgprs: 80
109 define void @use_80_sgpr() #1 {
110   call void asm sideeffect "", "~{s79}"() #0
111   ret void
114 ; GCN-LABEL: {{^}}indirect_use_80_sgpr:
115 ; GCN: ; NumSgprs: 82
116 define void @indirect_use_80_sgpr() #1 {
117   call void @use_80_sgpr()
118   ret void
121 ; GCN-LABEL: {{^}}indirect_2_level_use_80_sgpr:
122 ; GCN: is_dynamic_callstack = 0
123 ; CI: ; NumSgprs: 84
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()
128   ret void
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"([512 x i32] addrspace(5)* %alloca) #0
137   ret void
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"([100 x i32] addrspace(5)* %alloca) #0
145   ret void
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"([16 x i32] addrspace(5)* %alloca) #0
153   call void @use_stack0()
154   ret void
157 ; GCN-LABEL: {{^}}indirect_2_level_use_stack:
158 ; GCN: is_dynamic_callstack = 0
159 ; GCN: ScratchSize: 2132
160 define amdgpu_kernel void @indirect_2_level_use_stack() #0 {
161   call void @indirect_use_stack()
162   ret void
166 ; Should be maximum of callee usage
167 ; GCN-LABEL: {{^}}multi_call_use_use_stack:
168 ; GCN: is_dynamic_callstack = 0
169 ; GCN: ScratchSize: 2052
170 define amdgpu_kernel void @multi_call_use_use_stack() #0 {
171   call void @use_stack0()
172   call void @use_stack1()
173   ret void
177 declare void @external() #0
179 ; GCN-LABEL: {{^}}usage_external:
180 ; GCN: is_dynamic_callstack = 1
181 ; NumSgprs: 48
182 ; NumVgprs: 24
183 ; GCN: ScratchSize: 16384
184 define amdgpu_kernel void @usage_external() #0 {
185   call void @external()
186   ret void
189 declare void @external_recurse() #2
191 ; GCN-LABEL: {{^}}usage_external_recurse:
192 ; GCN: is_dynamic_callstack = 1
193 ; NumSgprs: 48
194 ; NumVgprs: 24
195 ; GCN: ScratchSize: 16384
196 define amdgpu_kernel void @usage_external_recurse() #0 {
197   call void @external_recurse()
198   ret void
201 ; GCN-LABEL: {{^}}direct_recursion_use_stack:
202 ; GCN: ScratchSize: 2064
203 define void @direct_recursion_use_stack(i32 %val) #2 {
204   %alloca = alloca [512 x i32], align 4, addrspace(5)
205   call void asm sideeffect "; use $0", "v"([512 x i32] addrspace(5)* %alloca) #0
206   %cmp = icmp eq i32 %val, 0
207   br i1 %cmp, label %ret, label %call
209 call:
210   %val.sub1 = sub i32 %val, 1
211   call void @direct_recursion_use_stack(i32 %val.sub1)
212   br label %ret
214 ret:
215   ret void
218 ; GCN-LABEL: {{^}}usage_direct_recursion:
219 ; GCN: is_ptr64 = 1
220 ; GCN: is_dynamic_callstack = 1
221 ; GCN: workitem_private_segment_byte_size = 2064
222 define amdgpu_kernel void @usage_direct_recursion(i32 %n) #0 {
223   call void @direct_recursion_use_stack(i32 %n)
224   ret void
228 attributes #0 = { nounwind norecurse }
229 attributes #1 = { nounwind noinline norecurse }
230 attributes #2 = { nounwind noinline }