1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs -mattr=-unaligned-access-mode < %s | FileCheck -check-prefixes=GCN,GFX900 %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs -mattr=-unaligned-access-mode -mattr=+enable-flat-scratch < %s | FileCheck -check-prefixes=GCN,FLATSCR %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs -mattr=-unaligned-access-mode < %s | FileCheck -check-prefixes=GFX10,GFX10_DEFAULT %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs -mattr=-unaligned-access-mode -mattr=+enable-flat-scratch < %s | FileCheck -check-prefixes=GFX10,FLATSCR_GFX10 %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs -mattr=-unaligned-access-mode < %s | FileCheck -check-prefixes=GFX11 %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs -mattr=-unaligned-access-mode -mattr=+enable-flat-scratch < %s | FileCheck -check-prefixes=GFX11 %s
9 define <2 x half> @chain_hi_to_lo_private() {
10 ; GFX900-LABEL: chain_hi_to_lo_private:
11 ; GFX900: ; %bb.0: ; %bb
12 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
13 ; GFX900-NEXT: buffer_load_ushort v0, off, s[0:3], 0 offset:2
14 ; GFX900-NEXT: s_nop 0
15 ; GFX900-NEXT: buffer_load_short_d16_hi v0, off, s[0:3], 0
16 ; GFX900-NEXT: s_waitcnt vmcnt(0)
17 ; GFX900-NEXT: s_setpc_b64 s[30:31]
19 ; FLATSCR-LABEL: chain_hi_to_lo_private:
20 ; FLATSCR: ; %bb.0: ; %bb
21 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
22 ; FLATSCR-NEXT: s_mov_b32 s0, 2
23 ; FLATSCR-NEXT: scratch_load_ushort v0, off, s0
24 ; FLATSCR-NEXT: s_mov_b32 s0, 0
25 ; FLATSCR-NEXT: scratch_load_short_d16_hi v0, off, s0
26 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
27 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
29 ; GFX10_DEFAULT-LABEL: chain_hi_to_lo_private:
30 ; GFX10_DEFAULT: ; %bb.0: ; %bb
31 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
32 ; GFX10_DEFAULT-NEXT: s_clause 0x1
33 ; GFX10_DEFAULT-NEXT: buffer_load_ushort v0, off, s[0:3], 0 offset:2
34 ; GFX10_DEFAULT-NEXT: buffer_load_short_d16_hi v0, off, s[0:3], 0
35 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
36 ; GFX10_DEFAULT-NEXT: s_setpc_b64 s[30:31]
38 ; FLATSCR_GFX10-LABEL: chain_hi_to_lo_private:
39 ; FLATSCR_GFX10: ; %bb.0: ; %bb
40 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
41 ; FLATSCR_GFX10-NEXT: s_mov_b32 s0, 2
42 ; FLATSCR_GFX10-NEXT: scratch_load_ushort v0, off, s0
43 ; FLATSCR_GFX10-NEXT: s_waitcnt_depctr 0xffe3
44 ; FLATSCR_GFX10-NEXT: s_mov_b32 s0, 0
45 ; FLATSCR_GFX10-NEXT: scratch_load_short_d16_hi v0, off, s0
46 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
47 ; FLATSCR_GFX10-NEXT: s_setpc_b64 s[30:31]
49 ; GFX11-LABEL: chain_hi_to_lo_private:
50 ; GFX11: ; %bb.0: ; %bb
51 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
52 ; GFX11-NEXT: s_mov_b32 s0, 2
53 ; GFX11-NEXT: scratch_load_u16 v0, off, s0
54 ; GFX11-NEXT: s_mov_b32 s0, 0
55 ; GFX11-NEXT: scratch_load_d16_hi_b16 v0, off, s0
56 ; GFX11-NEXT: s_waitcnt vmcnt(0)
57 ; GFX11-NEXT: s_setpc_b64 s[30:31]
59 %gep_lo = getelementptr inbounds half, ptr addrspace(5) null, i64 1
60 %load_lo = load half, ptr addrspace(5) %gep_lo
61 %load_hi = load half, ptr addrspace(5) null
63 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
64 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
66 ret <2 x half> %result
69 define <2 x half> @chain_hi_to_lo_private_different_bases(ptr addrspace(5) %base_lo, ptr addrspace(5) %base_hi) {
70 ; GFX900-LABEL: chain_hi_to_lo_private_different_bases:
71 ; GFX900: ; %bb.0: ; %bb
72 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
73 ; GFX900-NEXT: buffer_load_ushort v0, v0, s[0:3], 0 offen
74 ; GFX900-NEXT: s_nop 0
75 ; GFX900-NEXT: buffer_load_short_d16_hi v0, v1, s[0:3], 0 offen
76 ; GFX900-NEXT: s_waitcnt vmcnt(0)
77 ; GFX900-NEXT: s_setpc_b64 s[30:31]
79 ; FLATSCR-LABEL: chain_hi_to_lo_private_different_bases:
80 ; FLATSCR: ; %bb.0: ; %bb
81 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
82 ; FLATSCR-NEXT: scratch_load_ushort v0, v0, off
83 ; FLATSCR-NEXT: s_nop 0
84 ; FLATSCR-NEXT: scratch_load_short_d16_hi v0, v1, off
85 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
86 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
88 ; GFX10_DEFAULT-LABEL: chain_hi_to_lo_private_different_bases:
89 ; GFX10_DEFAULT: ; %bb.0: ; %bb
90 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
91 ; GFX10_DEFAULT-NEXT: s_clause 0x1
92 ; GFX10_DEFAULT-NEXT: buffer_load_ushort v0, v0, s[0:3], 0 offen
93 ; GFX10_DEFAULT-NEXT: buffer_load_short_d16_hi v0, v1, s[0:3], 0 offen
94 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
95 ; GFX10_DEFAULT-NEXT: s_setpc_b64 s[30:31]
97 ; FLATSCR_GFX10-LABEL: chain_hi_to_lo_private_different_bases:
98 ; FLATSCR_GFX10: ; %bb.0: ; %bb
99 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
100 ; FLATSCR_GFX10-NEXT: scratch_load_ushort v0, v0, off
101 ; FLATSCR_GFX10-NEXT: scratch_load_short_d16_hi v0, v1, off
102 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
103 ; FLATSCR_GFX10-NEXT: s_setpc_b64 s[30:31]
105 ; GFX11-LABEL: chain_hi_to_lo_private_different_bases:
106 ; GFX11: ; %bb.0: ; %bb
107 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
108 ; GFX11-NEXT: scratch_load_u16 v0, v0, off
109 ; GFX11-NEXT: scratch_load_d16_hi_b16 v0, v1, off
110 ; GFX11-NEXT: s_waitcnt vmcnt(0)
111 ; GFX11-NEXT: s_setpc_b64 s[30:31]
113 %load_lo = load half, ptr addrspace(5) %base_lo
114 %load_hi = load half, ptr addrspace(5) %base_hi
116 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
117 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
119 ret <2 x half> %result
122 define <2 x half> @chain_hi_to_lo_arithmatic(ptr addrspace(5) %base, half %in) {
123 ; GFX900-LABEL: chain_hi_to_lo_arithmatic:
124 ; GFX900: ; %bb.0: ; %bb
125 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
126 ; GFX900-NEXT: v_add_f16_e32 v1, 1.0, v1
127 ; GFX900-NEXT: buffer_load_short_d16_hi v1, v0, s[0:3], 0 offen
128 ; GFX900-NEXT: s_waitcnt vmcnt(0)
129 ; GFX900-NEXT: v_mov_b32_e32 v0, v1
130 ; GFX900-NEXT: s_setpc_b64 s[30:31]
132 ; FLATSCR-LABEL: chain_hi_to_lo_arithmatic:
133 ; FLATSCR: ; %bb.0: ; %bb
134 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
135 ; FLATSCR-NEXT: v_add_f16_e32 v1, 1.0, v1
136 ; FLATSCR-NEXT: scratch_load_short_d16_hi v1, v0, off
137 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
138 ; FLATSCR-NEXT: v_mov_b32_e32 v0, v1
139 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
141 ; GFX10_DEFAULT-LABEL: chain_hi_to_lo_arithmatic:
142 ; GFX10_DEFAULT: ; %bb.0: ; %bb
143 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
144 ; GFX10_DEFAULT-NEXT: v_add_f16_e32 v1, 1.0, v1
145 ; GFX10_DEFAULT-NEXT: buffer_load_short_d16_hi v1, v0, s[0:3], 0 offen
146 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
147 ; GFX10_DEFAULT-NEXT: v_mov_b32_e32 v0, v1
148 ; GFX10_DEFAULT-NEXT: s_setpc_b64 s[30:31]
150 ; FLATSCR_GFX10-LABEL: chain_hi_to_lo_arithmatic:
151 ; FLATSCR_GFX10: ; %bb.0: ; %bb
152 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
153 ; FLATSCR_GFX10-NEXT: v_add_f16_e32 v1, 1.0, v1
154 ; FLATSCR_GFX10-NEXT: scratch_load_short_d16_hi v1, v0, off
155 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
156 ; FLATSCR_GFX10-NEXT: v_mov_b32_e32 v0, v1
157 ; FLATSCR_GFX10-NEXT: s_setpc_b64 s[30:31]
159 ; GFX11-LABEL: chain_hi_to_lo_arithmatic:
160 ; GFX11: ; %bb.0: ; %bb
161 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
162 ; GFX11-NEXT: v_add_f16_e32 v1, 1.0, v1
163 ; GFX11-NEXT: scratch_load_d16_hi_b16 v1, v0, off
164 ; GFX11-NEXT: s_waitcnt vmcnt(0)
165 ; GFX11-NEXT: v_mov_b32_e32 v0, v1
166 ; GFX11-NEXT: s_setpc_b64 s[30:31]
168 %arith_lo = fadd half %in, 1.0
169 %load_hi = load half, ptr addrspace(5) %base
171 %temp = insertelement <2 x half> undef, half %arith_lo, i32 0
172 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
174 ret <2 x half> %result
177 define <2 x half> @chain_hi_to_lo_group() {
178 ; GCN-LABEL: chain_hi_to_lo_group:
179 ; GCN: ; %bb.0: ; %bb
180 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
181 ; GCN-NEXT: v_mov_b32_e32 v1, 0
182 ; GCN-NEXT: ds_read_u16 v0, v1 offset:2
183 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
184 ; GCN-NEXT: ds_read_u16_d16_hi v0, v1
185 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
186 ; GCN-NEXT: s_setpc_b64 s[30:31]
188 ; GFX10-LABEL: chain_hi_to_lo_group:
189 ; GFX10: ; %bb.0: ; %bb
190 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
191 ; GFX10-NEXT: v_mov_b32_e32 v1, 0
192 ; GFX10-NEXT: ds_read_u16 v0, v1 offset:2
193 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
194 ; GFX10-NEXT: ds_read_u16_d16_hi v0, v1
195 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
196 ; GFX10-NEXT: s_setpc_b64 s[30:31]
198 ; GFX11-LABEL: chain_hi_to_lo_group:
199 ; GFX11: ; %bb.0: ; %bb
200 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
201 ; GFX11-NEXT: v_mov_b32_e32 v1, 0
202 ; GFX11-NEXT: ds_load_u16 v0, v1 offset:2
203 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
204 ; GFX11-NEXT: ds_load_u16_d16_hi v0, v1
205 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
206 ; GFX11-NEXT: s_setpc_b64 s[30:31]
208 %gep_lo = getelementptr inbounds half, ptr addrspace(3) null, i64 1
209 %load_lo = load half, ptr addrspace(3) %gep_lo
210 %load_hi = load half, ptr addrspace(3) null
212 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
213 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
215 ret <2 x half> %result
218 define <2 x half> @chain_hi_to_lo_group_different_bases(ptr addrspace(3) %base_lo, ptr addrspace(3) %base_hi) {
219 ; GCN-LABEL: chain_hi_to_lo_group_different_bases:
220 ; GCN: ; %bb.0: ; %bb
221 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
222 ; GCN-NEXT: ds_read_u16 v0, v0
223 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
224 ; GCN-NEXT: ds_read_u16_d16_hi v0, v1
225 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
226 ; GCN-NEXT: s_setpc_b64 s[30:31]
228 ; GFX10-LABEL: chain_hi_to_lo_group_different_bases:
229 ; GFX10: ; %bb.0: ; %bb
230 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
231 ; GFX10-NEXT: ds_read_u16 v0, v0
232 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
233 ; GFX10-NEXT: ds_read_u16_d16_hi v0, v1
234 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
235 ; GFX10-NEXT: s_setpc_b64 s[30:31]
237 ; GFX11-LABEL: chain_hi_to_lo_group_different_bases:
238 ; GFX11: ; %bb.0: ; %bb
239 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
240 ; GFX11-NEXT: ds_load_u16 v0, v0
241 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
242 ; GFX11-NEXT: ds_load_u16_d16_hi v0, v1
243 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
244 ; GFX11-NEXT: s_setpc_b64 s[30:31]
246 %load_lo = load half, ptr addrspace(3) %base_lo
247 %load_hi = load half, ptr addrspace(3) %base_hi
249 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
250 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
252 ret <2 x half> %result
255 define <2 x half> @chain_hi_to_lo_global() {
256 ; GCN-LABEL: chain_hi_to_lo_global:
257 ; GCN: ; %bb.0: ; %bb
258 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
259 ; GCN-NEXT: v_mov_b32_e32 v0, 2
260 ; GCN-NEXT: v_mov_b32_e32 v1, 0
261 ; GCN-NEXT: global_load_ushort v0, v[0:1], off
262 ; GCN-NEXT: v_mov_b32_e32 v1, 0
263 ; GCN-NEXT: v_mov_b32_e32 v2, 0
264 ; GCN-NEXT: global_load_short_d16_hi v0, v[1:2], off
265 ; GCN-NEXT: s_waitcnt vmcnt(0)
266 ; GCN-NEXT: s_setpc_b64 s[30:31]
268 ; GFX10-LABEL: chain_hi_to_lo_global:
269 ; GFX10: ; %bb.0: ; %bb
270 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
271 ; GFX10-NEXT: v_mov_b32_e32 v0, 2
272 ; GFX10-NEXT: v_mov_b32_e32 v1, 0
273 ; GFX10-NEXT: global_load_ushort v0, v[0:1], off
274 ; GFX10-NEXT: v_mov_b32_e32 v1, 0
275 ; GFX10-NEXT: v_mov_b32_e32 v2, 0
276 ; GFX10-NEXT: global_load_short_d16_hi v0, v[1:2], off
277 ; GFX10-NEXT: s_waitcnt vmcnt(0)
278 ; GFX10-NEXT: s_setpc_b64 s[30:31]
280 ; GFX11-LABEL: chain_hi_to_lo_global:
281 ; GFX11: ; %bb.0: ; %bb
282 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
283 ; GFX11-NEXT: v_mov_b32_e32 v0, 2
284 ; GFX11-NEXT: v_mov_b32_e32 v1, 0
285 ; GFX11-NEXT: global_load_u16 v0, v[0:1], off
286 ; GFX11-NEXT: v_mov_b32_e32 v1, 0
287 ; GFX11-NEXT: v_mov_b32_e32 v2, 0
288 ; GFX11-NEXT: global_load_d16_hi_b16 v0, v[1:2], off
289 ; GFX11-NEXT: s_waitcnt vmcnt(0)
290 ; GFX11-NEXT: s_setpc_b64 s[30:31]
292 %gep_lo = getelementptr inbounds half, ptr addrspace(1) null, i64 1
293 %load_lo = load half, ptr addrspace(1) %gep_lo
294 %load_hi = load half, ptr addrspace(1) null
296 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
297 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
299 ret <2 x half> %result
302 define <2 x half> @chain_hi_to_lo_global_different_bases(ptr addrspace(1) %base_lo, ptr addrspace(1) %base_hi) {
303 ; GCN-LABEL: chain_hi_to_lo_global_different_bases:
304 ; GCN: ; %bb.0: ; %bb
305 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
306 ; GCN-NEXT: global_load_ushort v0, v[0:1], off
308 ; GCN-NEXT: global_load_short_d16_hi v0, v[2:3], off
309 ; GCN-NEXT: s_waitcnt vmcnt(0)
310 ; GCN-NEXT: s_setpc_b64 s[30:31]
312 ; GFX10-LABEL: chain_hi_to_lo_global_different_bases:
313 ; GFX10: ; %bb.0: ; %bb
314 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
315 ; GFX10-NEXT: global_load_ushort v0, v[0:1], off
316 ; GFX10-NEXT: global_load_short_d16_hi v0, v[2:3], off
317 ; GFX10-NEXT: s_waitcnt vmcnt(0)
318 ; GFX10-NEXT: s_setpc_b64 s[30:31]
320 ; GFX11-LABEL: chain_hi_to_lo_global_different_bases:
321 ; GFX11: ; %bb.0: ; %bb
322 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
323 ; GFX11-NEXT: global_load_u16 v0, v[0:1], off
324 ; GFX11-NEXT: global_load_d16_hi_b16 v0, v[2:3], off
325 ; GFX11-NEXT: s_waitcnt vmcnt(0)
326 ; GFX11-NEXT: s_setpc_b64 s[30:31]
328 %load_lo = load half, ptr addrspace(1) %base_lo
329 %load_hi = load half, ptr addrspace(1) %base_hi
331 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
332 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
334 ret <2 x half> %result
337 define <2 x half> @chain_hi_to_lo_flat() {
338 ; GCN-LABEL: chain_hi_to_lo_flat:
339 ; GCN: ; %bb.0: ; %bb
340 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
341 ; GCN-NEXT: v_mov_b32_e32 v0, 2
342 ; GCN-NEXT: v_mov_b32_e32 v1, 0
343 ; GCN-NEXT: flat_load_ushort v0, v[0:1]
344 ; GCN-NEXT: v_mov_b32_e32 v1, 0
345 ; GCN-NEXT: v_mov_b32_e32 v2, 0
346 ; GCN-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
347 ; GCN-NEXT: flat_load_short_d16_hi v0, v[1:2]
348 ; GCN-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
349 ; GCN-NEXT: s_setpc_b64 s[30:31]
351 ; GFX10-LABEL: chain_hi_to_lo_flat:
352 ; GFX10: ; %bb.0: ; %bb
353 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
354 ; GFX10-NEXT: v_mov_b32_e32 v0, 2
355 ; GFX10-NEXT: v_mov_b32_e32 v1, 0
356 ; GFX10-NEXT: flat_load_ushort v0, v[0:1]
357 ; GFX10-NEXT: v_mov_b32_e32 v1, 0
358 ; GFX10-NEXT: v_mov_b32_e32 v2, 0
359 ; GFX10-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
360 ; GFX10-NEXT: flat_load_short_d16_hi v0, v[1:2]
361 ; GFX10-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
362 ; GFX10-NEXT: s_setpc_b64 s[30:31]
364 ; GFX11-LABEL: chain_hi_to_lo_flat:
365 ; GFX11: ; %bb.0: ; %bb
366 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
367 ; GFX11-NEXT: v_mov_b32_e32 v0, 2
368 ; GFX11-NEXT: v_mov_b32_e32 v1, 0
369 ; GFX11-NEXT: flat_load_u16 v0, v[0:1]
370 ; GFX11-NEXT: v_mov_b32_e32 v1, 0
371 ; GFX11-NEXT: v_mov_b32_e32 v2, 0
372 ; GFX11-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
373 ; GFX11-NEXT: flat_load_d16_hi_b16 v0, v[1:2]
374 ; GFX11-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
375 ; GFX11-NEXT: s_setpc_b64 s[30:31]
377 %gep_lo = getelementptr inbounds half, ptr null, i64 1
378 %load_lo = load half, ptr %gep_lo
379 %load_hi = load half, ptr null
381 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
382 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
384 ret <2 x half> %result
387 define <2 x half> @chain_hi_to_lo_flat_different_bases(ptr %base_lo, ptr %base_hi) {
388 ; GCN-LABEL: chain_hi_to_lo_flat_different_bases:
389 ; GCN: ; %bb.0: ; %bb
390 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
391 ; GCN-NEXT: flat_load_ushort v0, v[0:1]
392 ; GCN-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
393 ; GCN-NEXT: flat_load_short_d16_hi v0, v[2:3]
394 ; GCN-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
395 ; GCN-NEXT: s_setpc_b64 s[30:31]
397 ; GFX10-LABEL: chain_hi_to_lo_flat_different_bases:
398 ; GFX10: ; %bb.0: ; %bb
399 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
400 ; GFX10-NEXT: flat_load_ushort v0, v[0:1]
401 ; GFX10-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
402 ; GFX10-NEXT: flat_load_short_d16_hi v0, v[2:3]
403 ; GFX10-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
404 ; GFX10-NEXT: s_setpc_b64 s[30:31]
406 ; GFX11-LABEL: chain_hi_to_lo_flat_different_bases:
407 ; GFX11: ; %bb.0: ; %bb
408 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
409 ; GFX11-NEXT: flat_load_u16 v0, v[0:1]
410 ; GFX11-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
411 ; GFX11-NEXT: flat_load_d16_hi_b16 v0, v[2:3]
412 ; GFX11-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
413 ; GFX11-NEXT: s_setpc_b64 s[30:31]
415 %load_lo = load half, ptr %base_lo
416 %load_hi = load half, ptr %base_hi
418 %temp = insertelement <2 x half> undef, half %load_lo, i32 0
419 %result = insertelement <2 x half> %temp, half %load_hi, i32 1
421 ret <2 x half> %result
424 ; Make sure we don't lose any of the private stores.
425 define amdgpu_kernel void @vload2_private(ptr addrspace(1) nocapture readonly %in, ptr addrspace(1) nocapture %out) #0 {
426 ; GFX900-LABEL: vload2_private:
427 ; GFX900: ; %bb.0: ; %entry
428 ; GFX900-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
429 ; GFX900-NEXT: v_mov_b32_e32 v2, 0
430 ; GFX900-NEXT: s_add_u32 s0, s0, s9
431 ; GFX900-NEXT: s_addc_u32 s1, s1, 0
432 ; GFX900-NEXT: s_waitcnt lgkmcnt(0)
433 ; GFX900-NEXT: global_load_ushort v0, v2, s[4:5]
434 ; GFX900-NEXT: s_waitcnt vmcnt(0)
435 ; GFX900-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:4
436 ; GFX900-NEXT: s_waitcnt vmcnt(0)
437 ; GFX900-NEXT: global_load_ushort v0, v2, s[4:5] offset:2
438 ; GFX900-NEXT: s_waitcnt vmcnt(0)
439 ; GFX900-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:6
440 ; GFX900-NEXT: s_waitcnt vmcnt(0)
441 ; GFX900-NEXT: global_load_ushort v0, v2, s[4:5] offset:4
442 ; GFX900-NEXT: s_mov_b32 s4, 0x5040100
443 ; GFX900-NEXT: s_waitcnt vmcnt(0)
444 ; GFX900-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:8
445 ; GFX900-NEXT: s_waitcnt vmcnt(0)
446 ; GFX900-NEXT: buffer_load_ushort v0, off, s[0:3], 0 offset:6
447 ; GFX900-NEXT: buffer_load_ushort v3, off, s[0:3], 0 offset:4
448 ; GFX900-NEXT: s_waitcnt vmcnt(1)
449 ; GFX900-NEXT: v_mov_b32_e32 v1, v0
450 ; GFX900-NEXT: buffer_load_short_d16_hi v1, off, s[0:3], 0 offset:8
451 ; GFX900-NEXT: s_waitcnt vmcnt(1)
452 ; GFX900-NEXT: v_perm_b32 v0, v0, v3, s4
453 ; GFX900-NEXT: s_waitcnt vmcnt(0)
454 ; GFX900-NEXT: global_store_dwordx2 v2, v[0:1], s[6:7]
455 ; GFX900-NEXT: s_endpgm
457 ; FLATSCR-LABEL: vload2_private:
458 ; FLATSCR: ; %bb.0: ; %entry
459 ; FLATSCR-NEXT: s_add_u32 flat_scratch_lo, s2, s5
460 ; FLATSCR-NEXT: s_addc_u32 flat_scratch_hi, s3, 0
461 ; FLATSCR-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
462 ; FLATSCR-NEXT: v_mov_b32_e32 v2, 0
463 ; FLATSCR-NEXT: s_mov_b32 s4, 0
464 ; FLATSCR-NEXT: s_waitcnt lgkmcnt(0)
465 ; FLATSCR-NEXT: global_load_ushort v0, v2, s[0:1]
466 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
467 ; FLATSCR-NEXT: scratch_store_short off, v0, s4 offset:4
468 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
469 ; FLATSCR-NEXT: global_load_ushort v0, v2, s[0:1] offset:2
470 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
471 ; FLATSCR-NEXT: scratch_store_short off, v0, s4 offset:6
472 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
473 ; FLATSCR-NEXT: global_load_ushort v0, v2, s[0:1] offset:4
474 ; FLATSCR-NEXT: s_mov_b32 s0, 0
475 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
476 ; FLATSCR-NEXT: scratch_store_short off, v0, s0 offset:8
477 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
478 ; FLATSCR-NEXT: scratch_load_dword v0, off, s0 offset:4
479 ; FLATSCR-NEXT: scratch_load_dword v1, off, s0 offset:6
480 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
481 ; FLATSCR-NEXT: global_store_dwordx2 v2, v[0:1], s[2:3]
482 ; FLATSCR-NEXT: s_endpgm
484 ; GFX10_DEFAULT-LABEL: vload2_private:
485 ; GFX10_DEFAULT: ; %bb.0: ; %entry
486 ; GFX10_DEFAULT-NEXT: s_load_dwordx4 s[4:7], s[4:5], 0x0
487 ; GFX10_DEFAULT-NEXT: v_mov_b32_e32 v2, 0
488 ; GFX10_DEFAULT-NEXT: s_add_u32 s0, s0, s9
489 ; GFX10_DEFAULT-NEXT: s_addc_u32 s1, s1, 0
490 ; GFX10_DEFAULT-NEXT: s_waitcnt lgkmcnt(0)
491 ; GFX10_DEFAULT-NEXT: global_load_ushort v0, v2, s[4:5]
492 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
493 ; GFX10_DEFAULT-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:4
494 ; GFX10_DEFAULT-NEXT: s_waitcnt_vscnt null, 0x0
495 ; GFX10_DEFAULT-NEXT: global_load_ushort v0, v2, s[4:5] offset:2
496 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
497 ; GFX10_DEFAULT-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:6
498 ; GFX10_DEFAULT-NEXT: s_waitcnt_vscnt null, 0x0
499 ; GFX10_DEFAULT-NEXT: global_load_ushort v0, v2, s[4:5] offset:4
500 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
501 ; GFX10_DEFAULT-NEXT: buffer_store_short v0, off, s[0:3], 0 offset:8
502 ; GFX10_DEFAULT-NEXT: s_waitcnt_vscnt null, 0x0
503 ; GFX10_DEFAULT-NEXT: s_clause 0x1
504 ; GFX10_DEFAULT-NEXT: buffer_load_ushort v0, off, s[0:3], 0 offset:6
505 ; GFX10_DEFAULT-NEXT: buffer_load_ushort v3, off, s[0:3], 0 offset:4
506 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(1)
507 ; GFX10_DEFAULT-NEXT: v_mov_b32_e32 v1, v0
508 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
509 ; GFX10_DEFAULT-NEXT: v_perm_b32 v0, v0, v3, 0x5040100
510 ; GFX10_DEFAULT-NEXT: buffer_load_short_d16_hi v1, off, s[0:3], 0 offset:8
511 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
512 ; GFX10_DEFAULT-NEXT: global_store_dwordx2 v2, v[0:1], s[6:7]
513 ; GFX10_DEFAULT-NEXT: s_endpgm
515 ; FLATSCR_GFX10-LABEL: vload2_private:
516 ; FLATSCR_GFX10: ; %bb.0: ; %entry
517 ; FLATSCR_GFX10-NEXT: s_add_u32 s2, s2, s5
518 ; FLATSCR_GFX10-NEXT: s_addc_u32 s3, s3, 0
519 ; FLATSCR_GFX10-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_LO), s2
520 ; FLATSCR_GFX10-NEXT: s_setreg_b32 hwreg(HW_REG_FLAT_SCR_HI), s3
521 ; FLATSCR_GFX10-NEXT: s_load_dwordx4 s[0:3], s[0:1], 0x0
522 ; FLATSCR_GFX10-NEXT: v_mov_b32_e32 v2, 0
523 ; FLATSCR_GFX10-NEXT: s_mov_b32 s4, 0
524 ; FLATSCR_GFX10-NEXT: s_waitcnt lgkmcnt(0)
525 ; FLATSCR_GFX10-NEXT: global_load_ushort v0, v2, s[0:1]
526 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
527 ; FLATSCR_GFX10-NEXT: scratch_store_short off, v0, s4 offset:4
528 ; FLATSCR_GFX10-NEXT: s_waitcnt_vscnt null, 0x0
529 ; FLATSCR_GFX10-NEXT: global_load_ushort v0, v2, s[0:1] offset:2
530 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
531 ; FLATSCR_GFX10-NEXT: scratch_store_short off, v0, s4 offset:6
532 ; FLATSCR_GFX10-NEXT: s_waitcnt_vscnt null, 0x0
533 ; FLATSCR_GFX10-NEXT: global_load_ushort v0, v2, s[0:1] offset:4
534 ; FLATSCR_GFX10-NEXT: s_waitcnt_depctr 0xffe3
535 ; FLATSCR_GFX10-NEXT: s_mov_b32 s0, 0
536 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
537 ; FLATSCR_GFX10-NEXT: scratch_store_short off, v0, s0 offset:8
538 ; FLATSCR_GFX10-NEXT: s_waitcnt_vscnt null, 0x0
539 ; FLATSCR_GFX10-NEXT: s_clause 0x1
540 ; FLATSCR_GFX10-NEXT: scratch_load_dword v0, off, s0 offset:4
541 ; FLATSCR_GFX10-NEXT: scratch_load_dword v1, off, s0 offset:6
542 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
543 ; FLATSCR_GFX10-NEXT: global_store_dwordx2 v2, v[0:1], s[2:3]
544 ; FLATSCR_GFX10-NEXT: s_endpgm
546 ; GFX11-LABEL: vload2_private:
547 ; GFX11: ; %bb.0: ; %entry
548 ; GFX11-NEXT: s_load_b128 s[0:3], s[0:1], 0x0
549 ; GFX11-NEXT: v_mov_b32_e32 v2, 0
550 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
551 ; GFX11-NEXT: global_load_u16 v0, v2, s[0:1]
552 ; GFX11-NEXT: s_waitcnt vmcnt(0)
553 ; GFX11-NEXT: scratch_store_b16 off, v0, off offset:4 dlc
554 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
555 ; GFX11-NEXT: global_load_u16 v0, v2, s[0:1] offset:2
556 ; GFX11-NEXT: s_waitcnt vmcnt(0)
557 ; GFX11-NEXT: scratch_store_b16 off, v0, off offset:6 dlc
558 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
559 ; GFX11-NEXT: global_load_u16 v0, v2, s[0:1] offset:4
560 ; GFX11-NEXT: s_waitcnt vmcnt(0)
561 ; GFX11-NEXT: scratch_store_b16 off, v0, off offset:8 dlc
562 ; GFX11-NEXT: s_waitcnt_vscnt null, 0x0
563 ; GFX11-NEXT: s_clause 0x1
564 ; GFX11-NEXT: scratch_load_b32 v0, off, off offset:4
565 ; GFX11-NEXT: scratch_load_b32 v1, off, off offset:6
566 ; GFX11-NEXT: s_waitcnt vmcnt(0)
567 ; GFX11-NEXT: global_store_b64 v2, v[0:1], s[2:3]
568 ; GFX11-NEXT: s_nop 0
569 ; GFX11-NEXT: s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
570 ; GFX11-NEXT: s_endpgm
572 %loc = alloca [3 x i16], align 2, addrspace(5)
573 %tmp = load i16, ptr addrspace(1) %in, align 2
574 store volatile i16 %tmp, ptr addrspace(5) %loc
575 %arrayidx.1 = getelementptr inbounds i16, ptr addrspace(1) %in, i64 1
576 %tmp1 = load i16, ptr addrspace(1) %arrayidx.1, align 2
577 %loc.2.sroa_idx3 = getelementptr inbounds [3 x i16], ptr addrspace(5) %loc, i32 0, i32 1
578 store volatile i16 %tmp1, ptr addrspace(5) %loc.2.sroa_idx3
579 %arrayidx.2 = getelementptr inbounds i16, ptr addrspace(1) %in, i64 2
580 %tmp2 = load i16, ptr addrspace(1) %arrayidx.2, align 2
581 %loc.4.sroa_idx = getelementptr inbounds [3 x i16], ptr addrspace(5) %loc, i32 0, i32 2
582 store volatile i16 %tmp2, ptr addrspace(5) %loc.4.sroa_idx
583 %loc.0. = load <2 x i16>, ptr addrspace(5) %loc, align 2
584 store <2 x i16> %loc.0., ptr addrspace(1) %out, align 4
585 %loc.2.sroa_idx = getelementptr inbounds [3 x i16], ptr addrspace(5) %loc, i32 0, i32 1
586 %loc.2. = load <2 x i16>, ptr addrspace(5) %loc.2.sroa_idx, align 2
587 %arrayidx6 = getelementptr inbounds <2 x i16>, ptr addrspace(1) %out, i64 1
588 store <2 x i16> %loc.2., ptr addrspace(1) %arrayidx6, align 4
592 ; There is another instruction between the misordered instruction and
593 ; the value dependent load, so a simple operand check is insufficient.
594 define <2 x i16> @chain_hi_to_lo_group_other_dep(ptr addrspace(3) %ptr) {
595 ; GCN-LABEL: chain_hi_to_lo_group_other_dep:
596 ; GCN: ; %bb.0: ; %bb
597 ; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
598 ; GCN-NEXT: ds_read_u16_d16_hi v1, v0
599 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
600 ; GCN-NEXT: v_pk_sub_u16 v1, v1, -12 op_sel_hi:[1,0]
601 ; GCN-NEXT: ds_read_u16_d16 v1, v0 offset:2
602 ; GCN-NEXT: s_waitcnt lgkmcnt(0)
603 ; GCN-NEXT: v_mov_b32_e32 v0, v1
604 ; GCN-NEXT: s_setpc_b64 s[30:31]
606 ; GFX10-LABEL: chain_hi_to_lo_group_other_dep:
607 ; GFX10: ; %bb.0: ; %bb
608 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
609 ; GFX10-NEXT: ds_read_u16_d16_hi v1, v0
610 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
611 ; GFX10-NEXT: v_pk_sub_u16 v1, v1, -12 op_sel_hi:[1,0]
612 ; GFX10-NEXT: ds_read_u16_d16 v1, v0 offset:2
613 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
614 ; GFX10-NEXT: v_mov_b32_e32 v0, v1
615 ; GFX10-NEXT: s_setpc_b64 s[30:31]
617 ; GFX11-LABEL: chain_hi_to_lo_group_other_dep:
618 ; GFX11: ; %bb.0: ; %bb
619 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
620 ; GFX11-NEXT: ds_load_u16_d16_hi v1, v0
621 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
622 ; GFX11-NEXT: v_pk_sub_u16 v1, v1, -12 op_sel_hi:[1,0]
623 ; GFX11-NEXT: ds_load_u16_d16 v1, v0 offset:2
624 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
625 ; GFX11-NEXT: v_mov_b32_e32 v0, v1
626 ; GFX11-NEXT: s_setpc_b64 s[30:31]
628 %gep_lo = getelementptr inbounds i16, ptr addrspace(3) %ptr, i64 1
629 %load_lo = load i16, ptr addrspace(3) %gep_lo
630 %load_hi = load i16, ptr addrspace(3) %ptr
631 %to.hi = insertelement <2 x i16> undef, i16 %load_hi, i32 1
632 %op.hi = add <2 x i16> %to.hi, <i16 12, i16 12>
633 %result = insertelement <2 x i16> %op.hi, i16 %load_lo, i32 0
634 ret <2 x i16> %result
637 ; The volatile operations aren't put on the same chain
638 define <2 x i16> @chain_hi_to_lo_group_other_dep_multi_chain(ptr addrspace(3) %ptr) {
639 ; GFX900-LABEL: chain_hi_to_lo_group_other_dep_multi_chain:
640 ; GFX900: ; %bb.0: ; %bb
641 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
642 ; GFX900-NEXT: ds_read_u16 v1, v0 offset:2
643 ; GFX900-NEXT: ds_read_u16_d16_hi v0, v0
644 ; GFX900-NEXT: s_mov_b32 s4, 0xffff
645 ; GFX900-NEXT: s_waitcnt lgkmcnt(0)
646 ; GFX900-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
647 ; GFX900-NEXT: v_bfi_b32 v0, s4, v1, v0
648 ; GFX900-NEXT: s_setpc_b64 s[30:31]
650 ; FLATSCR-LABEL: chain_hi_to_lo_group_other_dep_multi_chain:
651 ; FLATSCR: ; %bb.0: ; %bb
652 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
653 ; FLATSCR-NEXT: ds_read_u16 v1, v0 offset:2
654 ; FLATSCR-NEXT: ds_read_u16_d16_hi v0, v0
655 ; FLATSCR-NEXT: s_mov_b32 s0, 0xffff
656 ; FLATSCR-NEXT: s_waitcnt lgkmcnt(0)
657 ; FLATSCR-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
658 ; FLATSCR-NEXT: v_bfi_b32 v0, s0, v1, v0
659 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
661 ; GFX10-LABEL: chain_hi_to_lo_group_other_dep_multi_chain:
662 ; GFX10: ; %bb.0: ; %bb
663 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
664 ; GFX10-NEXT: ds_read_u16 v1, v0 offset:2
665 ; GFX10-NEXT: ds_read_u16_d16_hi v0, v0
666 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
667 ; GFX10-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
668 ; GFX10-NEXT: v_bfi_b32 v0, 0xffff, v1, v0
669 ; GFX10-NEXT: s_setpc_b64 s[30:31]
671 ; GFX11-LABEL: chain_hi_to_lo_group_other_dep_multi_chain:
672 ; GFX11: ; %bb.0: ; %bb
673 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
674 ; GFX11-NEXT: ds_load_u16 v1, v0 offset:2
675 ; GFX11-NEXT: ds_load_u16_d16_hi v0, v0
676 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
677 ; GFX11-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
678 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
679 ; GFX11-NEXT: v_bfi_b32 v0, 0xffff, v1, v0
680 ; GFX11-NEXT: s_setpc_b64 s[30:31]
682 %gep_lo = getelementptr inbounds i16, ptr addrspace(3) %ptr, i64 1
683 %load_lo = load volatile i16, ptr addrspace(3) %gep_lo
684 %load_hi = load volatile i16, ptr addrspace(3) %ptr
685 %to.hi = insertelement <2 x i16> undef, i16 %load_hi, i32 1
686 %op.hi = add <2 x i16> %to.hi, <i16 12, i16 12>
687 %result = insertelement <2 x i16> %op.hi, i16 %load_lo, i32 0
688 ret <2 x i16> %result
691 define <2 x i16> @chain_hi_to_lo_private_other_dep(ptr addrspace(5) %ptr) {
692 ; GFX900-LABEL: chain_hi_to_lo_private_other_dep:
693 ; GFX900: ; %bb.0: ; %bb
694 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
695 ; GFX900-NEXT: buffer_load_short_d16_hi v1, v0, s[0:3], 0 offen
696 ; GFX900-NEXT: s_waitcnt vmcnt(0)
697 ; GFX900-NEXT: v_pk_sub_u16 v1, v1, -12 op_sel_hi:[1,0]
698 ; GFX900-NEXT: buffer_load_short_d16 v1, v0, s[0:3], 0 offen offset:2
699 ; GFX900-NEXT: s_waitcnt vmcnt(0)
700 ; GFX900-NEXT: v_mov_b32_e32 v0, v1
701 ; GFX900-NEXT: s_setpc_b64 s[30:31]
703 ; FLATSCR-LABEL: chain_hi_to_lo_private_other_dep:
704 ; FLATSCR: ; %bb.0: ; %bb
705 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
706 ; FLATSCR-NEXT: scratch_load_short_d16_hi v1, v0, off
707 ; FLATSCR-NEXT: v_add_u32_e32 v2, 2, v0
708 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
709 ; FLATSCR-NEXT: v_pk_sub_u16 v0, v1, -12 op_sel_hi:[1,0]
710 ; FLATSCR-NEXT: scratch_load_short_d16 v0, v2, off
711 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
712 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
714 ; GFX10_DEFAULT-LABEL: chain_hi_to_lo_private_other_dep:
715 ; GFX10_DEFAULT: ; %bb.0: ; %bb
716 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
717 ; GFX10_DEFAULT-NEXT: buffer_load_short_d16_hi v1, v0, s[0:3], 0 offen
718 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
719 ; GFX10_DEFAULT-NEXT: v_pk_sub_u16 v1, v1, -12 op_sel_hi:[1,0]
720 ; GFX10_DEFAULT-NEXT: buffer_load_short_d16 v1, v0, s[0:3], 0 offen offset:2
721 ; GFX10_DEFAULT-NEXT: s_waitcnt vmcnt(0)
722 ; GFX10_DEFAULT-NEXT: v_mov_b32_e32 v0, v1
723 ; GFX10_DEFAULT-NEXT: s_setpc_b64 s[30:31]
725 ; FLATSCR_GFX10-LABEL: chain_hi_to_lo_private_other_dep:
726 ; FLATSCR_GFX10: ; %bb.0: ; %bb
727 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
728 ; FLATSCR_GFX10-NEXT: scratch_load_short_d16_hi v1, v0, off
729 ; FLATSCR_GFX10-NEXT: v_add_nc_u32_e32 v2, 2, v0
730 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
731 ; FLATSCR_GFX10-NEXT: v_pk_sub_u16 v0, v1, -12 op_sel_hi:[1,0]
732 ; FLATSCR_GFX10-NEXT: scratch_load_short_d16 v0, v2, off
733 ; FLATSCR_GFX10-NEXT: s_waitcnt vmcnt(0)
734 ; FLATSCR_GFX10-NEXT: s_setpc_b64 s[30:31]
736 ; GFX11-LABEL: chain_hi_to_lo_private_other_dep:
737 ; GFX11: ; %bb.0: ; %bb
738 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
739 ; GFX11-NEXT: scratch_load_d16_hi_b16 v1, v0, off
740 ; GFX11-NEXT: v_add_nc_u32_e32 v2, 2, v0
741 ; GFX11-NEXT: s_waitcnt vmcnt(0)
742 ; GFX11-NEXT: v_pk_sub_u16 v0, v1, -12 op_sel_hi:[1,0]
743 ; GFX11-NEXT: scratch_load_d16_b16 v0, v2, off
744 ; GFX11-NEXT: s_waitcnt vmcnt(0)
745 ; GFX11-NEXT: s_setpc_b64 s[30:31]
747 %gep_lo = getelementptr inbounds i16, ptr addrspace(5) %ptr, i64 1
748 %load_lo = load i16, ptr addrspace(5) %gep_lo
749 %load_hi = load i16, ptr addrspace(5) %ptr
750 %to.hi = insertelement <2 x i16> undef, i16 %load_hi, i32 1
751 %op.hi = add <2 x i16> %to.hi, <i16 12, i16 12>
752 %result = insertelement <2 x i16> %op.hi, i16 %load_lo, i32 0
753 ret <2 x i16> %result
756 define <2 x i16> @chain_hi_to_lo_global_other_dep(ptr addrspace(1) %ptr) {
757 ; GFX900-LABEL: chain_hi_to_lo_global_other_dep:
758 ; GFX900: ; %bb.0: ; %bb
759 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
760 ; GFX900-NEXT: global_load_ushort v2, v[0:1], off offset:2 glc
761 ; GFX900-NEXT: s_waitcnt vmcnt(0)
762 ; GFX900-NEXT: global_load_short_d16_hi v0, v[0:1], off glc
763 ; GFX900-NEXT: s_waitcnt vmcnt(0)
764 ; GFX900-NEXT: s_mov_b32 s4, 0xffff
765 ; GFX900-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
766 ; GFX900-NEXT: v_bfi_b32 v0, s4, v2, v0
767 ; GFX900-NEXT: s_setpc_b64 s[30:31]
769 ; FLATSCR-LABEL: chain_hi_to_lo_global_other_dep:
770 ; FLATSCR: ; %bb.0: ; %bb
771 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
772 ; FLATSCR-NEXT: global_load_ushort v2, v[0:1], off offset:2 glc
773 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
774 ; FLATSCR-NEXT: global_load_short_d16_hi v0, v[0:1], off glc
775 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
776 ; FLATSCR-NEXT: s_mov_b32 s0, 0xffff
777 ; FLATSCR-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
778 ; FLATSCR-NEXT: v_bfi_b32 v0, s0, v2, v0
779 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
781 ; GFX10-LABEL: chain_hi_to_lo_global_other_dep:
782 ; GFX10: ; %bb.0: ; %bb
783 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
784 ; GFX10-NEXT: global_load_ushort v2, v[0:1], off offset:2 glc dlc
785 ; GFX10-NEXT: s_waitcnt vmcnt(0)
786 ; GFX10-NEXT: global_load_short_d16_hi v0, v[0:1], off glc dlc
787 ; GFX10-NEXT: s_waitcnt vmcnt(0)
788 ; GFX10-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
789 ; GFX10-NEXT: v_bfi_b32 v0, 0xffff, v2, v0
790 ; GFX10-NEXT: s_setpc_b64 s[30:31]
792 ; GFX11-LABEL: chain_hi_to_lo_global_other_dep:
793 ; GFX11: ; %bb.0: ; %bb
794 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
795 ; GFX11-NEXT: global_load_u16 v2, v[0:1], off offset:2 glc dlc
796 ; GFX11-NEXT: s_waitcnt vmcnt(0)
797 ; GFX11-NEXT: global_load_d16_hi_b16 v0, v[0:1], off glc dlc
798 ; GFX11-NEXT: s_waitcnt vmcnt(0)
799 ; GFX11-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
800 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
801 ; GFX11-NEXT: v_bfi_b32 v0, 0xffff, v2, v0
802 ; GFX11-NEXT: s_setpc_b64 s[30:31]
804 %gep_lo = getelementptr inbounds i16, ptr addrspace(1) %ptr, i64 1
805 %load_lo = load volatile i16, ptr addrspace(1) %gep_lo
806 %load_hi = load volatile i16, ptr addrspace(1) %ptr
807 %to.hi = insertelement <2 x i16> undef, i16 %load_hi, i32 1
808 %op.hi = add <2 x i16> %to.hi, <i16 12, i16 12>
809 %result = insertelement <2 x i16> %op.hi, i16 %load_lo, i32 0
810 ret <2 x i16> %result
813 define <2 x i16> @chain_hi_to_lo_flat_other_dep(ptr addrspace(0) %ptr) {
814 ; GFX900-LABEL: chain_hi_to_lo_flat_other_dep:
815 ; GFX900: ; %bb.0: ; %bb
816 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
817 ; GFX900-NEXT: flat_load_ushort v2, v[0:1] offset:2 glc
818 ; GFX900-NEXT: s_waitcnt vmcnt(0)
819 ; GFX900-NEXT: flat_load_short_d16_hi v0, v[0:1] glc
820 ; GFX900-NEXT: s_waitcnt vmcnt(0)
821 ; GFX900-NEXT: s_mov_b32 s4, 0xffff
822 ; GFX900-NEXT: s_waitcnt lgkmcnt(0)
823 ; GFX900-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
824 ; GFX900-NEXT: v_bfi_b32 v0, s4, v2, v0
825 ; GFX900-NEXT: s_setpc_b64 s[30:31]
827 ; FLATSCR-LABEL: chain_hi_to_lo_flat_other_dep:
828 ; FLATSCR: ; %bb.0: ; %bb
829 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
830 ; FLATSCR-NEXT: flat_load_ushort v2, v[0:1] offset:2 glc
831 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
832 ; FLATSCR-NEXT: flat_load_short_d16_hi v0, v[0:1] glc
833 ; FLATSCR-NEXT: s_waitcnt vmcnt(0)
834 ; FLATSCR-NEXT: s_mov_b32 s0, 0xffff
835 ; FLATSCR-NEXT: s_waitcnt lgkmcnt(0)
836 ; FLATSCR-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
837 ; FLATSCR-NEXT: v_bfi_b32 v0, s0, v2, v0
838 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
840 ; GFX10-LABEL: chain_hi_to_lo_flat_other_dep:
841 ; GFX10: ; %bb.0: ; %bb
842 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
843 ; GFX10-NEXT: v_add_co_u32 v2, vcc_lo, v0, 2
844 ; GFX10-NEXT: v_add_co_ci_u32_e32 v3, vcc_lo, 0, v1, vcc_lo
845 ; GFX10-NEXT: flat_load_ushort v2, v[2:3] glc dlc
846 ; GFX10-NEXT: s_waitcnt vmcnt(0)
847 ; GFX10-NEXT: flat_load_short_d16_hi v0, v[0:1] glc dlc
848 ; GFX10-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
849 ; GFX10-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
850 ; GFX10-NEXT: v_bfi_b32 v0, 0xffff, v2, v0
851 ; GFX10-NEXT: s_setpc_b64 s[30:31]
853 ; GFX11-LABEL: chain_hi_to_lo_flat_other_dep:
854 ; GFX11: ; %bb.0: ; %bb
855 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
856 ; GFX11-NEXT: flat_load_u16 v2, v[0:1] offset:2 glc dlc
857 ; GFX11-NEXT: s_waitcnt vmcnt(0)
858 ; GFX11-NEXT: flat_load_d16_hi_b16 v0, v[0:1] glc dlc
859 ; GFX11-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
860 ; GFX11-NEXT: v_pk_sub_u16 v0, v0, -12 op_sel_hi:[1,0]
861 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
862 ; GFX11-NEXT: v_bfi_b32 v0, 0xffff, v2, v0
863 ; GFX11-NEXT: s_setpc_b64 s[30:31]
865 %gep_lo = getelementptr inbounds i16, ptr addrspace(0) %ptr, i64 1
866 %load_lo = load volatile i16, ptr addrspace(0) %gep_lo
867 %load_hi = load volatile i16, ptr addrspace(0) %ptr
868 %to.hi = insertelement <2 x i16> undef, i16 %load_hi, i32 1
869 %op.hi = add <2 x i16> %to.hi, <i16 12, i16 12>
870 %result = insertelement <2 x i16> %op.hi, i16 %load_lo, i32 0
871 ret <2 x i16> %result
874 define <2 x i16> @chain_hi_to_lo_group_may_alias_store(ptr addrspace(3) %ptr, ptr addrspace(3) %may.alias) {
875 ; GFX900-LABEL: chain_hi_to_lo_group_may_alias_store:
876 ; GFX900: ; %bb.0: ; %bb
877 ; GFX900-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
878 ; GFX900-NEXT: v_mov_b32_e32 v3, 0x7b
879 ; GFX900-NEXT: ds_read_u16 v2, v0
880 ; GFX900-NEXT: ds_write_b16 v1, v3
881 ; GFX900-NEXT: ds_read_u16 v0, v0 offset:2
882 ; GFX900-NEXT: s_mov_b32 s4, 0x5040100
883 ; GFX900-NEXT: s_waitcnt lgkmcnt(0)
884 ; GFX900-NEXT: v_perm_b32 v0, v2, v0, s4
885 ; GFX900-NEXT: s_setpc_b64 s[30:31]
887 ; FLATSCR-LABEL: chain_hi_to_lo_group_may_alias_store:
888 ; FLATSCR: ; %bb.0: ; %bb
889 ; FLATSCR-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
890 ; FLATSCR-NEXT: v_mov_b32_e32 v3, 0x7b
891 ; FLATSCR-NEXT: ds_read_u16 v2, v0
892 ; FLATSCR-NEXT: ds_write_b16 v1, v3
893 ; FLATSCR-NEXT: ds_read_u16 v0, v0 offset:2
894 ; FLATSCR-NEXT: s_mov_b32 s0, 0x5040100
895 ; FLATSCR-NEXT: s_waitcnt lgkmcnt(0)
896 ; FLATSCR-NEXT: v_perm_b32 v0, v2, v0, s0
897 ; FLATSCR-NEXT: s_setpc_b64 s[30:31]
899 ; GFX10-LABEL: chain_hi_to_lo_group_may_alias_store:
900 ; GFX10: ; %bb.0: ; %bb
901 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
902 ; GFX10-NEXT: v_mov_b32_e32 v2, 0x7b
903 ; GFX10-NEXT: ds_read_u16 v3, v0
904 ; GFX10-NEXT: ds_write_b16 v1, v2
905 ; GFX10-NEXT: ds_read_u16 v0, v0 offset:2
906 ; GFX10-NEXT: s_waitcnt lgkmcnt(0)
907 ; GFX10-NEXT: v_perm_b32 v0, v3, v0, 0x5040100
908 ; GFX10-NEXT: s_setpc_b64 s[30:31]
910 ; GFX11-LABEL: chain_hi_to_lo_group_may_alias_store:
911 ; GFX11: ; %bb.0: ; %bb
912 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
913 ; GFX11-NEXT: v_mov_b32_e32 v2, 0x7b
914 ; GFX11-NEXT: ds_load_u16 v3, v0
915 ; GFX11-NEXT: ds_store_b16 v1, v2
916 ; GFX11-NEXT: ds_load_u16 v0, v0 offset:2
917 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
918 ; GFX11-NEXT: v_perm_b32 v0, v3, v0, 0x5040100
919 ; GFX11-NEXT: s_setpc_b64 s[30:31]
921 %gep_lo = getelementptr inbounds i16, ptr addrspace(3) %ptr, i64 1
922 %load_hi = load i16, ptr addrspace(3) %ptr
923 store i16 123, ptr addrspace(3) %may.alias
924 %load_lo = load i16, ptr addrspace(3) %gep_lo
926 %to.hi = insertelement <2 x i16> undef, i16 %load_hi, i32 1
927 %result = insertelement <2 x i16> %to.hi, i16 %load_lo, i32 0
928 ret <2 x i16> %result