blob: 04cd199b81ae5a8e2c8337d8922c5e451033e5cd [file] [log] [blame]
Matt Arsenault9c47dd52016-02-11 06:02:01 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI -check-prefix=FUNC %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 -check-prefix=FUNC %s
Matt Arsenault5e0bdb82016-01-11 22:01:48 +00003
4; FIXME: This should be merged with sint_to_fp.ll, but s_sint_to_fp_v2i64 crashes on r600
5
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +00006; FUNC-LABEL: {{^}}s_sint_to_fp_i64_to_f16:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +00007define amdgpu_kernel void @s_sint_to_fp_i64_to_f16(half addrspace(1)* %out, i64 %in) #0 {
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +00008 %result = sitofp i64 %in to half
9 store half %result, half addrspace(1)* %out
10 ret void
11}
12
13; FUNC-LABEL: {{^}}v_sint_to_fp_i64_to_f16:
14; GCN: {{buffer|flat}}_load_dwordx2
15
16; GCN: v_ashrrev_i32_e32 v{{[0-9]+}}, 31, v{{[0-9]+}}
17; GCN: v_xor_b32
18
19; GCN: v_ffbh_u32
20; GCN: v_ffbh_u32
21; GCN: v_cndmask
22; GCN: v_cndmask
23
24; GCN-DAG: v_cmp_eq_u64
25; GCN-DAG: v_cmp_lt_u64
26
27; GCN: v_xor_b32_e32 v{{[0-9]+}}, 0x80000000, v{{[0-9]+}}
28; GCN: v_cndmask_b32_e{{32|64}} [[SIGN_SEL:v[0-9]+]],
29; GCN: v_cvt_f16_f32_e32 [[SIGN_SEL_F16:v[0-9]+]], [[SIGN_SEL]]
30; GCN: {{buffer|flat}}_store_short {{.*}}[[SIGN_SEL_F16]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000031define amdgpu_kernel void @v_sint_to_fp_i64_to_f16(half addrspace(1)* %out, i64 addrspace(1)* %in) #0 {
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +000032 %tid = call i32 @llvm.amdgcn.workitem.id.x()
33 %in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
34 %out.gep = getelementptr half, half addrspace(1)* %out, i32 %tid
35 %val = load i64, i64 addrspace(1)* %in.gep
36 %result = sitofp i64 %val to half
37 store half %result, half addrspace(1)* %out.gep
38 ret void
39}
40
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000041; FUNC-LABEL: {{^}}s_sint_to_fp_i64_to_f32:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000042define amdgpu_kernel void @s_sint_to_fp_i64_to_f32(float addrspace(1)* %out, i64 %in) #0 {
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000043 %result = sitofp i64 %in to float
44 store float %result, float addrspace(1)* %out
45 ret void
46}
47
48; FUNC-LABEL: {{^}}v_sint_to_fp_i64_to_f32:
49; GCN: {{buffer|flat}}_load_dwordx2
50
Matt Arsenault33e3ece2016-01-18 22:09:04 +000051; GCN: v_ashrrev_i32_e32 v{{[0-9]+}}, 31, v{{[0-9]+}}
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000052; GCN: v_xor_b32
53
54; GCN: v_ffbh_u32
55; GCN: v_ffbh_u32
56; GCN: v_cndmask
57; GCN: v_cndmask
58
Matt Arsenault5d8eb252016-09-30 01:50:20 +000059; GCN-DAG: v_cmp_eq_u64
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000060; GCN-DAG: v_cmp_lt_u64
61
62; GCN: v_xor_b32_e32 v{{[0-9]+}}, 0x80000000, v{{[0-9]+}}
Artem Tamazov13548772016-06-06 15:23:43 +000063; GCN: v_cndmask_b32_e{{32|64}} [[SIGN_SEL:v[0-9]+]],
Tom Stellard46937ca2016-02-12 17:57:54 +000064; GCN: {{buffer|flat}}_store_dword {{.*}}[[SIGN_SEL]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000065define amdgpu_kernel void @v_sint_to_fp_i64_to_f32(float addrspace(1)* %out, i64 addrspace(1)* %in) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000066 %tid = call i32 @llvm.amdgcn.workitem.id.x()
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000067 %in.gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
68 %out.gep = getelementptr float, float addrspace(1)* %out, i32 %tid
69 %val = load i64, i64 addrspace(1)* %in.gep
70 %result = sitofp i64 %val to float
71 store float %result, float addrspace(1)* %out.gep
72 ret void
73}
74
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +000075; FUNC-LABEL: {{^}}s_sint_to_fp_v2i64_to_v2f32:
Matt Arsenaultfa5f7672016-09-14 15:19:03 +000076; GCN-NOT: v_and_b32_e32 v{{[0-9]+}}, -1,
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000077define amdgpu_kernel void @s_sint_to_fp_v2i64_to_v2f32(<2 x float> addrspace(1)* %out, <2 x i64> %in) #0{
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000078 %result = sitofp <2 x i64> %in to <2 x float>
79 store <2 x float> %result, <2 x float> addrspace(1)* %out
80 ret void
81}
82
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +000083; FUNC-LABEL: {{^}}v_sint_to_fp_v4i64_to_v4f32:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000084define amdgpu_kernel void @v_sint_to_fp_v4i64_to_v4f32(<4 x float> addrspace(1)* %out, <4 x i64> addrspace(1)* %in) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000085 %tid = call i32 @llvm.amdgcn.workitem.id.x()
Matt Arsenault5e0bdb82016-01-11 22:01:48 +000086 %in.gep = getelementptr <4 x i64>, <4 x i64> addrspace(1)* %in, i32 %tid
87 %out.gep = getelementptr <4 x float>, <4 x float> addrspace(1)* %out, i32 %tid
88 %value = load <4 x i64>, <4 x i64> addrspace(1)* %in.gep
89 %result = sitofp <4 x i64> %value to <4 x float>
90 store <4 x float> %result, <4 x float> addrspace(1)* %out.gep
91 ret void
92}
93
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +000094; FUNC-LABEL: {{^}}s_sint_to_fp_v2i64_to_v2f16:
95; GCN-NOT: v_and_b32_e32 v{{[0-9]+}}, -1,
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000096define amdgpu_kernel void @s_sint_to_fp_v2i64_to_v2f16(<2 x half> addrspace(1)* %out, <2 x i64> %in) #0{
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +000097 %result = sitofp <2 x i64> %in to <2 x half>
98 store <2 x half> %result, <2 x half> addrspace(1)* %out
99 ret void
100}
101
102; FUNC-LABEL: {{^}}v_sint_to_fp_v4i64_to_v4f16:
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000103define amdgpu_kernel void @v_sint_to_fp_v4i64_to_v4f16(<4 x half> addrspace(1)* %out, <4 x i64> addrspace(1)* %in) #0 {
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000104 %tid = call i32 @llvm.amdgcn.workitem.id.x()
105 %in.gep = getelementptr <4 x i64>, <4 x i64> addrspace(1)* %in, i32 %tid
106 %out.gep = getelementptr <4 x half>, <4 x half> addrspace(1)* %out, i32 %tid
107 %value = load <4 x i64>, <4 x i64> addrspace(1)* %in.gep
108 %result = sitofp <4 x i64> %value to <4 x half>
109 store <4 x half> %result, <4 x half> addrspace(1)* %out.gep
110 ret void
111}
112
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000113declare i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault5e0bdb82016-01-11 22:01:48 +0000114
115attributes #0 = { nounwind }
116attributes #1 = { nounwind readnone }