1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX6 %s
3 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX8 %s
4 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GFX9 %s
6 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone speculatable
8 define amdgpu_kernel void @s_sub_i32(ptr addrspace(1) %out, i32 %a, i32 %b) {
9 ; GFX6-LABEL: s_sub_i32:
11 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
12 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
13 ; GFX6-NEXT: s_mov_b32 s6, -1
14 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
15 ; GFX6-NEXT: s_mov_b32 s4, s0
16 ; GFX6-NEXT: s_sub_i32 s0, s2, s3
17 ; GFX6-NEXT: s_mov_b32 s5, s1
18 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
19 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
22 ; GFX8-LABEL: s_sub_i32:
24 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
25 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
26 ; GFX8-NEXT: s_sub_i32 s2, s2, s3
27 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
28 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
29 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
30 ; GFX8-NEXT: flat_store_dword v[0:1], v2
33 ; GFX9-LABEL: s_sub_i32:
35 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
36 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
37 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
38 ; GFX9-NEXT: s_sub_i32 s2, s2, s3
39 ; GFX9-NEXT: v_mov_b32_e32 v1, s2
40 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
42 %result = sub i32 %a, %b
43 store i32 %result, ptr addrspace(1) %out
47 define amdgpu_kernel void @s_sub_imm_i32(ptr addrspace(1) %out, i32 %a) {
48 ; GFX6-LABEL: s_sub_imm_i32:
50 ; GFX6-NEXT: s_load_dword s4, s[0:1], 0xb
51 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
52 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
53 ; GFX6-NEXT: s_mov_b32 s2, -1
54 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
55 ; GFX6-NEXT: s_sub_i32 s4, 0x4d2, s4
56 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
57 ; GFX6-NEXT: buffer_store_dword v0, off, s[0:3], 0
60 ; GFX8-LABEL: s_sub_imm_i32:
62 ; GFX8-NEXT: s_load_dword s2, s[0:1], 0x2c
63 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x24
64 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
65 ; GFX8-NEXT: s_sub_i32 s2, 0x4d2, s2
66 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
67 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
68 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
69 ; GFX8-NEXT: flat_store_dword v[0:1], v2
72 ; GFX9-LABEL: s_sub_imm_i32:
74 ; GFX9-NEXT: s_load_dword s4, s[0:1], 0x2c
75 ; GFX9-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
76 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
77 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
78 ; GFX9-NEXT: s_sub_i32 s0, 0x4d2, s4
79 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
80 ; GFX9-NEXT: global_store_dword v0, v1, s[2:3]
82 %result = sub i32 1234, %a
83 store i32 %result, ptr addrspace(1) %out
87 define amdgpu_kernel void @test_sub_i32(ptr addrspace(1) %out, ptr addrspace(1) %in) {
88 ; GFX6-LABEL: test_sub_i32:
90 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
91 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
92 ; GFX6-NEXT: s_mov_b32 s6, -1
93 ; GFX6-NEXT: s_mov_b32 s10, s6
94 ; GFX6-NEXT: s_mov_b32 s11, s7
95 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
96 ; GFX6-NEXT: s_mov_b32 s8, s2
97 ; GFX6-NEXT: s_mov_b32 s9, s3
98 ; GFX6-NEXT: buffer_load_dwordx2 v[0:1], off, s[8:11], 0
99 ; GFX6-NEXT: s_mov_b32 s4, s0
100 ; GFX6-NEXT: s_mov_b32 s5, s1
101 ; GFX6-NEXT: s_waitcnt vmcnt(0)
102 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v1
103 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
104 ; GFX6-NEXT: s_endpgm
106 ; GFX8-LABEL: test_sub_i32:
108 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
109 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
110 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
111 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
112 ; GFX8-NEXT: flat_load_dwordx2 v[0:1], v[0:1]
113 ; GFX8-NEXT: v_mov_b32_e32 v2, s0
114 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
115 ; GFX8-NEXT: s_waitcnt vmcnt(0)
116 ; GFX8-NEXT: v_sub_u32_e32 v0, vcc, v0, v1
117 ; GFX8-NEXT: flat_store_dword v[2:3], v0
118 ; GFX8-NEXT: s_endpgm
120 ; GFX9-LABEL: test_sub_i32:
122 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
123 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
124 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
125 ; GFX9-NEXT: global_load_dwordx2 v[0:1], v2, s[2:3]
126 ; GFX9-NEXT: s_waitcnt vmcnt(0)
127 ; GFX9-NEXT: v_sub_u32_e32 v0, v0, v1
128 ; GFX9-NEXT: global_store_dword v2, v0, s[0:1]
129 ; GFX9-NEXT: s_endpgm
130 %b_ptr = getelementptr i32, ptr addrspace(1) %in, i32 1
131 %a = load i32, ptr addrspace(1) %in
132 %b = load i32, ptr addrspace(1) %b_ptr
133 %result = sub i32 %a, %b
134 store i32 %result, ptr addrspace(1) %out
138 define amdgpu_kernel void @test_sub_imm_i32(ptr addrspace(1) %out, ptr addrspace(1) %in) {
139 ; GFX6-LABEL: test_sub_imm_i32:
141 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
142 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
143 ; GFX6-NEXT: s_mov_b32 s6, -1
144 ; GFX6-NEXT: s_mov_b32 s10, s6
145 ; GFX6-NEXT: s_mov_b32 s11, s7
146 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
147 ; GFX6-NEXT: s_mov_b32 s8, s2
148 ; GFX6-NEXT: s_mov_b32 s9, s3
149 ; GFX6-NEXT: buffer_load_dword v0, off, s[8:11], 0
150 ; GFX6-NEXT: s_mov_b32 s4, s0
151 ; GFX6-NEXT: s_mov_b32 s5, s1
152 ; GFX6-NEXT: s_waitcnt vmcnt(0)
153 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, 0x7b, v0
154 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
155 ; GFX6-NEXT: s_endpgm
157 ; GFX8-LABEL: test_sub_imm_i32:
159 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
160 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
161 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
162 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
163 ; GFX8-NEXT: flat_load_dword v2, v[0:1]
164 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
165 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
166 ; GFX8-NEXT: s_waitcnt vmcnt(0)
167 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, 0x7b, v2
168 ; GFX8-NEXT: flat_store_dword v[0:1], v2
169 ; GFX8-NEXT: s_endpgm
171 ; GFX9-LABEL: test_sub_imm_i32:
173 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
174 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
175 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
176 ; GFX9-NEXT: global_load_dword v1, v0, s[2:3]
177 ; GFX9-NEXT: s_waitcnt vmcnt(0)
178 ; GFX9-NEXT: v_sub_u32_e32 v1, 0x7b, v1
179 ; GFX9-NEXT: global_store_dword v0, v1, s[0:1]
180 ; GFX9-NEXT: s_endpgm
181 %a = load i32, ptr addrspace(1) %in
182 %result = sub i32 123, %a
183 store i32 %result, ptr addrspace(1) %out
187 define amdgpu_kernel void @test_sub_v2i32(ptr addrspace(1) %out, ptr addrspace(1) %in) {
188 ; GFX6-LABEL: test_sub_v2i32:
190 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
191 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
192 ; GFX6-NEXT: s_mov_b32 s6, -1
193 ; GFX6-NEXT: s_mov_b32 s10, s6
194 ; GFX6-NEXT: s_mov_b32 s11, s7
195 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
196 ; GFX6-NEXT: s_mov_b32 s8, s2
197 ; GFX6-NEXT: s_mov_b32 s9, s3
198 ; GFX6-NEXT: buffer_load_dwordx4 v[0:3], off, s[8:11], 0
199 ; GFX6-NEXT: s_mov_b32 s4, s0
200 ; GFX6-NEXT: s_mov_b32 s5, s1
201 ; GFX6-NEXT: s_waitcnt vmcnt(0)
202 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v3
203 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v2
204 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
205 ; GFX6-NEXT: s_endpgm
207 ; GFX8-LABEL: test_sub_v2i32:
209 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
210 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
211 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
212 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
213 ; GFX8-NEXT: flat_load_dwordx4 v[0:3], v[0:1]
214 ; GFX8-NEXT: v_mov_b32_e32 v4, s0
215 ; GFX8-NEXT: v_mov_b32_e32 v5, s1
216 ; GFX8-NEXT: s_waitcnt vmcnt(0)
217 ; GFX8-NEXT: v_sub_u32_e32 v1, vcc, v1, v3
218 ; GFX8-NEXT: v_sub_u32_e32 v0, vcc, v0, v2
219 ; GFX8-NEXT: flat_store_dwordx2 v[4:5], v[0:1]
220 ; GFX8-NEXT: s_endpgm
222 ; GFX9-LABEL: test_sub_v2i32:
224 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
225 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
226 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
227 ; GFX9-NEXT: global_load_dwordx4 v[0:3], v4, s[2:3]
228 ; GFX9-NEXT: s_waitcnt vmcnt(0)
229 ; GFX9-NEXT: v_sub_u32_e32 v1, v1, v3
230 ; GFX9-NEXT: v_sub_u32_e32 v0, v0, v2
231 ; GFX9-NEXT: global_store_dwordx2 v4, v[0:1], s[0:1]
232 ; GFX9-NEXT: s_endpgm
233 %b_ptr = getelementptr <2 x i32>, ptr addrspace(1) %in, i32 1
234 %a = load <2 x i32>, ptr addrspace(1) %in
235 %b = load <2 x i32>, ptr addrspace(1) %b_ptr
236 %result = sub <2 x i32> %a, %b
237 store <2 x i32> %result, ptr addrspace(1) %out
241 define amdgpu_kernel void @test_sub_v4i32(ptr addrspace(1) %out, ptr addrspace(1) %in) {
242 ; GFX6-LABEL: test_sub_v4i32:
244 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
245 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
246 ; GFX6-NEXT: s_mov_b32 s6, -1
247 ; GFX6-NEXT: s_mov_b32 s10, s6
248 ; GFX6-NEXT: s_mov_b32 s11, s7
249 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
250 ; GFX6-NEXT: s_mov_b32 s8, s2
251 ; GFX6-NEXT: s_mov_b32 s9, s3
252 ; GFX6-NEXT: buffer_load_dwordx4 v[0:3], off, s[8:11], 0
253 ; GFX6-NEXT: buffer_load_dwordx4 v[4:7], off, s[8:11], 0 offset:16
254 ; GFX6-NEXT: s_mov_b32 s4, s0
255 ; GFX6-NEXT: s_mov_b32 s5, s1
256 ; GFX6-NEXT: s_waitcnt vmcnt(0)
257 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, v3, v7
258 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, v2, v6
259 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v5
260 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v4
261 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[4:7], 0
262 ; GFX6-NEXT: s_endpgm
264 ; GFX8-LABEL: test_sub_v4i32:
266 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
267 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
268 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
269 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
270 ; GFX8-NEXT: s_add_u32 s2, s2, 16
271 ; GFX8-NEXT: s_addc_u32 s3, s3, 0
272 ; GFX8-NEXT: v_mov_b32_e32 v5, s3
273 ; GFX8-NEXT: v_mov_b32_e32 v4, s2
274 ; GFX8-NEXT: flat_load_dwordx4 v[0:3], v[0:1]
275 ; GFX8-NEXT: flat_load_dwordx4 v[4:7], v[4:5]
276 ; GFX8-NEXT: v_mov_b32_e32 v8, s0
277 ; GFX8-NEXT: v_mov_b32_e32 v9, s1
278 ; GFX8-NEXT: s_waitcnt vmcnt(0)
279 ; GFX8-NEXT: v_sub_u32_e32 v3, vcc, v3, v7
280 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, v2, v6
281 ; GFX8-NEXT: v_sub_u32_e32 v1, vcc, v1, v5
282 ; GFX8-NEXT: v_sub_u32_e32 v0, vcc, v0, v4
283 ; GFX8-NEXT: flat_store_dwordx4 v[8:9], v[0:3]
284 ; GFX8-NEXT: s_endpgm
286 ; GFX9-LABEL: test_sub_v4i32:
288 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
289 ; GFX9-NEXT: v_mov_b32_e32 v8, 0
290 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
291 ; GFX9-NEXT: global_load_dwordx4 v[0:3], v8, s[2:3] offset:16
292 ; GFX9-NEXT: global_load_dwordx4 v[4:7], v8, s[2:3]
293 ; GFX9-NEXT: s_waitcnt vmcnt(0)
294 ; GFX9-NEXT: v_sub_u32_e32 v3, v7, v3
295 ; GFX9-NEXT: v_sub_u32_e32 v2, v6, v2
296 ; GFX9-NEXT: v_sub_u32_e32 v1, v5, v1
297 ; GFX9-NEXT: v_sub_u32_e32 v0, v4, v0
298 ; GFX9-NEXT: global_store_dwordx4 v8, v[0:3], s[0:1]
299 ; GFX9-NEXT: s_endpgm
300 %b_ptr = getelementptr <4 x i32>, ptr addrspace(1) %in, i32 1
301 %a = load <4 x i32>, ptr addrspace(1) %in
302 %b = load <4 x i32>, ptr addrspace(1) %b_ptr
303 %result = sub <4 x i32> %a, %b
304 store <4 x i32> %result, ptr addrspace(1) %out
308 define amdgpu_kernel void @test_sub_i16(ptr addrspace(1) %out, ptr addrspace(1) %in) {
309 ; GFX6-LABEL: test_sub_i16:
311 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
312 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
313 ; GFX6-NEXT: s_mov_b32 s10, 0
314 ; GFX6-NEXT: s_mov_b32 s11, s7
315 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 1, v0
316 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
317 ; GFX6-NEXT: s_mov_b64 s[8:9], s[2:3]
318 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
319 ; GFX6-NEXT: buffer_load_ushort v2, v[0:1], s[8:11], 0 addr64 glc
320 ; GFX6-NEXT: s_waitcnt vmcnt(0)
321 ; GFX6-NEXT: buffer_load_ushort v0, v[0:1], s[8:11], 0 addr64 offset:2 glc
322 ; GFX6-NEXT: s_waitcnt vmcnt(0)
323 ; GFX6-NEXT: s_mov_b32 s6, -1
324 ; GFX6-NEXT: s_mov_b32 s4, s0
325 ; GFX6-NEXT: s_mov_b32 s5, s1
326 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v2, v0
327 ; GFX6-NEXT: buffer_store_short v0, off, s[4:7], 0
328 ; GFX6-NEXT: s_endpgm
330 ; GFX8-LABEL: test_sub_i16:
332 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
333 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 1, v0
334 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
335 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
336 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s2, v0
337 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
338 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, 2, v0
339 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
340 ; GFX8-NEXT: flat_load_ushort v4, v[0:1] glc
341 ; GFX8-NEXT: s_waitcnt vmcnt(0)
342 ; GFX8-NEXT: flat_load_ushort v2, v[2:3] glc
343 ; GFX8-NEXT: s_waitcnt vmcnt(0)
344 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
345 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
346 ; GFX8-NEXT: v_sub_u16_e32 v2, v4, v2
347 ; GFX8-NEXT: flat_store_short v[0:1], v2
348 ; GFX8-NEXT: s_endpgm
350 ; GFX9-LABEL: test_sub_i16:
352 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
353 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 1, v0
354 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
355 ; GFX9-NEXT: global_load_ushort v1, v0, s[2:3] glc
356 ; GFX9-NEXT: s_waitcnt vmcnt(0)
357 ; GFX9-NEXT: global_load_ushort v2, v0, s[2:3] offset:2 glc
358 ; GFX9-NEXT: s_waitcnt vmcnt(0)
359 ; GFX9-NEXT: v_mov_b32_e32 v0, 0
360 ; GFX9-NEXT: v_sub_u16_e32 v1, v1, v2
361 ; GFX9-NEXT: global_store_short v0, v1, s[0:1]
362 ; GFX9-NEXT: s_endpgm
363 %tid = call i32 @llvm.amdgcn.workitem.id.x()
364 %gep = getelementptr i16, ptr addrspace(1) %in, i32 %tid
365 %b_ptr = getelementptr i16, ptr addrspace(1) %gep, i32 1
366 %a = load volatile i16, ptr addrspace(1) %gep
367 %b = load volatile i16, ptr addrspace(1) %b_ptr
368 %result = sub i16 %a, %b
369 store i16 %result, ptr addrspace(1) %out
373 define amdgpu_kernel void @test_sub_v2i16(ptr addrspace(1) %out, ptr addrspace(1) %in) {
374 ; GFX6-LABEL: test_sub_v2i16:
376 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
377 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
378 ; GFX6-NEXT: s_mov_b32 s10, 0
379 ; GFX6-NEXT: s_mov_b32 s11, s7
380 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 2, v0
381 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
382 ; GFX6-NEXT: s_mov_b64 s[8:9], s[2:3]
383 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
384 ; GFX6-NEXT: buffer_load_dwordx2 v[0:1], v[0:1], s[8:11], 0 addr64
385 ; GFX6-NEXT: s_mov_b32 s6, -1
386 ; GFX6-NEXT: s_mov_b32 s4, s0
387 ; GFX6-NEXT: s_mov_b32 s5, s1
388 ; GFX6-NEXT: s_waitcnt vmcnt(0)
389 ; GFX6-NEXT: v_lshrrev_b32_e32 v2, 16, v0
390 ; GFX6-NEXT: v_lshrrev_b32_e32 v3, 16, v1
391 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v1
392 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v2, v3
393 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
394 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
395 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
396 ; GFX6-NEXT: buffer_store_dword v0, off, s[4:7], 0
397 ; GFX6-NEXT: s_endpgm
399 ; GFX8-LABEL: test_sub_v2i16:
401 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
402 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 2, v0
403 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
404 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
405 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s2, v0
406 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
407 ; GFX8-NEXT: flat_load_dwordx2 v[0:1], v[0:1]
408 ; GFX8-NEXT: v_mov_b32_e32 v2, s0
409 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
410 ; GFX8-NEXT: s_waitcnt vmcnt(0)
411 ; GFX8-NEXT: v_sub_u16_e32 v4, v0, v1
412 ; GFX8-NEXT: v_sub_u16_sdwa v0, v0, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
413 ; GFX8-NEXT: v_or_b32_e32 v0, v4, v0
414 ; GFX8-NEXT: flat_store_dword v[2:3], v0
415 ; GFX8-NEXT: s_endpgm
417 ; GFX9-LABEL: test_sub_v2i16:
419 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
420 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 2, v0
421 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
422 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
423 ; GFX9-NEXT: global_load_dwordx2 v[0:1], v0, s[2:3]
424 ; GFX9-NEXT: s_waitcnt vmcnt(0)
425 ; GFX9-NEXT: v_pk_sub_i16 v0, v0, v1
426 ; GFX9-NEXT: global_store_dword v2, v0, s[0:1]
427 ; GFX9-NEXT: s_endpgm
428 %tid = call i32 @llvm.amdgcn.workitem.id.x()
429 %gep = getelementptr <2 x i16>, ptr addrspace(1) %in, i32 %tid
430 %b_ptr = getelementptr <2 x i16>, ptr addrspace(1) %gep, i16 1
431 %a = load <2 x i16>, ptr addrspace(1) %gep
432 %b = load <2 x i16>, ptr addrspace(1) %b_ptr
433 %result = sub <2 x i16> %a, %b
434 store <2 x i16> %result, ptr addrspace(1) %out
438 define amdgpu_kernel void @test_sub_v4i16(ptr addrspace(1) %out, ptr addrspace(1) %in) {
439 ; GFX6-LABEL: test_sub_v4i16:
441 ; GFX6-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x9
442 ; GFX6-NEXT: s_mov_b32 s7, 0xf000
443 ; GFX6-NEXT: s_mov_b32 s10, 0
444 ; GFX6-NEXT: s_mov_b32 s11, s7
445 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 3, v0
446 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
447 ; GFX6-NEXT: s_mov_b64 s[8:9], s[2:3]
448 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
449 ; GFX6-NEXT: buffer_load_dwordx4 v[0:3], v[0:1], s[8:11], 0 addr64
450 ; GFX6-NEXT: s_mov_b32 s6, -1
451 ; GFX6-NEXT: s_mov_b32 s4, s0
452 ; GFX6-NEXT: s_mov_b32 s5, s1
453 ; GFX6-NEXT: s_waitcnt vmcnt(0)
454 ; GFX6-NEXT: v_lshrrev_b32_e32 v4, 16, v0
455 ; GFX6-NEXT: v_lshrrev_b32_e32 v5, 16, v1
456 ; GFX6-NEXT: v_lshrrev_b32_e32 v6, 16, v2
457 ; GFX6-NEXT: v_lshrrev_b32_e32 v7, 16, v3
458 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, v1, v3
459 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v2
460 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, v5, v7
461 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, v4, v6
462 ; GFX6-NEXT: v_and_b32_e32 v1, 0xffff, v1
463 ; GFX6-NEXT: v_and_b32_e32 v0, 0xffff, v0
464 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
465 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
466 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
467 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v3
468 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[4:7], 0
469 ; GFX6-NEXT: s_endpgm
471 ; GFX8-LABEL: test_sub_v4i16:
473 ; GFX8-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
474 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 3, v0
475 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
476 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
477 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s2, v0
478 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
479 ; GFX8-NEXT: flat_load_dwordx4 v[0:3], v[0:1]
480 ; GFX8-NEXT: v_mov_b32_e32 v4, s0
481 ; GFX8-NEXT: v_mov_b32_e32 v5, s1
482 ; GFX8-NEXT: s_waitcnt vmcnt(0)
483 ; GFX8-NEXT: v_sub_u16_e32 v6, v1, v3
484 ; GFX8-NEXT: v_sub_u16_sdwa v1, v1, v3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
485 ; GFX8-NEXT: v_sub_u16_e32 v3, v0, v2
486 ; GFX8-NEXT: v_sub_u16_sdwa v0, v0, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:WORD_1
487 ; GFX8-NEXT: v_or_b32_e32 v1, v6, v1
488 ; GFX8-NEXT: v_or_b32_e32 v0, v3, v0
489 ; GFX8-NEXT: flat_store_dwordx2 v[4:5], v[0:1]
490 ; GFX8-NEXT: s_endpgm
492 ; GFX9-LABEL: test_sub_v4i16:
494 ; GFX9-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x24
495 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 3, v0
496 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
497 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
498 ; GFX9-NEXT: global_load_dwordx4 v[0:3], v0, s[2:3]
499 ; GFX9-NEXT: s_waitcnt vmcnt(0)
500 ; GFX9-NEXT: v_pk_sub_i16 v1, v1, v3
501 ; GFX9-NEXT: v_pk_sub_i16 v0, v0, v2
502 ; GFX9-NEXT: global_store_dwordx2 v4, v[0:1], s[0:1]
503 ; GFX9-NEXT: s_endpgm
504 %tid = call i32 @llvm.amdgcn.workitem.id.x()
505 %gep = getelementptr <4 x i16>, ptr addrspace(1) %in, i32 %tid
506 %b_ptr = getelementptr <4 x i16>, ptr addrspace(1) %gep, i16 1
507 %a = load <4 x i16>, ptr addrspace(1) %gep
508 %b = load <4 x i16>, ptr addrspace(1) %b_ptr
509 %result = sub <4 x i16> %a, %b
510 store <4 x i16> %result, ptr addrspace(1) %out
514 define amdgpu_kernel void @s_sub_i64(ptr addrspace(1) noalias %out, i64 %a, i64 %b) nounwind {
515 ; GFX6-LABEL: s_sub_i64:
517 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0xb
518 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x9
519 ; GFX6-NEXT: s_mov_b32 s3, 0xf000
520 ; GFX6-NEXT: s_mov_b32 s2, -1
521 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
522 ; GFX6-NEXT: s_sub_u32 s4, s4, s6
523 ; GFX6-NEXT: s_subb_u32 s5, s5, s7
524 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
525 ; GFX6-NEXT: v_mov_b32_e32 v1, s5
526 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[0:3], 0
527 ; GFX6-NEXT: s_endpgm
529 ; GFX8-LABEL: s_sub_i64:
531 ; GFX8-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
532 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x24
533 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
534 ; GFX8-NEXT: s_sub_u32 s2, s4, s6
535 ; GFX8-NEXT: s_subb_u32 s3, s5, s7
536 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
537 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
538 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
539 ; GFX8-NEXT: v_mov_b32_e32 v3, s3
540 ; GFX8-NEXT: flat_store_dwordx2 v[0:1], v[2:3]
541 ; GFX8-NEXT: s_endpgm
543 ; GFX9-LABEL: s_sub_i64:
545 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x2c
546 ; GFX9-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x24
547 ; GFX9-NEXT: v_mov_b32_e32 v2, 0
548 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
549 ; GFX9-NEXT: s_sub_u32 s0, s4, s6
550 ; GFX9-NEXT: s_subb_u32 s1, s5, s7
551 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
552 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
553 ; GFX9-NEXT: global_store_dwordx2 v2, v[0:1], s[2:3]
554 ; GFX9-NEXT: s_endpgm
555 %result = sub i64 %a, %b
556 store i64 %result, ptr addrspace(1) %out, align 8
560 define amdgpu_kernel void @v_sub_i64(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %inA, ptr addrspace(1) noalias %inB) nounwind {
561 ; GFX6-LABEL: v_sub_i64:
563 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
564 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
565 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
566 ; GFX6-NEXT: s_mov_b32 s14, 0
567 ; GFX6-NEXT: s_mov_b32 s15, s11
568 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 3, v0
569 ; GFX6-NEXT: v_mov_b32_e32 v1, 0
570 ; GFX6-NEXT: s_mov_b64 s[2:3], s[14:15]
571 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
572 ; GFX6-NEXT: s_mov_b64 s[12:13], s[6:7]
573 ; GFX6-NEXT: buffer_load_dwordx2 v[2:3], v[0:1], s[0:3], 0 addr64
574 ; GFX6-NEXT: buffer_load_dwordx2 v[0:1], v[0:1], s[12:15], 0 addr64
575 ; GFX6-NEXT: s_mov_b32 s10, -1
576 ; GFX6-NEXT: s_mov_b32 s8, s4
577 ; GFX6-NEXT: s_mov_b32 s9, s5
578 ; GFX6-NEXT: s_waitcnt vmcnt(0)
579 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v2
580 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v3, vcc
581 ; GFX6-NEXT: buffer_store_dwordx2 v[0:1], off, s[8:11], 0
582 ; GFX6-NEXT: s_endpgm
584 ; GFX8-LABEL: v_sub_i64:
586 ; GFX8-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
587 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x34
588 ; GFX8-NEXT: v_lshlrev_b32_e32 v2, 3, v0
589 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
590 ; GFX8-NEXT: v_mov_b32_e32 v1, s7
591 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s6, v2
592 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
593 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
594 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, s0, v2
595 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, 0, v3, vcc
596 ; GFX8-NEXT: flat_load_dwordx2 v[0:1], v[0:1]
597 ; GFX8-NEXT: flat_load_dwordx2 v[2:3], v[2:3]
598 ; GFX8-NEXT: s_waitcnt vmcnt(0)
599 ; GFX8-NEXT: v_sub_u32_e32 v0, vcc, v0, v2
600 ; GFX8-NEXT: v_subb_u32_e32 v1, vcc, v1, v3, vcc
601 ; GFX8-NEXT: v_mov_b32_e32 v2, s4
602 ; GFX8-NEXT: v_mov_b32_e32 v3, s5
603 ; GFX8-NEXT: flat_store_dwordx2 v[2:3], v[0:1]
604 ; GFX8-NEXT: s_endpgm
606 ; GFX9-LABEL: v_sub_i64:
608 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
609 ; GFX9-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
610 ; GFX9-NEXT: v_lshlrev_b32_e32 v4, 3, v0
611 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
612 ; GFX9-NEXT: global_load_dwordx2 v[0:1], v4, s[6:7]
613 ; GFX9-NEXT: global_load_dwordx2 v[2:3], v4, s[2:3]
614 ; GFX9-NEXT: v_mov_b32_e32 v4, 0
615 ; GFX9-NEXT: s_waitcnt vmcnt(0)
616 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, v0, v2
617 ; GFX9-NEXT: v_subb_co_u32_e32 v1, vcc, v1, v3, vcc
618 ; GFX9-NEXT: global_store_dwordx2 v4, v[0:1], s[4:5]
619 ; GFX9-NEXT: s_endpgm
620 %tid = call i32 @llvm.amdgcn.workitem.id.x() readnone
621 %a_ptr = getelementptr i64, ptr addrspace(1) %inA, i32 %tid
622 %b_ptr = getelementptr i64, ptr addrspace(1) %inB, i32 %tid
623 %a = load i64, ptr addrspace(1) %a_ptr
624 %b = load i64, ptr addrspace(1) %b_ptr
625 %result = sub i64 %a, %b
626 store i64 %result, ptr addrspace(1) %out, align 8
630 define amdgpu_kernel void @v_test_sub_v2i64(ptr addrspace(1) %out, ptr addrspace(1) noalias %inA, ptr addrspace(1) noalias %inB) {
631 ; GFX6-LABEL: v_test_sub_v2i64:
633 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
634 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
635 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
636 ; GFX6-NEXT: s_mov_b32 s14, 0
637 ; GFX6-NEXT: s_mov_b32 s15, s11
638 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 4, v0
639 ; GFX6-NEXT: v_mov_b32_e32 v5, 0
640 ; GFX6-NEXT: s_mov_b64 s[2:3], s[14:15]
641 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
642 ; GFX6-NEXT: s_mov_b64 s[12:13], s[6:7]
643 ; GFX6-NEXT: buffer_load_dwordx4 v[0:3], v[4:5], s[0:3], 0 addr64
644 ; GFX6-NEXT: buffer_load_dwordx4 v[4:7], v[4:5], s[12:15], 0 addr64
645 ; GFX6-NEXT: s_mov_b32 s10, -1
646 ; GFX6-NEXT: s_mov_b32 s8, s4
647 ; GFX6-NEXT: s_mov_b32 s9, s5
648 ; GFX6-NEXT: s_waitcnt vmcnt(0)
649 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, v6, v2
650 ; GFX6-NEXT: v_subb_u32_e32 v3, vcc, v7, v3, vcc
651 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v4, v0
652 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v5, v1, vcc
653 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[8:11], 0
654 ; GFX6-NEXT: s_endpgm
656 ; GFX8-LABEL: v_test_sub_v2i64:
658 ; GFX8-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
659 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x34
660 ; GFX8-NEXT: v_lshlrev_b32_e32 v2, 4, v0
661 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
662 ; GFX8-NEXT: v_mov_b32_e32 v1, s7
663 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s6, v2
664 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, 0, v1, vcc
665 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
666 ; GFX8-NEXT: v_add_u32_e32 v4, vcc, s0, v2
667 ; GFX8-NEXT: v_addc_u32_e32 v5, vcc, 0, v3, vcc
668 ; GFX8-NEXT: flat_load_dwordx4 v[0:3], v[0:1]
669 ; GFX8-NEXT: flat_load_dwordx4 v[4:7], v[4:5]
670 ; GFX8-NEXT: s_waitcnt vmcnt(0)
671 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, v2, v6
672 ; GFX8-NEXT: v_subb_u32_e32 v3, vcc, v3, v7, vcc
673 ; GFX8-NEXT: v_sub_u32_e32 v0, vcc, v0, v4
674 ; GFX8-NEXT: v_subb_u32_e32 v1, vcc, v1, v5, vcc
675 ; GFX8-NEXT: v_mov_b32_e32 v4, s4
676 ; GFX8-NEXT: v_mov_b32_e32 v5, s5
677 ; GFX8-NEXT: flat_store_dwordx4 v[4:5], v[0:3]
678 ; GFX8-NEXT: s_endpgm
680 ; GFX9-LABEL: v_test_sub_v2i64:
682 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
683 ; GFX9-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
684 ; GFX9-NEXT: v_lshlrev_b32_e32 v8, 4, v0
685 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
686 ; GFX9-NEXT: global_load_dwordx4 v[0:3], v8, s[6:7]
687 ; GFX9-NEXT: global_load_dwordx4 v[4:7], v8, s[2:3]
688 ; GFX9-NEXT: v_mov_b32_e32 v8, 0
689 ; GFX9-NEXT: s_waitcnt vmcnt(0)
690 ; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, v2, v6
691 ; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v3, v7, vcc
692 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, v0, v4
693 ; GFX9-NEXT: v_subb_co_u32_e32 v1, vcc, v1, v5, vcc
694 ; GFX9-NEXT: global_store_dwordx4 v8, v[0:3], s[4:5]
695 ; GFX9-NEXT: s_endpgm
696 %tid = call i32 @llvm.amdgcn.workitem.id.x() readnone
697 %a_ptr = getelementptr <2 x i64>, ptr addrspace(1) %inA, i32 %tid
698 %b_ptr = getelementptr <2 x i64>, ptr addrspace(1) %inB, i32 %tid
699 %a = load <2 x i64>, ptr addrspace(1) %a_ptr
700 %b = load <2 x i64>, ptr addrspace(1) %b_ptr
701 %result = sub <2 x i64> %a, %b
702 store <2 x i64> %result, ptr addrspace(1) %out
706 define amdgpu_kernel void @v_test_sub_v4i64(ptr addrspace(1) %out, ptr addrspace(1) noalias %inA, ptr addrspace(1) noalias %inB) {
707 ; GFX6-LABEL: v_test_sub_v4i64:
709 ; GFX6-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x9
710 ; GFX6-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0xd
711 ; GFX6-NEXT: s_mov_b32 s11, 0xf000
712 ; GFX6-NEXT: s_mov_b32 s14, 0
713 ; GFX6-NEXT: s_mov_b32 s15, s11
714 ; GFX6-NEXT: s_waitcnt lgkmcnt(0)
715 ; GFX6-NEXT: s_mov_b64 s[12:13], s[6:7]
716 ; GFX6-NEXT: v_lshlrev_b32_e32 v12, 5, v0
717 ; GFX6-NEXT: v_mov_b32_e32 v13, 0
718 ; GFX6-NEXT: s_mov_b64 s[2:3], s[14:15]
719 ; GFX6-NEXT: buffer_load_dwordx4 v[0:3], v[12:13], s[12:15], 0 addr64
720 ; GFX6-NEXT: buffer_load_dwordx4 v[4:7], v[12:13], s[0:3], 0 addr64
721 ; GFX6-NEXT: buffer_load_dwordx4 v[8:11], v[12:13], s[0:3], 0 addr64 offset:16
722 ; GFX6-NEXT: buffer_load_dwordx4 v[12:15], v[12:13], s[12:15], 0 addr64 offset:16
723 ; GFX6-NEXT: s_mov_b32 s10, -1
724 ; GFX6-NEXT: s_mov_b32 s8, s4
725 ; GFX6-NEXT: s_mov_b32 s9, s5
726 ; GFX6-NEXT: s_waitcnt vmcnt(2)
727 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, v2, v6
728 ; GFX6-NEXT: v_subb_u32_e32 v3, vcc, v3, v7, vcc
729 ; GFX6-NEXT: v_sub_i32_e32 v0, vcc, v0, v4
730 ; GFX6-NEXT: v_subb_u32_e32 v1, vcc, v1, v5, vcc
731 ; GFX6-NEXT: s_waitcnt vmcnt(0)
732 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, v14, v10
733 ; GFX6-NEXT: v_subb_u32_e32 v7, vcc, v15, v11, vcc
734 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, v12, v8
735 ; GFX6-NEXT: v_subb_u32_e32 v5, vcc, v13, v9, vcc
736 ; GFX6-NEXT: buffer_store_dwordx4 v[4:7], off, s[8:11], 0 offset:16
737 ; GFX6-NEXT: buffer_store_dwordx4 v[0:3], off, s[8:11], 0
738 ; GFX6-NEXT: s_endpgm
740 ; GFX8-LABEL: v_test_sub_v4i64:
742 ; GFX8-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
743 ; GFX8-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x34
744 ; GFX8-NEXT: v_lshlrev_b32_e32 v0, 5, v0
745 ; GFX8-NEXT: s_waitcnt lgkmcnt(0)
746 ; GFX8-NEXT: v_mov_b32_e32 v1, s7
747 ; GFX8-NEXT: v_add_u32_e32 v8, vcc, s6, v0
748 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, 0, v1, vcc
749 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
750 ; GFX8-NEXT: v_add_u32_e32 v12, vcc, s0, v0
751 ; GFX8-NEXT: v_addc_u32_e32 v13, vcc, 0, v1, vcc
752 ; GFX8-NEXT: flat_load_dwordx4 v[0:3], v[8:9]
753 ; GFX8-NEXT: flat_load_dwordx4 v[4:7], v[12:13]
754 ; GFX8-NEXT: v_add_u32_e32 v8, vcc, 16, v8
755 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, 0, v9, vcc
756 ; GFX8-NEXT: v_add_u32_e32 v12, vcc, 16, v12
757 ; GFX8-NEXT: v_addc_u32_e32 v13, vcc, 0, v13, vcc
758 ; GFX8-NEXT: flat_load_dwordx4 v[8:11], v[8:9]
759 ; GFX8-NEXT: flat_load_dwordx4 v[12:15], v[12:13]
760 ; GFX8-NEXT: v_mov_b32_e32 v17, s5
761 ; GFX8-NEXT: v_mov_b32_e32 v16, s4
762 ; GFX8-NEXT: s_add_u32 s0, s4, 16
763 ; GFX8-NEXT: s_addc_u32 s1, s5, 0
764 ; GFX8-NEXT: s_waitcnt vmcnt(2)
765 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, v2, v6
766 ; GFX8-NEXT: v_subb_u32_e32 v3, vcc, v3, v7, vcc
767 ; GFX8-NEXT: v_sub_u32_e32 v0, vcc, v0, v4
768 ; GFX8-NEXT: v_subb_u32_e32 v1, vcc, v1, v5, vcc
769 ; GFX8-NEXT: flat_store_dwordx4 v[16:17], v[0:3]
770 ; GFX8-NEXT: s_waitcnt vmcnt(1)
771 ; GFX8-NEXT: v_sub_u32_e32 v6, vcc, v10, v14
772 ; GFX8-NEXT: v_subb_u32_e32 v7, vcc, v11, v15, vcc
773 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, v8, v12
774 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
775 ; GFX8-NEXT: v_subb_u32_e32 v5, vcc, v9, v13, vcc
776 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
777 ; GFX8-NEXT: flat_store_dwordx4 v[0:1], v[4:7]
778 ; GFX8-NEXT: s_endpgm
780 ; GFX9-LABEL: v_test_sub_v4i64:
782 ; GFX9-NEXT: s_load_dwordx4 s[4:7], s[0:1], 0x24
783 ; GFX9-NEXT: s_load_dwordx2 s[2:3], s[0:1], 0x34
784 ; GFX9-NEXT: v_lshlrev_b32_e32 v16, 5, v0
785 ; GFX9-NEXT: s_waitcnt lgkmcnt(0)
786 ; GFX9-NEXT: global_load_dwordx4 v[0:3], v16, s[6:7]
787 ; GFX9-NEXT: global_load_dwordx4 v[4:7], v16, s[2:3]
788 ; GFX9-NEXT: global_load_dwordx4 v[8:11], v16, s[6:7] offset:16
789 ; GFX9-NEXT: global_load_dwordx4 v[12:15], v16, s[2:3] offset:16
790 ; GFX9-NEXT: v_mov_b32_e32 v16, 0
791 ; GFX9-NEXT: s_waitcnt vmcnt(2)
792 ; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, v2, v6
793 ; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v3, v7, vcc
794 ; GFX9-NEXT: v_sub_co_u32_e32 v0, vcc, v0, v4
795 ; GFX9-NEXT: v_subb_co_u32_e32 v1, vcc, v1, v5, vcc
796 ; GFX9-NEXT: s_waitcnt vmcnt(0)
797 ; GFX9-NEXT: v_sub_co_u32_e32 v6, vcc, v10, v14
798 ; GFX9-NEXT: v_subb_co_u32_e32 v7, vcc, v11, v15, vcc
799 ; GFX9-NEXT: v_sub_co_u32_e32 v4, vcc, v8, v12
800 ; GFX9-NEXT: v_subb_co_u32_e32 v5, vcc, v9, v13, vcc
801 ; GFX9-NEXT: global_store_dwordx4 v16, v[4:7], s[4:5] offset:16
802 ; GFX9-NEXT: global_store_dwordx4 v16, v[0:3], s[4:5]
803 ; GFX9-NEXT: s_endpgm
804 %tid = call i32 @llvm.amdgcn.workitem.id.x() readnone
805 %a_ptr = getelementptr <4 x i64>, ptr addrspace(1) %inA, i32 %tid
806 %b_ptr = getelementptr <4 x i64>, ptr addrspace(1) %inB, i32 %tid
807 %a = load <4 x i64>, ptr addrspace(1) %a_ptr
808 %b = load <4 x i64>, ptr addrspace(1) %b_ptr
809 %result = sub <4 x i64> %a, %b
810 store <4 x i64> %result, ptr addrspace(1) %out
814 ; Make sure the VOP3 form of sub is initially selected. Otherwise pair
815 ; of opies from/to VCC would be necessary
817 define amdgpu_ps void @sub_select_vop3(i32 inreg %s, i32 %v) {
818 ; GFX6-LABEL: sub_select_vop3:
820 ; GFX6-NEXT: v_subrev_i32_e64 v0, s[0:1], s0, v0
821 ; GFX6-NEXT: s_mov_b32 m0, -1
822 ; GFX6-NEXT: ;;#ASMSTART
823 ; GFX6-NEXT: ; def vcc
824 ; GFX6-NEXT: ;;#ASMEND
825 ; GFX6-NEXT: ds_write_b32 v0, v0
826 ; GFX6-NEXT: ;;#ASMSTART
827 ; GFX6-NEXT: ; use vcc
828 ; GFX6-NEXT: ;;#ASMEND
829 ; GFX6-NEXT: s_endpgm
831 ; GFX8-LABEL: sub_select_vop3:
833 ; GFX8-NEXT: v_subrev_u32_e64 v0, s[0:1], s0, v0
834 ; GFX8-NEXT: s_mov_b32 m0, -1
835 ; GFX8-NEXT: ;;#ASMSTART
836 ; GFX8-NEXT: ; def vcc
837 ; GFX8-NEXT: ;;#ASMEND
838 ; GFX8-NEXT: ds_write_b32 v0, v0
839 ; GFX8-NEXT: ;;#ASMSTART
840 ; GFX8-NEXT: ; use vcc
841 ; GFX8-NEXT: ;;#ASMEND
842 ; GFX8-NEXT: s_endpgm
844 ; GFX9-LABEL: sub_select_vop3:
846 ; GFX9-NEXT: v_subrev_u32_e32 v0, s0, v0
847 ; GFX9-NEXT: ;;#ASMSTART
848 ; GFX9-NEXT: ; def vcc
849 ; GFX9-NEXT: ;;#ASMEND
850 ; GFX9-NEXT: ds_write_b32 v0, v0
851 ; GFX9-NEXT: ;;#ASMSTART
852 ; GFX9-NEXT: ; use vcc
853 ; GFX9-NEXT: ;;#ASMEND
854 ; GFX9-NEXT: s_endpgm
855 %vcc = call i64 asm sideeffect "; def vcc", "={vcc}"()
856 %sub = sub i32 %v, %s
857 store i32 %sub, ptr addrspace(3) undef
858 call void asm sideeffect "; use vcc", "{vcc}"(i64 %vcc)