1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI -check-prefix=FUNC %s
4 ; FIXME: This should be merged with sint_to_fp.ll, but s_sint_to_fp_v2i64 crashes on r600
6 ; FUNC-LABEL: {{^}}s_sint_to_fp_i64_to_f16:
7 define amdgpu_kernel void @s_sint_to_fp_i64_to_f16(half addrspace(1)* %out, i64 %in) #0 {
8 %result = sitofp i64 %in to half
9 store half %result, half addrspace(1)* %out
13 ; FUNC-LABEL: {{^}}v_sint_to_fp_i64_to_f16:
14 ; GCN: {{buffer|flat}}_load_dwordx2
16 ; GCN: v_ashrrev_i32_e32 v{{[0-9]+}}, 31, v{{[0-9]+}}
24 ; GCN-DAG: v_cmp_eq_u64
25 ; GCN-DAG: v_cmp_gt_u64
27 ; GCN: v_cndmask_b32_e64 [[SIGN_SEL:v[0-9]+]], v{{[0-9]+}}, -v{{[0-9]+}}
28 ; GCN: v_cvt_f16_f32_e32 [[SIGN_SEL_F16:v[0-9]+]], [[SIGN_SEL]]
29 ; GCN: {{buffer|flat}}_store_short {{.*}}[[SIGN_SEL_F16]]
30 define amdgpu_kernel void @v_sint_to_fp_i64_to_f16(half addrspace(1)* %out, i64 addrspace(1)* %in) #0 {
31 %tid = call i32 @llvm.amdgcn.workitem.id.x()
32 %in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
33 %out.gep = getelementptr half, half addrspace(1)* %out, i32 %tid
34 %val = load i64, i64 addrspace(1)* %in.gep
35 %result = sitofp i64 %val to half
36 store half %result, half addrspace(1)* %out.gep
40 ; FUNC-LABEL: {{^}}s_sint_to_fp_i64_to_f32:
41 define amdgpu_kernel void @s_sint_to_fp_i64_to_f32(float addrspace(1)* %out, i64 %in) #0 {
42 %result = sitofp i64 %in to float
43 store float %result, float addrspace(1)* %out
47 ; FUNC-LABEL: {{^}}v_sint_to_fp_i64_to_f32:
48 ; GCN: {{buffer|flat}}_load_dwordx2
50 ; GCN: v_ashrrev_i32_e32 v{{[0-9]+}}, 31, v{{[0-9]+}}
58 ; GCN-DAG: v_cmp_eq_u64
59 ; GCN-DAG: v_cmp_gt_u64
61 ; GCN: v_cndmask_b32_e64 [[SIGN_SEL:v[0-9]+]], v{{[0-9]+}}, -v{{[0-9]+}}
62 ; GCN: {{buffer|flat}}_store_dword {{.*}}[[SIGN_SEL]]
63 define amdgpu_kernel void @v_sint_to_fp_i64_to_f32(float addrspace(1)* %out, i64 addrspace(1)* %in) #0 {
64 %tid = call i32 @llvm.amdgcn.workitem.id.x()
65 %in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
66 %out.gep = getelementptr float, float addrspace(1)* %out, i32 %tid
67 %val = load i64, i64 addrspace(1)* %in.gep
68 %result = sitofp i64 %val to float
69 store float %result, float addrspace(1)* %out.gep
73 ; FUNC-LABEL: {{^}}s_sint_to_fp_v2i64_to_v2f32:
74 ; GCN-NOT: v_and_b32_e32 v{{[0-9]+}}, -1,
75 define amdgpu_kernel void @s_sint_to_fp_v2i64_to_v2f32(<2 x float> addrspace(1)* %out, <2 x i64> %in) #0{
76 %result = sitofp <2 x i64> %in to <2 x float>
77 store <2 x float> %result, <2 x float> addrspace(1)* %out
81 ; FUNC-LABEL: {{^}}v_sint_to_fp_v4i64_to_v4f32:
82 define amdgpu_kernel void @v_sint_to_fp_v4i64_to_v4f32(<4 x float> addrspace(1)* %out, <4 x i64> addrspace(1)* %in) #0 {
83 %tid = call i32 @llvm.amdgcn.workitem.id.x()
84 %in.gep = getelementptr <4 x i64>, <4 x i64> addrspace(1)* %in, i32 %tid
85 %out.gep = getelementptr <4 x float>, <4 x float> addrspace(1)* %out, i32 %tid
86 %value = load <4 x i64>, <4 x i64> addrspace(1)* %in.gep
87 %result = sitofp <4 x i64> %value to <4 x float>
88 store <4 x float> %result, <4 x float> addrspace(1)* %out.gep
92 ; FUNC-LABEL: {{^}}s_sint_to_fp_v2i64_to_v2f16:
93 ; GCN-NOT: v_and_b32_e32 v{{[0-9]+}}, -1,
94 define amdgpu_kernel void @s_sint_to_fp_v2i64_to_v2f16(<2 x half> addrspace(1)* %out, <2 x i64> %in) #0{
95 %result = sitofp <2 x i64> %in to <2 x half>
96 store <2 x half> %result, <2 x half> addrspace(1)* %out
100 ; FUNC-LABEL: {{^}}v_sint_to_fp_v4i64_to_v4f16:
101 define amdgpu_kernel void @v_sint_to_fp_v4i64_to_v4f16(<4 x half> addrspace(1)* %out, <4 x i64> addrspace(1)* %in) #0 {
102 %tid = call i32 @llvm.amdgcn.workitem.id.x()
103 %in.gep = getelementptr <4 x i64>, <4 x i64> addrspace(1)* %in, i32 %tid
104 %out.gep = getelementptr <4 x half>, <4 x half> addrspace(1)* %out, i32 %tid
105 %value = load <4 x i64>, <4 x i64> addrspace(1)* %in.gep
106 %result = sitofp <4 x i64> %value to <4 x half>
107 store <4 x half> %result, <4 x half> addrspace(1)* %out.gep
111 declare i32 @llvm.amdgcn.workitem.id.x() #1
113 attributes #0 = { nounwind }
114 attributes #1 = { nounwind readnone }