1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=SI --check-prefix=FUNC --check-prefix=GCN
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=VI --check-prefix=FUNC --check-prefix=GCN
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_sint_i32:
8 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
9 ; SI: v_cvt_i32_f32_e32
11 define amdgpu_kernel void @fp_to_sint_i32(i32 addrspace(1)* %out, float %in) {
12 %conv = fptosi float %in to i32
13 store i32 %conv, i32 addrspace(1)* %out
17 ; FUNC-LABEL: {{^}}fp_to_sint_i32_fabs:
18 ; SI: v_cvt_i32_f32_e64 v{{[0-9]+}}, |s{{[0-9]+}}|{{$}}
19 define amdgpu_kernel void @fp_to_sint_i32_fabs(i32 addrspace(1)* %out, float %in) {
20 %in.fabs = call float @llvm.fabs.f32(float %in)
21 %conv = fptosi float %in.fabs to i32
22 store i32 %conv, i32 addrspace(1)* %out
26 ; FUNC-LABEL: {{^}}fp_to_sint_v2i32:
27 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
28 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
29 ; SI: v_cvt_i32_f32_e32
30 ; SI: v_cvt_i32_f32_e32
31 define amdgpu_kernel void @fp_to_sint_v2i32(<2 x i32> addrspace(1)* %out, <2 x float> %in) {
32 %result = fptosi <2 x float> %in to <2 x i32>
33 store <2 x i32> %result, <2 x i32> addrspace(1)* %out
37 ; FUNC-LABEL: {{^}}fp_to_sint_v4i32:
38 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
39 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW]}}
40 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
41 ; EG: FLT_TO_INT {{\** *}}T{{[0-9]+\.[XYZW], PV\.[XYZW]}}
42 ; SI: v_cvt_i32_f32_e32
43 ; SI: v_cvt_i32_f32_e32
44 ; SI: v_cvt_i32_f32_e32
45 ; SI: v_cvt_i32_f32_e32
46 define amdgpu_kernel void @fp_to_sint_v4i32(<4 x i32> addrspace(1)* %out, <4 x float> addrspace(1)* %in) {
47 %value = load <4 x float>, <4 x float> addrspace(1) * %in
48 %result = fptosi <4 x float> %value to <4 x i32>
49 store <4 x i32> %result, <4 x i32> addrspace(1)* %out
53 ; FUNC-LABEL: {{^}}fp_to_sint_i64:
77 ; Check that the compiler doesn't crash with a "cannot select" error
79 define amdgpu_kernel void @fp_to_sint_i64 (i64 addrspace(1)* %out, float %in) {
81 %0 = fptosi float %in to i64
82 store i64 %0, i64 addrspace(1)* %out
86 ; FUNC: {{^}}fp_to_sint_v2i64:
131 define amdgpu_kernel void @fp_to_sint_v2i64(<2 x i64> addrspace(1)* %out, <2 x float> %x) {
132 %conv = fptosi <2 x float> %x to <2 x i64>
133 store <2 x i64> %conv, <2 x i64> addrspace(1)* %out
137 ; FUNC: {{^}}fp_to_sint_v4i64:
224 define amdgpu_kernel void @fp_to_sint_v4i64(<4 x i64> addrspace(1)* %out, <4 x float> %x) {
225 %conv = fptosi <4 x float> %x to <4 x i64>
226 store <4 x i64> %conv, <4 x i64> addrspace(1)* %out
230 ; FUNC-LABEL: {{^}}fp_to_uint_f32_to_i1:
231 ; SI: v_cmp_eq_f32_e64 s{{\[[0-9]+:[0-9]+\]}}, -1.0, s{{[0-9]+}}
234 ; EG: SETE_DX10 {{[*]?}} T{{[0-9]+}}.{{[XYZW]}}, KC0[2].Z, literal.y,
235 ; EG-NEXT: -1082130432(-1.000000e+00)
236 define amdgpu_kernel void @fp_to_uint_f32_to_i1(i1 addrspace(1)* %out, float %in) #0 {
237 %conv = fptosi float %in to i1
238 store i1 %conv, i1 addrspace(1)* %out
242 ; FUNC-LABEL: {{^}}fp_to_uint_fabs_f32_to_i1:
243 ; SI: v_cmp_eq_f32_e64 s{{\[[0-9]+:[0-9]+\]}}, -1.0, |s{{[0-9]+}}|
244 define amdgpu_kernel void @fp_to_uint_fabs_f32_to_i1(i1 addrspace(1)* %out, float %in) #0 {
245 %in.fabs = call float @llvm.fabs.f32(float %in)
246 %conv = fptosi float %in.fabs to i1
247 store i1 %conv, i1 addrspace(1)* %out
251 ; FUNC-LABEL: {{^}}fp_to_sint_f32_i16:
252 ; GCN: v_cvt_i32_f32_e32 [[VAL:v[0-9]+]], s{{[0-9]+}}
253 ; GCN: buffer_store_short [[VAL]]
254 define amdgpu_kernel void @fp_to_sint_f32_i16(i16 addrspace(1)* %out, float %in) #0 {
255 %sint = fptosi float %in to i16
256 store i16 %sint, i16 addrspace(1)* %out
260 attributes #0 = { nounwind }
261 attributes #1 = { nounwind readnone }