134
|
1 ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI %s
|
|
2 ; RUN: llc -march=amdgcn -mtriple=amdgcn---amdgiz -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
|
121
|
3
|
|
4 ; GCN-LABEL: {{^}}extract_vector_elt_v2f16:
|
|
5 ; GCN: s_load_dword [[VEC:s[0-9]+]]
|
|
6 ; GCN: s_lshr_b32 [[ELT1:s[0-9]+]], [[VEC]], 16
|
|
7 ; GCN-DAG: v_mov_b32_e32 [[VELT0:v[0-9]+]], [[VEC]]
|
|
8 ; GCN-DAG: v_mov_b32_e32 [[VELT1:v[0-9]+]], [[ELT1]]
|
|
9 ; GCN-DAG: buffer_store_short [[VELT0]]
|
|
10 ; GCN-DAG: buffer_store_short [[VELT1]]
|
134
|
11 define amdgpu_kernel void @extract_vector_elt_v2f16(half addrspace(1)* %out, <2 x half> addrspace(4)* %vec.ptr) #0 {
|
|
12 %vec = load <2 x half>, <2 x half> addrspace(4)* %vec.ptr
|
121
|
13 %p0 = extractelement <2 x half> %vec, i32 0
|
|
14 %p1 = extractelement <2 x half> %vec, i32 1
|
|
15 %out1 = getelementptr half, half addrspace(1)* %out, i32 10
|
|
16 store half %p1, half addrspace(1)* %out, align 2
|
|
17 store half %p0, half addrspace(1)* %out1, align 2
|
|
18 ret void
|
|
19 }
|
|
20
|
|
21 ; GCN-LABEL: {{^}}extract_vector_elt_v2f16_dynamic_sgpr:
|
|
22 ; GCN: s_load_dword [[IDX:s[0-9]+]]
|
|
23 ; GCN: s_load_dword [[VEC:s[0-9]+]]
|
|
24 ; GCN: s_lshl_b32 [[IDX_SCALED:s[0-9]+]], [[IDX]], 16
|
|
25 ; GCN: s_lshr_b32 [[ELT1:s[0-9]+]], [[VEC]], [[IDX_SCALED]]
|
|
26 ; GCN: v_mov_b32_e32 [[VELT1:v[0-9]+]], [[ELT1]]
|
|
27 ; GCN: buffer_store_short [[VELT1]]
|
|
28 ; GCN: ScratchSize: 0
|
134
|
29 define amdgpu_kernel void @extract_vector_elt_v2f16_dynamic_sgpr(half addrspace(1)* %out, <2 x half> addrspace(4)* %vec.ptr, i32 %idx) #0 {
|
|
30 %vec = load <2 x half>, <2 x half> addrspace(4)* %vec.ptr
|
121
|
31 %elt = extractelement <2 x half> %vec, i32 %idx
|
|
32 store half %elt, half addrspace(1)* %out, align 2
|
|
33 ret void
|
|
34 }
|
|
35
|
|
36 ; GCN-LABEL: {{^}}extract_vector_elt_v2f16_dynamic_vgpr:
|
|
37 ; GCN-DAG: s_load_dword [[VEC:s[0-9]+]]
|
|
38 ; GCN-DAG: {{flat|buffer}}_load_dword [[IDX:v[0-9]+]]
|
|
39 ; GCN: v_lshlrev_b32_e32 [[IDX_SCALED:v[0-9]+]], 16, [[IDX]]
|
|
40
|
|
41 ; SI: v_lshr_b32_e32 [[ELT:v[0-9]+]], [[VEC]], [[IDX_SCALED]]
|
|
42 ; VI: v_lshrrev_b32_e64 [[ELT:v[0-9]+]], [[IDX_SCALED]], [[VEC]]
|
|
43
|
|
44
|
|
45 ; SI: buffer_store_short [[ELT]]
|
|
46 ; VI: flat_store_short v{{\[[0-9]+:[0-9]+\]}}, [[ELT]]
|
|
47 ; GCN: ScratchSize: 0{{$}}
|
134
|
48 define amdgpu_kernel void @extract_vector_elt_v2f16_dynamic_vgpr(half addrspace(1)* %out, <2 x half> addrspace(4)* %vec.ptr, i32 addrspace(1)* %idx.ptr) #0 {
|
121
|
49 %tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
50 %tid.ext = sext i32 %tid to i64
|
|
51 %gep = getelementptr inbounds i32, i32 addrspace(1)* %idx.ptr, i64 %tid.ext
|
|
52 %out.gep = getelementptr inbounds half, half addrspace(1)* %out, i64 %tid.ext
|
134
|
53 %vec = load <2 x half>, <2 x half> addrspace(4)* %vec.ptr
|
121
|
54 %idx = load i32, i32 addrspace(1)* %gep
|
|
55 %elt = extractelement <2 x half> %vec, i32 %idx
|
|
56 store half %elt, half addrspace(1)* %out.gep, align 2
|
|
57 ret void
|
|
58 }
|
|
59
|
|
60 ; GCN-LABEL: {{^}}extract_vector_elt_v3f16:
|
|
61 ; GCN: buffer_load_ushort
|
|
62 ; GCN: buffer_store_short
|
|
63 ; GCN: buffer_store_short
|
|
64 define amdgpu_kernel void @extract_vector_elt_v3f16(half addrspace(1)* %out, <3 x half> %foo) #0 {
|
|
65 %p0 = extractelement <3 x half> %foo, i32 0
|
|
66 %p1 = extractelement <3 x half> %foo, i32 2
|
|
67 %out1 = getelementptr half, half addrspace(1)* %out, i32 1
|
|
68 store half %p1, half addrspace(1)* %out, align 2
|
|
69 store half %p0, half addrspace(1)* %out1, align 2
|
|
70 ret void
|
|
71 }
|
|
72
|
|
73 ; GCN-LABEL: {{^}}extract_vector_elt_v4f16:
|
|
74 ; GCN: buffer_load_ushort
|
|
75 ; GCN: buffer_load_ushort
|
|
76 ; GCN: buffer_store_short
|
|
77 ; GCN: buffer_store_short
|
|
78 define amdgpu_kernel void @extract_vector_elt_v4f16(half addrspace(1)* %out, <4 x half> %foo) #0 {
|
|
79 %p0 = extractelement <4 x half> %foo, i32 0
|
|
80 %p1 = extractelement <4 x half> %foo, i32 2
|
|
81 %out1 = getelementptr half, half addrspace(1)* %out, i32 10
|
|
82 store half %p1, half addrspace(1)* %out, align 2
|
|
83 store half %p0, half addrspace(1)* %out1, align 2
|
|
84 ret void
|
|
85 }
|
|
86
|
|
87 ; GCN-LABEL: {{^}}dynamic_extract_vector_elt_v3f16:
|
|
88 ; GCN: buffer_load_ushort
|
|
89 ; GCN: buffer_load_ushort
|
|
90 ; GCN: buffer_load_ushort
|
|
91
|
|
92 ; GCN: buffer_store_short
|
|
93 ; GCN: buffer_store_short
|
|
94 ; GCN: buffer_store_short
|
|
95
|
|
96 ; GCN: buffer_load_ushort
|
|
97 ; GCN: buffer_store_short
|
|
98 define amdgpu_kernel void @dynamic_extract_vector_elt_v3f16(half addrspace(1)* %out, <3 x half> %foo, i32 %idx) #0 {
|
|
99 %p0 = extractelement <3 x half> %foo, i32 %idx
|
|
100 %out1 = getelementptr half, half addrspace(1)* %out, i32 1
|
|
101 store half %p0, half addrspace(1)* %out
|
|
102 ret void
|
|
103 }
|
|
104
|
|
105 ; GCN-LABEL: {{^}}dynamic_extract_vector_elt_v4f16:
|
|
106 ; GCN: buffer_load_ushort
|
|
107 ; GCN: buffer_load_ushort
|
|
108 ; GCN: buffer_load_ushort
|
|
109 ; GCN: buffer_load_ushort
|
|
110
|
|
111 ; GCN: buffer_store_short
|
|
112 ; GCN: buffer_store_short
|
|
113 ; GCN: buffer_store_short
|
|
114 ; GCN: buffer_store_short
|
|
115
|
|
116 ; GCN: buffer_load_ushort
|
|
117 ; GCN: buffer_store_short
|
|
118 define amdgpu_kernel void @dynamic_extract_vector_elt_v4f16(half addrspace(1)* %out, <4 x half> %foo, i32 %idx) #0 {
|
|
119 %p0 = extractelement <4 x half> %foo, i32 %idx
|
|
120 %out1 = getelementptr half, half addrspace(1)* %out, i32 1
|
|
121 store half %p0, half addrspace(1)* %out
|
|
122 ret void
|
|
123 }
|
|
124
|
|
125 declare i32 @llvm.amdgcn.workitem.id.x() #1
|
|
126
|
|
127 attributes #0 = { nounwind }
|
|
128 attributes #1 = { nounwind readnone }
|