1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
3
4; GCN-LABEL: {{^}}extract_vector_elt_v2i16:
5; GCN: buffer_load_ushort
6; GCN: buffer_load_ushort
7; GCN: buffer_store_short
8; GCN: buffer_store_short
9define void @extract_vector_elt_v2i16(i16 addrspace(1)* %out, <2 x i16> %foo) #0 {
10  %p0 = extractelement <2 x i16> %foo, i32 0
11  %p1 = extractelement <2 x i16> %foo, i32 1
12  %out1 = getelementptr i16, i16 addrspace(1)* %out, i32 10
13  store i16 %p1, i16 addrspace(1)* %out, align 2
14  store i16 %p0, i16 addrspace(1)* %out1, align 2
15  ret void
16}
17
18; GCN-LABEL: {{^}}extract_vector_elt_v3i16:
19; GCN: buffer_load_ushort
20; GCN: buffer_store_short
21; GCN: buffer_store_short
22define void @extract_vector_elt_v3i16(i16 addrspace(1)* %out, <3 x i16> %foo) #0 {
23  %p0 = extractelement <3 x i16> %foo, i32 0
24  %p1 = extractelement <3 x i16> %foo, i32 2
25  %out1 = getelementptr i16, i16 addrspace(1)* %out, i32 1
26  store i16 %p1, i16 addrspace(1)* %out, align 2
27  store i16 %p0, i16 addrspace(1)* %out1, align 2
28  ret void
29}
30
31; GCN-LABEL: {{^}}extract_vector_elt_v4i16:
32; GCN: buffer_load_ushort
33; GCN: buffer_load_ushort
34; GCN: buffer_store_short
35; GCN: buffer_store_short
36define void @extract_vector_elt_v4i16(i16 addrspace(1)* %out, <4 x i16> %foo) #0 {
37  %p0 = extractelement <4 x i16> %foo, i32 0
38  %p1 = extractelement <4 x i16> %foo, i32 2
39  %out1 = getelementptr i16, i16 addrspace(1)* %out, i32 10
40  store i16 %p1, i16 addrspace(1)* %out, align 2
41  store i16 %p0, i16 addrspace(1)* %out1, align 2
42  ret void
43}
44
45; GCN-LABEL: {{^}}dynamic_extract_vector_elt_v3i16:
46; GCN: buffer_load_ushort
47; GCN: buffer_load_ushort
48; GCN: buffer_load_ushort
49
50; GCN: buffer_store_short
51; GCN: buffer_store_short
52; GCN: buffer_store_short
53
54; GCN: buffer_load_ushort
55; GCN: buffer_store_short
56define void @dynamic_extract_vector_elt_v3i16(i16 addrspace(1)* %out, <3 x i16> %foo, i32 %idx) #0 {
57  %p0 = extractelement <3 x i16> %foo, i32 %idx
58  %out1 = getelementptr i16, i16 addrspace(1)* %out, i32 1
59  store i16 %p0, i16 addrspace(1)* %out
60  ret void
61}
62
63; GCN-LABEL: {{^}}dynamic_extract_vector_elt_v4i16:
64; GCN: buffer_load_ushort
65; GCN: buffer_load_ushort
66; GCN: buffer_load_ushort
67; GCN: buffer_load_ushort
68
69; GCN: buffer_store_short
70; GCN: buffer_store_short
71; GCN: buffer_store_short
72; GCN: buffer_store_short
73
74; GCN: buffer_load_ushort
75; GCN: buffer_store_short
76define void @dynamic_extract_vector_elt_v4i16(i16 addrspace(1)* %out, <4 x i16> %foo, i32 %idx) #0 {
77  %p0 = extractelement <4 x i16> %foo, i32 %idx
78  %out1 = getelementptr i16, i16 addrspace(1)* %out, i32 1
79  store i16 %p0, i16 addrspace(1)* %out
80  ret void
81}
82
83attributes #0 = { nounwind }
84