1 ; RUN: llc -O0 -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=VGPR %s
2 ; RUN: llc -O0 -march=amdgcn -mcpu=fiji -amdgpu-spill-sgpr-to-vgpr=0 -verify-machineinstrs < %s | FileCheck -check-prefix=ALL -check-prefix=VMEM %s
4 ; ALL-LABEL: {{^}}spill_sgpr_x2:
6 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 0
7 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 1
10 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 0
11 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 1
14 ; VMEM: buffer_store_dword
15 ; VMEM: buffer_store_dword
16 ; VMEM: s_cbranch_scc1
18 ; VMEM: buffer_load_dword
19 ; VMEM: buffer_load_dword
20 define amdgpu_kernel void @spill_sgpr_x2(i32 addrspace(1)* %out, i32 %in) #0 {
21 %wide.sgpr = call <2 x i32> asm sideeffect "; def $0", "=s" () #0
22 %cmp = icmp eq i32 %in, 0
23 br i1 %cmp, label %bb0, label %ret
26 call void asm sideeffect "; use $0", "s"(<2 x i32> %wide.sgpr) #0
33 ; ALL-LABEL: {{^}}spill_sgpr_x3:
35 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 0
36 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 1
37 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 2
38 ; VGPR: s_cbranch_scc1
40 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 0
41 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 1
42 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 2
45 ; VMEM: buffer_store_dword
46 ; VMEM: buffer_store_dword
47 ; VMEM: buffer_store_dword
48 ; VMEM: s_cbranch_scc1
50 ; VMEM: buffer_load_dword
51 ; VMEM: buffer_load_dword
52 ; VMEM: buffer_load_dword
53 define amdgpu_kernel void @spill_sgpr_x3(i32 addrspace(1)* %out, i32 %in) #0 {
54 %wide.sgpr = call <3 x i32> asm sideeffect "; def $0", "=s" () #0
55 %cmp = icmp eq i32 %in, 0
56 br i1 %cmp, label %bb0, label %ret
59 call void asm sideeffect "; use $0", "s"(<3 x i32> %wide.sgpr) #0
66 ; ALL-LABEL: {{^}}spill_sgpr_x4:
68 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 0
69 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 1
70 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 2
71 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 3
72 ; VGPR: s_cbranch_scc1
74 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 0
75 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 1
76 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 2
77 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 3
80 ; VMEM: buffer_store_dword
81 ; VMEM: buffer_store_dword
82 ; VMEM: buffer_store_dword
83 ; VMEM: buffer_store_dword
84 ; VMEM: s_cbranch_scc1
86 ; VMEM: buffer_load_dword
87 ; VMEM: buffer_load_dword
88 ; VMEM: buffer_load_dword
89 ; VMEM: buffer_load_dword
90 define amdgpu_kernel void @spill_sgpr_x4(i32 addrspace(1)* %out, i32 %in) #0 {
91 %wide.sgpr = call <4 x i32> asm sideeffect "; def $0", "=s" () #0
92 %cmp = icmp eq i32 %in, 0
93 br i1 %cmp, label %bb0, label %ret
96 call void asm sideeffect "; use $0", "s"(<4 x i32> %wide.sgpr) #0
103 ; ALL-LABEL: {{^}}spill_sgpr_x5:
105 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 0
106 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 1
107 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 2
108 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 3
109 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 4
110 ; VGPR: s_cbranch_scc1
112 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 0
113 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 1
114 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 2
115 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 3
116 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 4
119 ; VMEM: buffer_store_dword
120 ; VMEM: buffer_store_dword
121 ; VMEM: buffer_store_dword
122 ; VMEM: buffer_store_dword
123 ; VMEM: buffer_store_dword
124 ; VMEM: s_cbranch_scc1
126 ; VMEM: buffer_load_dword
127 ; VMEM: buffer_load_dword
128 ; VMEM: buffer_load_dword
129 ; VMEM: buffer_load_dword
130 ; VMEM: buffer_load_dword
131 define amdgpu_kernel void @spill_sgpr_x5(i32 addrspace(1)* %out, i32 %in) #0 {
132 %wide.sgpr = call <5 x i32> asm sideeffect "; def $0", "=s" () #0
133 %cmp = icmp eq i32 %in, 0
134 br i1 %cmp, label %bb0, label %ret
137 call void asm sideeffect "; use $0", "s"(<5 x i32> %wide.sgpr) #0
144 ; ALL-LABEL: {{^}}spill_sgpr_x8:
146 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 0
147 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 1
148 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 2
149 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 3
150 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 4
151 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 5
152 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 6
153 ; VGPR: v_writelane_b32 v{{[0-9]+}}, s{{[0-9]+}}, 7
154 ; VGPR: s_cbranch_scc1
156 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 0
157 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 1
158 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 2
159 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 3
160 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 4
161 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 5
162 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 6
163 ; VGPR: v_readlane_b32 s{{[0-9]+}}, v{{[0-9]+}}, 7
165 ; VMEM: buffer_store_dword
166 ; VMEM: buffer_store_dword
167 ; VMEM: buffer_store_dword
168 ; VMEM: buffer_store_dword
169 ; VMEM: buffer_store_dword
170 ; VMEM: buffer_store_dword
171 ; VMEM: buffer_store_dword
172 ; VMEM: buffer_store_dword
173 ; VMEM: s_cbranch_scc1
175 ; VMEM: buffer_load_dword
176 ; VMEM: buffer_load_dword
177 ; VMEM: buffer_load_dword
178 ; VMEM: buffer_load_dword
179 ; VMEM: buffer_load_dword
180 ; VMEM: buffer_load_dword
181 ; VMEM: buffer_load_dword
182 ; VMEM: buffer_load_dword
183 define amdgpu_kernel void @spill_sgpr_x8(i32 addrspace(1)* %out, i32 %in) #0 {
184 %wide.sgpr = call <8 x i32> asm sideeffect "; def $0", "=s" () #0
185 %cmp = icmp eq i32 %in, 0
186 br i1 %cmp, label %bb0, label %ret
189 call void asm sideeffect "; use $0", "s"(<8 x i32> %wide.sgpr) #0
196 ; FIXME: x16 inlineasm seems broken
197 ; define amdgpu_kernel void @spill_sgpr_x16(i32 addrspace(1)* %out, i32 %in) #0 {
198 ; %wide.sgpr = call <16 x i32> asm sideeffect "; def $0", "=s" () #0
199 ; %cmp = icmp eq i32 %in, 0
200 ; br i1 %cmp, label %bb0, label %ret
203 ; call void asm sideeffect "; use $0", "s"(<16 x i32> %wide.sgpr) #0
210 attributes #0 = { nounwind }