1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=GCN,FUNC,SI
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefixes=GCN,FUNC,VI
3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=EG -check-prefix=FUNC
5 declare float @llvm.fabs.f32(float) #1
7 ; FUNC-LABEL: {{^}}fp_to_uint_f32_to_i32:
8 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
10 ; GCN: v_cvt_u32_f32_e32
12 define amdgpu_kernel void @fp_to_uint_f32_to_i32 (i32 addrspace(1)* %out, float %in) {
13 %conv = fptoui float %in to i32
14 store i32 %conv, i32 addrspace(1)* %out
18 ; FUNC-LABEL: {{^}}fp_to_uint_v2f32_to_v2i32:
19 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
20 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
22 ; GCN: v_cvt_u32_f32_e32
23 ; GCN: v_cvt_u32_f32_e32
24 define amdgpu_kernel void @fp_to_uint_v2f32_to_v2i32(<2 x i32> addrspace(1)* %out, <2 x float> %in) {
25 %result = fptoui <2 x float> %in to <2 x i32>
26 store <2 x i32> %result, <2 x i32> addrspace(1)* %out
30 ; FUNC-LABEL: {{^}}fp_to_uint_v4f32_to_v4i32:
31 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
32 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
33 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
34 ; EG: FLT_TO_UINT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
35 ; GCN: v_cvt_u32_f32_e32
36 ; GCN: v_cvt_u32_f32_e32
37 ; GCN: v_cvt_u32_f32_e32
38 ; GCN: v_cvt_u32_f32_e32
40 define amdgpu_kernel void @fp_to_uint_v4f32_to_v4i32(<4 x i32> addrspace(1)* %out, <4 x float> addrspace(1)* %in) {
41 %value = load <4 x float>, <4 x float> addrspace(1) * %in
42 %result = fptoui <4 x float> %value to <4 x i32>
43 store <4 x i32> %result, <4 x i32> addrspace(1)* %out
47 ; FUNC: {{^}}fp_to_uint_f32_to_i64:
71 define amdgpu_kernel void @fp_to_uint_f32_to_i64(i64 addrspace(1)* %out, float %x) {
72 %conv = fptoui float %x to i64
73 store i64 %conv, i64 addrspace(1)* %out
77 ; FUNC: {{^}}fp_to_uint_v2f32_to_v2i64:
122 define amdgpu_kernel void @fp_to_uint_v2f32_to_v2i64(<2 x i64> addrspace(1)* %out, <2 x float> %x) {
123 %conv = fptoui <2 x float> %x to <2 x i64>
124 store <2 x i64> %conv, <2 x i64> addrspace(1)* %out
128 ; FUNC: {{^}}fp_to_uint_v4f32_to_v4i64:
215 define amdgpu_kernel void @fp_to_uint_v4f32_to_v4i64(<4 x i64> addrspace(1)* %out, <4 x float> %x) {
216 %conv = fptoui <4 x float> %x to <4 x i64>
217 store <4 x i64> %conv, <4 x i64> addrspace(1)* %out
222 ; FUNC-LABEL: {{^}}fp_to_uint_f32_to_i1:
223 ; GCN: v_cmp_eq_f32_e64 s{{\[[0-9]+:[0-9]+\]}}, 1.0, s{{[0-9]+}}
226 ; EG: SETE_DX10 {{[*]?}} T{{[0-9]+}}.{{[XYZW]}}, KC0[2].Z, 1.0,
227 define amdgpu_kernel void @fp_to_uint_f32_to_i1(i1 addrspace(1)* %out, float %in) #0 {
228 %conv = fptoui float %in to i1
229 store i1 %conv, i1 addrspace(1)* %out
233 ; FUNC-LABEL: {{^}}fp_to_uint_fabs_f32_to_i1:
234 ; GCN: v_cmp_eq_f32_e64 s{{\[[0-9]+:[0-9]+\]}}, 1.0, |s{{[0-9]+}}|
235 define amdgpu_kernel void @fp_to_uint_fabs_f32_to_i1(i1 addrspace(1)* %out, float %in) #0 {
236 %in.fabs = call float @llvm.fabs.f32(float %in)
237 %conv = fptoui float %in.fabs to i1
238 store i1 %conv, i1 addrspace(1)* %out
242 ; FUNC-LABEL: {{^}}fp_to_uint_f32_to_i16:
243 ; The reason different instructions are used on SI and VI is because for
244 ; SI fp_to_uint is legalized by the type legalizer and for VI it is
245 ; legalized by the dag legalizer and they legalize fp_to_uint differently.
246 ; SI: v_cvt_u32_f32_e32 [[VAL:v[0-9]+]], s{{[0-9]+}}
247 ; VI: v_cvt_i32_f32_e32 [[VAL:v[0-9]+]], s{{[0-9]+}}
248 ; GCN: buffer_store_short [[VAL]]
249 define amdgpu_kernel void @fp_to_uint_f32_to_i16(i16 addrspace(1)* %out, float %in) #0 {
250 %uint = fptoui float %in to i16
251 store i16 %uint, i16 addrspace(1)* %out
255 attributes #0 = { nounwind }
256 attributes #1 = { nounwind readnone }