blob: f839129fc3d871d45b658b29fca1c7bea615d71c [file] [log] [blame]
Tom Stellard115a6152016-11-10 16:02:37 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI %s
Matt Arsenault7aad8fd2017-01-24 22:02:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI %s
Matt Arsenault364a6742014-06-11 17:50:44 +00003
Konstantin Zhuravlyovf74fc602016-10-07 14:22:58 +00004declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
5declare i32 @llvm.amdgcn.workitem.id.y() nounwind readnone
6
Tom Stellard115a6152016-11-10 16:02:37 +00007; GCN-LABEL: {{^}}load_i8_to_f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +00008; GCN: {{buffer|flat}}_load_ubyte [[LOADREG:v[0-9]+]],
Tom Stellard115a6152016-11-10 16:02:37 +00009; GCN-NOT: bfe
10; GCN-NOT: lshr
11; GCN: v_cvt_f32_ubyte0_e32 [[CONV:v[0-9]+]], [[LOADREG]]
12; GCN: buffer_store_dword [[CONV]],
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000013define amdgpu_kernel void @load_i8_to_f32(float addrspace(1)* noalias %out, i8 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +000014 %tid = call i32 @llvm.amdgcn.workitem.id.x()
15 %gep = getelementptr i8, i8 addrspace(1)* %in, i32 %tid
16 %load = load i8, i8 addrspace(1)* %gep, align 1
Matt Arsenault364a6742014-06-11 17:50:44 +000017 %cvt = uitofp i8 %load to float
18 store float %cvt, float addrspace(1)* %out, align 4
19 ret void
20}
21
Tom Stellard115a6152016-11-10 16:02:37 +000022; GCN-LABEL: {{^}}load_v2i8_to_v2f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +000023; GCN: {{buffer|flat}}_load_ushort [[LD:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +000024; GCN-DAG: v_cvt_f32_ubyte1_e32 v[[HIRESULT:[0-9]+]], [[LD]]
25; GCN-DAG: v_cvt_f32_ubyte0_e32 v[[LORESULT:[0-9]+]], [[LD]]
26; GCN: buffer_store_dwordx2 v{{\[}}[[LORESULT]]:[[HIRESULT]]{{\]}},
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000027define amdgpu_kernel void @load_v2i8_to_v2f32(<2 x float> addrspace(1)* noalias %out, <2 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +000028 %tid = call i32 @llvm.amdgcn.workitem.id.x()
29 %gep = getelementptr <2 x i8>, <2 x i8> addrspace(1)* %in, i32 %tid
30 %load = load <2 x i8>, <2 x i8> addrspace(1)* %gep, align 2
Matt Arsenault364a6742014-06-11 17:50:44 +000031 %cvt = uitofp <2 x i8> %load to <2 x float>
32 store <2 x float> %cvt, <2 x float> addrspace(1)* %out, align 16
33 ret void
34}
35
Tom Stellard115a6152016-11-10 16:02:37 +000036; GCN-LABEL: {{^}}load_v3i8_to_v3f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +000037; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +000038; GCN-NOT: v_cvt_f32_ubyte3_e32
39; GCN-DAG: v_cvt_f32_ubyte2_e32 v{{[0-9]+}}, [[VAL]]
40; GCN-DAG: v_cvt_f32_ubyte1_e32 v[[HIRESULT:[0-9]+]], [[VAL]]
41; GCN-DAG: v_cvt_f32_ubyte0_e32 v[[LORESULT:[0-9]+]], [[VAL]]
42; GCN: buffer_store_dwordx2 v{{\[}}[[LORESULT]]:[[HIRESULT]]{{\]}},
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000043define amdgpu_kernel void @load_v3i8_to_v3f32(<3 x float> addrspace(1)* noalias %out, <3 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +000044 %tid = call i32 @llvm.amdgcn.workitem.id.x()
45 %gep = getelementptr <3 x i8>, <3 x i8> addrspace(1)* %in, i32 %tid
46 %load = load <3 x i8>, <3 x i8> addrspace(1)* %gep, align 4
Matt Arsenault364a6742014-06-11 17:50:44 +000047 %cvt = uitofp <3 x i8> %load to <3 x float>
48 store <3 x float> %cvt, <3 x float> addrspace(1)* %out, align 16
49 ret void
50}
51
Tom Stellard115a6152016-11-10 16:02:37 +000052; GCN-LABEL: {{^}}load_v4i8_to_v4f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +000053; GCN: {{buffer|flat}}_load_dword [[LOADREG:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +000054; GCN-NOT: bfe
55; GCN-NOT: lshr
56; GCN-DAG: v_cvt_f32_ubyte3_e32 v[[HIRESULT:[0-9]+]], [[LOADREG]]
57; GCN-DAG: v_cvt_f32_ubyte2_e32 v{{[0-9]+}}, [[LOADREG]]
58; GCN-DAG: v_cvt_f32_ubyte1_e32 v{{[0-9]+}}, [[LOADREG]]
59; GCN-DAG: v_cvt_f32_ubyte0_e32 v[[LORESULT:[0-9]+]], [[LOADREG]]
60; GCN: buffer_store_dwordx4 v{{\[}}[[LORESULT]]:[[HIRESULT]]{{\]}},
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000061define amdgpu_kernel void @load_v4i8_to_v4f32(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +000062 %tid = call i32 @llvm.amdgcn.workitem.id.x()
63 %gep = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid
64 %load = load <4 x i8>, <4 x i8> addrspace(1)* %gep, align 4
Matt Arsenaultbd223422015-01-14 01:35:17 +000065 %cvt = uitofp <4 x i8> %load to <4 x float>
66 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
67 ret void
68}
69
70; This should not be adding instructions to shift into the correct
71; position in the word for the component.
72
Matt Arsenault8af47a02016-07-01 22:55:55 +000073; FIXME: Packing bytes
Tom Stellard115a6152016-11-10 16:02:37 +000074; GCN-LABEL: {{^}}load_v4i8_to_v4f32_unaligned:
Alexander Timofeev982aee62017-07-04 17:32:00 +000075; GCN: {{buffer|flat}}_load_ubyte [[LOADREG3:v[0-9]+]]
76; GCN: {{buffer|flat}}_load_ubyte [[LOADREG2:v[0-9]+]]
77; GCN: {{buffer|flat}}_load_ubyte [[LOADREG1:v[0-9]+]]
78; GCN: {{buffer|flat}}_load_ubyte [[LOADREG0:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +000079; GCN-DAG: v_lshlrev_b32
80; GCN-DAG: v_or_b32
81; GCN-DAG: v_cvt_f32_ubyte0_e32 v[[LORESULT:[0-9]+]],
82; GCN-DAG: v_cvt_f32_ubyte0_e32 v{{[0-9]+}},
83; GCN-DAG: v_cvt_f32_ubyte0_e32 v{{[0-9]+}},
84; GCN-DAG: v_cvt_f32_ubyte0_e32 v[[HIRESULT:[0-9]+]]
Matt Arsenaultbd223422015-01-14 01:35:17 +000085
Tom Stellard115a6152016-11-10 16:02:37 +000086; GCN: buffer_store_dwordx4
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000087define amdgpu_kernel void @load_v4i8_to_v4f32_unaligned(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +000088 %tid = call i32 @llvm.amdgcn.workitem.id.x()
89 %gep = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid
90 %load = load <4 x i8>, <4 x i8> addrspace(1)* %gep, align 1
Matt Arsenault364a6742014-06-11 17:50:44 +000091 %cvt = uitofp <4 x i8> %load to <4 x float>
92 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
93 ret void
94}
95
Konstantin Zhuravlyovf74fc602016-10-07 14:22:58 +000096; FIXME: Need to handle non-uniform case for function below (load without gep).
Matt Arsenault327bb5a2016-07-01 22:47:50 +000097; Instructions still emitted to repack bytes for add use.
Matt Arsenault364a6742014-06-11 17:50:44 +000098
Tom Stellard115a6152016-11-10 16:02:37 +000099; GCN-LABEL: {{^}}load_v4i8_to_v4f32_2_uses:
100; GCN: {{buffer|flat}}_load_dword
101; GCN-DAG: v_cvt_f32_ubyte0_e32
102; GCN-DAG: v_cvt_f32_ubyte1_e32
103; GCN-DAG: v_cvt_f32_ubyte2_e32
104; GCN-DAG: v_cvt_f32_ubyte3_e32
105
106; GCN-DAG: v_lshrrev_b32_e32 v{{[0-9]+}}, 24
Tom Stellard115a6152016-11-10 16:02:37 +0000107
Matt Arsenault327bb5a2016-07-01 22:47:50 +0000108; SI-DAG: v_lshlrev_b32_e32 v{{[0-9]+}}, 16
109; SI-DAG: v_lshlrev_b32_e32 v{{[0-9]+}}, 8
110; SI-DAG: v_and_b32_e32 v{{[0-9]+}}, 0xffff,
Nirav Davea81682a2016-10-13 20:23:25 +0000111; SI-DAG: v_and_b32_e32 v{{[0-9]+}}, 0xff00,
Matt Arsenault327bb5a2016-07-01 22:47:50 +0000112; SI-DAG: v_add_i32
113
Tom Stellard115a6152016-11-10 16:02:37 +0000114; VI-DAG: v_and_b32_e32 v{{[0-9]+}}, 0xffffff00,
115; VI-DAG: v_add_u16_e32
116; VI-DAG: v_add_u16_e32
Matt Arsenault327bb5a2016-07-01 22:47:50 +0000117
Tom Stellard115a6152016-11-10 16:02:37 +0000118; GCN: {{buffer|flat}}_store_dwordx4
119; GCN: {{buffer|flat}}_store_dword
120
121; GCN: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000122define amdgpu_kernel void @load_v4i8_to_v4f32_2_uses(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %out2, <4 x i8> addrspace(1)* noalias %in) nounwind {
Konstantin Zhuravlyovf74fc602016-10-07 14:22:58 +0000123 %tid.x = call i32 @llvm.amdgcn.workitem.id.x()
124 %in.ptr = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid.x
125 %load = load <4 x i8>, <4 x i8> addrspace(1)* %in.ptr, align 4
Matt Arsenault364a6742014-06-11 17:50:44 +0000126 %cvt = uitofp <4 x i8> %load to <4 x float>
127 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
128 %add = add <4 x i8> %load, <i8 9, i8 9, i8 9, i8 9> ; Second use of %load
129 store <4 x i8> %add, <4 x i8> addrspace(1)* %out2, align 4
130 ret void
131}
132
133; Make sure this doesn't crash.
Tom Stellard115a6152016-11-10 16:02:37 +0000134; GCN-LABEL: {{^}}load_v7i8_to_v7f32:
135; GCN: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000136define amdgpu_kernel void @load_v7i8_to_v7f32(<7 x float> addrspace(1)* noalias %out, <7 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000137 %tid = call i32 @llvm.amdgcn.workitem.id.x()
138 %gep = getelementptr <7 x i8>, <7 x i8> addrspace(1)* %in, i32 %tid
139 %load = load <7 x i8>, <7 x i8> addrspace(1)* %gep, align 1
Matt Arsenault364a6742014-06-11 17:50:44 +0000140 %cvt = uitofp <7 x i8> %load to <7 x float>
141 store <7 x float> %cvt, <7 x float> addrspace(1)* %out, align 16
142 ret void
143}
144
Tom Stellard115a6152016-11-10 16:02:37 +0000145; GCN-LABEL: {{^}}load_v8i8_to_v8f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +0000146; GCN: {{buffer|flat}}_load_dwordx2 v{{\[}}[[LOLOAD:[0-9]+]]:[[HILOAD:[0-9]+]]{{\]}},
Tom Stellard115a6152016-11-10 16:02:37 +0000147; GCN-NOT: bfe
148; GCN-NOT: lshr
149; GCN-DAG: v_cvt_f32_ubyte3_e32 v{{[0-9]+}}, v[[LOLOAD]]
150; GCN-DAG: v_cvt_f32_ubyte2_e32 v{{[0-9]+}}, v[[LOLOAD]]
151; GCN-DAG: v_cvt_f32_ubyte1_e32 v{{[0-9]+}}, v[[LOLOAD]]
152; GCN-DAG: v_cvt_f32_ubyte0_e32 v{{[0-9]+}}, v[[LOLOAD]]
153; GCN-DAG: v_cvt_f32_ubyte3_e32 v{{[0-9]+}}, v[[HILOAD]]
154; GCN-DAG: v_cvt_f32_ubyte2_e32 v{{[0-9]+}}, v[[HILOAD]]
155; GCN-DAG: v_cvt_f32_ubyte1_e32 v{{[0-9]+}}, v[[HILOAD]]
156; GCN-DAG: v_cvt_f32_ubyte0_e32 v{{[0-9]+}}, v[[HILOAD]]
157; GCN-NOT: bfe
158; GCN-NOT: lshr
159; GCN: buffer_store_dwordx4
160; GCN: buffer_store_dwordx4
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000161define amdgpu_kernel void @load_v8i8_to_v8f32(<8 x float> addrspace(1)* noalias %out, <8 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000162 %tid = call i32 @llvm.amdgcn.workitem.id.x()
163 %gep = getelementptr <8 x i8>, <8 x i8> addrspace(1)* %in, i32 %tid
164 %load = load <8 x i8>, <8 x i8> addrspace(1)* %gep, align 8
Matt Arsenault364a6742014-06-11 17:50:44 +0000165 %cvt = uitofp <8 x i8> %load to <8 x float>
166 store <8 x float> %cvt, <8 x float> addrspace(1)* %out, align 16
167 ret void
168}
169
Tom Stellard115a6152016-11-10 16:02:37 +0000170; GCN-LABEL: {{^}}i8_zext_inreg_i32_to_f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +0000171; GCN: {{buffer|flat}}_load_dword [[LOADREG:v[0-9]+]],
Tom Stellard115a6152016-11-10 16:02:37 +0000172; GCN: v_add_i32_e32 [[ADD:v[0-9]+]], vcc, 2, [[LOADREG]]
173; GCN-NEXT: v_cvt_f32_ubyte0_e32 [[CONV:v[0-9]+]], [[ADD]]
174; GCN: buffer_store_dword [[CONV]],
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000175define amdgpu_kernel void @i8_zext_inreg_i32_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000176 %tid = call i32 @llvm.amdgcn.workitem.id.x()
177 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
178 %load = load i32, i32 addrspace(1)* %gep, align 4
Matt Arsenault364a6742014-06-11 17:50:44 +0000179 %add = add i32 %load, 2
180 %inreg = and i32 %add, 255
181 %cvt = uitofp i32 %inreg to float
182 store float %cvt, float addrspace(1)* %out, align 4
183 ret void
184}
185
Tom Stellard115a6152016-11-10 16:02:37 +0000186; GCN-LABEL: {{^}}i8_zext_inreg_hi1_to_f32:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000187define amdgpu_kernel void @i8_zext_inreg_hi1_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000188 %tid = call i32 @llvm.amdgcn.workitem.id.x()
189 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
190 %load = load i32, i32 addrspace(1)* %gep, align 4
Matt Arsenault364a6742014-06-11 17:50:44 +0000191 %inreg = and i32 %load, 65280
192 %shr = lshr i32 %inreg, 8
193 %cvt = uitofp i32 %shr to float
194 store float %cvt, float addrspace(1)* %out, align 4
195 ret void
196}
197
Matt Arsenault364a6742014-06-11 17:50:44 +0000198; We don't get these ones because of the zext, but instcombine removes
199; them so it shouldn't really matter.
Tom Stellard115a6152016-11-10 16:02:37 +0000200; GCN-LABEL: {{^}}i8_zext_i32_to_f32:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000201define amdgpu_kernel void @i8_zext_i32_to_f32(float addrspace(1)* noalias %out, i8 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000202 %tid = call i32 @llvm.amdgcn.workitem.id.x()
203 %gep = getelementptr i8, i8 addrspace(1)* %in, i32 %tid
204 %load = load i8, i8 addrspace(1)* %gep, align 1
Matt Arsenault364a6742014-06-11 17:50:44 +0000205 %ext = zext i8 %load to i32
206 %cvt = uitofp i32 %ext to float
207 store float %cvt, float addrspace(1)* %out, align 4
208 ret void
209}
210
Tom Stellard115a6152016-11-10 16:02:37 +0000211; GCN-LABEL: {{^}}v4i8_zext_v4i32_to_v4f32:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000212define amdgpu_kernel void @v4i8_zext_v4i32_to_v4f32(<4 x float> addrspace(1)* noalias %out, <4 x i8> addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000213 %tid = call i32 @llvm.amdgcn.workitem.id.x()
214 %gep = getelementptr <4 x i8>, <4 x i8> addrspace(1)* %in, i32 %tid
215 %load = load <4 x i8>, <4 x i8> addrspace(1)* %gep, align 1
Matt Arsenault364a6742014-06-11 17:50:44 +0000216 %ext = zext <4 x i8> %load to <4 x i32>
217 %cvt = uitofp <4 x i32> %ext to <4 x float>
218 store <4 x float> %cvt, <4 x float> addrspace(1)* %out, align 16
219 ret void
220}
Matt Arsenaulta949dc62016-05-09 16:29:50 +0000221
Tom Stellard115a6152016-11-10 16:02:37 +0000222; GCN-LABEL: {{^}}extract_byte0_to_f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +0000223; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +0000224; GCN-NOT: [[VAL]]
225; GCN: v_cvt_f32_ubyte0_e32 [[CONV:v[0-9]+]], [[VAL]]
226; GCN: buffer_store_dword [[CONV]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000227define amdgpu_kernel void @extract_byte0_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000228 %tid = call i32 @llvm.amdgcn.workitem.id.x()
229 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
230 %val = load i32, i32 addrspace(1)* %gep
Matt Arsenaulta949dc62016-05-09 16:29:50 +0000231 %and = and i32 %val, 255
232 %cvt = uitofp i32 %and to float
233 store float %cvt, float addrspace(1)* %out
234 ret void
235}
236
Tom Stellard115a6152016-11-10 16:02:37 +0000237; GCN-LABEL: {{^}}extract_byte1_to_f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +0000238; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +0000239; GCN-NOT: [[VAL]]
240; GCN: v_cvt_f32_ubyte1_e32 [[CONV:v[0-9]+]], [[VAL]]
241; GCN: buffer_store_dword [[CONV]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000242define amdgpu_kernel void @extract_byte1_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000243 %tid = call i32 @llvm.amdgcn.workitem.id.x()
244 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
245 %val = load i32, i32 addrspace(1)* %gep
Matt Arsenaulta949dc62016-05-09 16:29:50 +0000246 %srl = lshr i32 %val, 8
247 %and = and i32 %srl, 255
248 %cvt = uitofp i32 %and to float
249 store float %cvt, float addrspace(1)* %out
250 ret void
251}
252
Tom Stellard115a6152016-11-10 16:02:37 +0000253; GCN-LABEL: {{^}}extract_byte2_to_f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +0000254; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +0000255; GCN-NOT: [[VAL]]
256; GCN: v_cvt_f32_ubyte2_e32 [[CONV:v[0-9]+]], [[VAL]]
257; GCN: buffer_store_dword [[CONV]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000258define amdgpu_kernel void @extract_byte2_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000259 %tid = call i32 @llvm.amdgcn.workitem.id.x()
260 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
261 %val = load i32, i32 addrspace(1)* %gep
Matt Arsenaulta949dc62016-05-09 16:29:50 +0000262 %srl = lshr i32 %val, 16
263 %and = and i32 %srl, 255
264 %cvt = uitofp i32 %and to float
265 store float %cvt, float addrspace(1)* %out
266 ret void
267}
268
Tom Stellard115a6152016-11-10 16:02:37 +0000269; GCN-LABEL: {{^}}extract_byte3_to_f32:
Alexander Timofeev982aee62017-07-04 17:32:00 +0000270; GCN: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]]
Tom Stellard115a6152016-11-10 16:02:37 +0000271; GCN-NOT: [[VAL]]
272; GCN: v_cvt_f32_ubyte3_e32 [[CONV:v[0-9]+]], [[VAL]]
273; GCN: buffer_store_dword [[CONV]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000274define amdgpu_kernel void @extract_byte3_to_f32(float addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in) nounwind {
Alexander Timofeev982aee62017-07-04 17:32:00 +0000275 %tid = call i32 @llvm.amdgcn.workitem.id.x()
276 %gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
277 %val = load i32, i32 addrspace(1)* %gep
Matt Arsenaulta949dc62016-05-09 16:29:50 +0000278 %srl = lshr i32 %val, 24
279 %and = and i32 %srl, 255
280 %cvt = uitofp i32 %and to float
281 store float %cvt, float addrspace(1)* %out
282 ret void
283}