1 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 ; XUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
4 ; FIXME: cypress is broken because the bigger testcases spill and it's not implemented
6 ; FUNC-LABEL: {{^}}zextload_global_i16_to_i32:
7 ; SI: buffer_load_ushort
8 ; SI: buffer_store_dword
10 define amdgpu_kernel void @zextload_global_i16_to_i32(i32 addrspace(1)* %out, i16 addrspace(1)* %in) nounwind {
11 %a = load i16, i16 addrspace(1)* %in
12 %ext = zext i16 %a to i32
13 store i32 %ext, i32 addrspace(1)* %out
17 ; FUNC-LABEL: {{^}}sextload_global_i16_to_i32:
18 ; SI: buffer_load_sshort
19 ; SI: buffer_store_dword
21 define amdgpu_kernel void @sextload_global_i16_to_i32(i32 addrspace(1)* %out, i16 addrspace(1)* %in) nounwind {
22 %a = load i16, i16 addrspace(1)* %in
23 %ext = sext i16 %a to i32
24 store i32 %ext, i32 addrspace(1)* %out
28 ; FUNC-LABEL: {{^}}zextload_global_v1i16_to_v1i32:
29 ; SI: buffer_load_ushort
31 define amdgpu_kernel void @zextload_global_v1i16_to_v1i32(<1 x i32> addrspace(1)* %out, <1 x i16> addrspace(1)* nocapture %in) nounwind {
32 %load = load <1 x i16>, <1 x i16> addrspace(1)* %in
33 %ext = zext <1 x i16> %load to <1 x i32>
34 store <1 x i32> %ext, <1 x i32> addrspace(1)* %out
38 ; FUNC-LABEL: {{^}}sextload_global_v1i16_to_v1i32:
39 ; SI: buffer_load_sshort
41 define amdgpu_kernel void @sextload_global_v1i16_to_v1i32(<1 x i32> addrspace(1)* %out, <1 x i16> addrspace(1)* nocapture %in) nounwind {
42 %load = load <1 x i16>, <1 x i16> addrspace(1)* %in
43 %ext = sext <1 x i16> %load to <1 x i32>
44 store <1 x i32> %ext, <1 x i32> addrspace(1)* %out
48 ; FUNC-LABEL: {{^}}zextload_global_v2i16_to_v2i32:
50 define amdgpu_kernel void @zextload_global_v2i16_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i16> addrspace(1)* nocapture %in) nounwind {
51 %load = load <2 x i16>, <2 x i16> addrspace(1)* %in
52 %ext = zext <2 x i16> %load to <2 x i32>
53 store <2 x i32> %ext, <2 x i32> addrspace(1)* %out
57 ; FUNC-LABEL: {{^}}sextload_global_v2i16_to_v2i32:
59 define amdgpu_kernel void @sextload_global_v2i16_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x i16> addrspace(1)* nocapture %in) nounwind {
60 %load = load <2 x i16>, <2 x i16> addrspace(1)* %in
61 %ext = sext <2 x i16> %load to <2 x i32>
62 store <2 x i32> %ext, <2 x i32> addrspace(1)* %out
66 ; FUNC-LABEL: {{^}}zextload_global_v4i16_to_v4i32:
68 define amdgpu_kernel void @zextload_global_v4i16_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x i16> addrspace(1)* nocapture %in) nounwind {
69 %load = load <4 x i16>, <4 x i16> addrspace(1)* %in
70 %ext = zext <4 x i16> %load to <4 x i32>
71 store <4 x i32> %ext, <4 x i32> addrspace(1)* %out
75 ; FUNC-LABEL: {{^}}sextload_global_v4i16_to_v4i32:
77 define amdgpu_kernel void @sextload_global_v4i16_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x i16> addrspace(1)* nocapture %in) nounwind {
78 %load = load <4 x i16>, <4 x i16> addrspace(1)* %in
79 %ext = sext <4 x i16> %load to <4 x i32>
80 store <4 x i32> %ext, <4 x i32> addrspace(1)* %out
84 ; FUNC-LABEL: {{^}}zextload_global_v8i16_to_v8i32:
86 define amdgpu_kernel void @zextload_global_v8i16_to_v8i32(<8 x i32> addrspace(1)* %out, <8 x i16> addrspace(1)* nocapture %in) nounwind {
87 %load = load <8 x i16>, <8 x i16> addrspace(1)* %in
88 %ext = zext <8 x i16> %load to <8 x i32>
89 store <8 x i32> %ext, <8 x i32> addrspace(1)* %out
93 ; FUNC-LABEL: {{^}}sextload_global_v8i16_to_v8i32:
95 define amdgpu_kernel void @sextload_global_v8i16_to_v8i32(<8 x i32> addrspace(1)* %out, <8 x i16> addrspace(1)* nocapture %in) nounwind {
96 %load = load <8 x i16>, <8 x i16> addrspace(1)* %in
97 %ext = sext <8 x i16> %load to <8 x i32>
98 store <8 x i32> %ext, <8 x i32> addrspace(1)* %out
102 ; FUNC-LABEL: {{^}}zextload_global_v16i16_to_v16i32:
104 define amdgpu_kernel void @zextload_global_v16i16_to_v16i32(<16 x i32> addrspace(1)* %out, <16 x i16> addrspace(1)* nocapture %in) nounwind {
105 %load = load <16 x i16>, <16 x i16> addrspace(1)* %in
106 %ext = zext <16 x i16> %load to <16 x i32>
107 store <16 x i32> %ext, <16 x i32> addrspace(1)* %out
111 ; FUNC-LABEL: {{^}}sextload_global_v16i16_to_v16i32:
113 define amdgpu_kernel void @sextload_global_v16i16_to_v16i32(<16 x i32> addrspace(1)* %out, <16 x i16> addrspace(1)* nocapture %in) nounwind {
114 %load = load <16 x i16>, <16 x i16> addrspace(1)* %in
115 %ext = sext <16 x i16> %load to <16 x i32>
116 store <16 x i32> %ext, <16 x i32> addrspace(1)* %out
120 ; FUNC-LABEL: {{^}}zextload_global_v32i16_to_v32i32:
122 define amdgpu_kernel void @zextload_global_v32i16_to_v32i32(<32 x i32> addrspace(1)* %out, <32 x i16> addrspace(1)* nocapture %in) nounwind {
123 %load = load <32 x i16>, <32 x i16> addrspace(1)* %in
124 %ext = zext <32 x i16> %load to <32 x i32>
125 store <32 x i32> %ext, <32 x i32> addrspace(1)* %out
129 ; FUNC-LABEL: {{^}}sextload_global_v32i16_to_v32i32:
131 define amdgpu_kernel void @sextload_global_v32i16_to_v32i32(<32 x i32> addrspace(1)* %out, <32 x i16> addrspace(1)* nocapture %in) nounwind {
132 %load = load <32 x i16>, <32 x i16> addrspace(1)* %in
133 %ext = sext <32 x i16> %load to <32 x i32>
134 store <32 x i32> %ext, <32 x i32> addrspace(1)* %out
138 ; FUNC-LABEL: {{^}}zextload_global_v64i16_to_v64i32:
140 define amdgpu_kernel void @zextload_global_v64i16_to_v64i32(<64 x i32> addrspace(1)* %out, <64 x i16> addrspace(1)* nocapture %in) nounwind {
141 %load = load <64 x i16>, <64 x i16> addrspace(1)* %in
142 %ext = zext <64 x i16> %load to <64 x i32>
143 store <64 x i32> %ext, <64 x i32> addrspace(1)* %out
147 ; FUNC-LABEL: {{^}}sextload_global_v64i16_to_v64i32:
149 define amdgpu_kernel void @sextload_global_v64i16_to_v64i32(<64 x i32> addrspace(1)* %out, <64 x i16> addrspace(1)* nocapture %in) nounwind {
150 %load = load <64 x i16>, <64 x i16> addrspace(1)* %in
151 %ext = sext <64 x i16> %load to <64 x i32>
152 store <64 x i32> %ext, <64 x i32> addrspace(1)* %out
156 ; FUNC-LABEL: {{^}}zextload_global_i16_to_i64:
157 ; SI-DAG: buffer_load_ushort v[[LO:[0-9]+]],
158 ; SI-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0{{$}}
159 ; SI: buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]]
160 define amdgpu_kernel void @zextload_global_i16_to_i64(i64 addrspace(1)* %out, i16 addrspace(1)* %in) nounwind {
161 %a = load i16, i16 addrspace(1)* %in
162 %ext = zext i16 %a to i64
163 store i64 %ext, i64 addrspace(1)* %out
167 ; FUNC-LABEL: {{^}}sextload_global_i16_to_i64:
168 ; VI: buffer_load_ushort [[LOAD:v[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0
169 ; VI: v_ashrrev_i32_e32 v{{[0-9]+}}, 31, [[LOAD]]
170 ; VI: buffer_store_dwordx2 v[{{[0-9]+:[0-9]+}}], s[{{[0-9]+:[0-9]+}}], 0
171 define amdgpu_kernel void @sextload_global_i16_to_i64(i64 addrspace(1)* %out, i16 addrspace(1)* %in) nounwind {
172 %a = load i16, i16 addrspace(1)* %in
173 %ext = sext i16 %a to i64
174 store i64 %ext, i64 addrspace(1)* %out
178 ; FUNC-LABEL: {{^}}zextload_global_v1i16_to_v1i64:
180 define amdgpu_kernel void @zextload_global_v1i16_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i16> addrspace(1)* nocapture %in) nounwind {
181 %load = load <1 x i16>, <1 x i16> addrspace(1)* %in
182 %ext = zext <1 x i16> %load to <1 x i64>
183 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
187 ; FUNC-LABEL: {{^}}sextload_global_v1i16_to_v1i64:
189 define amdgpu_kernel void @sextload_global_v1i16_to_v1i64(<1 x i64> addrspace(1)* %out, <1 x i16> addrspace(1)* nocapture %in) nounwind {
190 %load = load <1 x i16>, <1 x i16> addrspace(1)* %in
191 %ext = sext <1 x i16> %load to <1 x i64>
192 store <1 x i64> %ext, <1 x i64> addrspace(1)* %out
196 ; FUNC-LABEL: {{^}}zextload_global_v2i16_to_v2i64:
198 define amdgpu_kernel void @zextload_global_v2i16_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i16> addrspace(1)* nocapture %in) nounwind {
199 %load = load <2 x i16>, <2 x i16> addrspace(1)* %in
200 %ext = zext <2 x i16> %load to <2 x i64>
201 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
205 ; FUNC-LABEL: {{^}}sextload_global_v2i16_to_v2i64:
207 define amdgpu_kernel void @sextload_global_v2i16_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x i16> addrspace(1)* nocapture %in) nounwind {
208 %load = load <2 x i16>, <2 x i16> addrspace(1)* %in
209 %ext = sext <2 x i16> %load to <2 x i64>
210 store <2 x i64> %ext, <2 x i64> addrspace(1)* %out
214 ; FUNC-LABEL: {{^}}zextload_global_v4i16_to_v4i64:
216 define amdgpu_kernel void @zextload_global_v4i16_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i16> addrspace(1)* nocapture %in) nounwind {
217 %load = load <4 x i16>, <4 x i16> addrspace(1)* %in
218 %ext = zext <4 x i16> %load to <4 x i64>
219 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
223 ; FUNC-LABEL: {{^}}sextload_global_v4i16_to_v4i64:
225 define amdgpu_kernel void @sextload_global_v4i16_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x i16> addrspace(1)* nocapture %in) nounwind {
226 %load = load <4 x i16>, <4 x i16> addrspace(1)* %in
227 %ext = sext <4 x i16> %load to <4 x i64>
228 store <4 x i64> %ext, <4 x i64> addrspace(1)* %out
232 ; FUNC-LABEL: {{^}}zextload_global_v8i16_to_v8i64:
234 define amdgpu_kernel void @zextload_global_v8i16_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i16> addrspace(1)* nocapture %in) nounwind {
235 %load = load <8 x i16>, <8 x i16> addrspace(1)* %in
236 %ext = zext <8 x i16> %load to <8 x i64>
237 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
241 ; FUNC-LABEL: {{^}}sextload_global_v8i16_to_v8i64:
243 define amdgpu_kernel void @sextload_global_v8i16_to_v8i64(<8 x i64> addrspace(1)* %out, <8 x i16> addrspace(1)* nocapture %in) nounwind {
244 %load = load <8 x i16>, <8 x i16> addrspace(1)* %in
245 %ext = sext <8 x i16> %load to <8 x i64>
246 store <8 x i64> %ext, <8 x i64> addrspace(1)* %out
250 ; FUNC-LABEL: {{^}}zextload_global_v16i16_to_v16i64:
252 define amdgpu_kernel void @zextload_global_v16i16_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i16> addrspace(1)* nocapture %in) nounwind {
253 %load = load <16 x i16>, <16 x i16> addrspace(1)* %in
254 %ext = zext <16 x i16> %load to <16 x i64>
255 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
259 ; FUNC-LABEL: {{^}}sextload_global_v16i16_to_v16i64:
261 define amdgpu_kernel void @sextload_global_v16i16_to_v16i64(<16 x i64> addrspace(1)* %out, <16 x i16> addrspace(1)* nocapture %in) nounwind {
262 %load = load <16 x i16>, <16 x i16> addrspace(1)* %in
263 %ext = sext <16 x i16> %load to <16 x i64>
264 store <16 x i64> %ext, <16 x i64> addrspace(1)* %out
268 ; FUNC-LABEL: {{^}}zextload_global_v32i16_to_v32i64:
270 define amdgpu_kernel void @zextload_global_v32i16_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i16> addrspace(1)* nocapture %in) nounwind {
271 %load = load <32 x i16>, <32 x i16> addrspace(1)* %in
272 %ext = zext <32 x i16> %load to <32 x i64>
273 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
277 ; FUNC-LABEL: {{^}}sextload_global_v32i16_to_v32i64:
279 define amdgpu_kernel void @sextload_global_v32i16_to_v32i64(<32 x i64> addrspace(1)* %out, <32 x i16> addrspace(1)* nocapture %in) nounwind {
280 %load = load <32 x i16>, <32 x i16> addrspace(1)* %in
281 %ext = sext <32 x i16> %load to <32 x i64>
282 store <32 x i64> %ext, <32 x i64> addrspace(1)* %out
286 ; FUNC-LABEL: {{^}}zextload_global_v64i16_to_v64i64:
288 define amdgpu_kernel void @zextload_global_v64i16_to_v64i64(<64 x i64> addrspace(1)* %out, <64 x i16> addrspace(1)* nocapture %in) nounwind {
289 %load = load <64 x i16>, <64 x i16> addrspace(1)* %in
290 %ext = zext <64 x i16> %load to <64 x i64>
291 store <64 x i64> %ext, <64 x i64> addrspace(1)* %out
295 ; FUNC-LABEL: {{^}}sextload_global_v64i16_to_v64i64:
297 define amdgpu_kernel void @sextload_global_v64i16_to_v64i64(<64 x i64> addrspace(1)* %out, <64 x i16> addrspace(1)* nocapture %in) nounwind {
298 %load = load <64 x i16>, <64 x i16> addrspace(1)* %in
299 %ext = sext <64 x i16> %load to <64 x i64>
300 store <64 x i64> %ext, <64 x i64> addrspace(1)* %out