blob: 75ffdd2cc85a461e6f7171ef2fb5e8e02d3ab950 [file] [log] [blame]
Tom Stellard49f8bfd2015-01-06 18:00:21 +00001; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Marek Olsak75170772015-01-27 17:27:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Matt Arsenault1c4571e2014-09-30 01:05:29 +00003; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
Tom Stellard5a6b0d82013-04-19 02:10:53 +00004
Tom Stellard79243d92014-10-01 17:15:17 +00005; FUNC-LABEL: {{^}}s_sint_to_fp_i32_to_f32:
Tom Stellard326d6ec2014-11-05 14:50:53 +00006; SI: v_cvt_f32_i32_e32 {{v[0-9]+}}, {{s[0-9]+$}}
Matt Arsenaultfe453a72016-01-11 17:02:10 +00007
8; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].Z
9define void @s_sint_to_fp_i32_to_f32(float addrspace(1)* %out, i32 %in) #0 {
Matt Arsenault1c4571e2014-09-30 01:05:29 +000010 %result = sitofp i32 %in to float
11 store float %result, float addrspace(1)* %out
12 ret void
13}
14
Matt Arsenaultfe453a72016-01-11 17:02:10 +000015; FUNC-LABEL: {{^}}v_sint_to_fp_i32_to_f32:
16; SI: v_cvt_f32_i32_e32 {{v[0-9]+}}, {{v[0-9]+$}}
17
18; R600: INT_TO_FLT
19define void @v_sint_to_fp_i32_to_f32(float addrspace(1)* %out, i32 addrspace(1)* %in) #0 {
20 %tid = call i32 @llvm.r600.read.tidig.x()
21 %in.gep = getelementptr i32, i32 addrspace(1)* %in, i32 %tid
22 %out.gep = getelementptr float, float addrspace(1)* %out, i32 %tid
23 %val = load i32, i32 addrspace(1)* %in.gep
24 %result = sitofp i32 %val to float
25 store float %result, float addrspace(1)* %out.gep
26 ret void
27}
28
29; FUNC-LABEL: {{^}}s_sint_to_fp_v2i32:
30; SI: v_cvt_f32_i32_e32
31; SI: v_cvt_f32_i32_e32
32
Matt Arsenault1c4571e2014-09-30 01:05:29 +000033; R600-DAG: INT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].W
34; R600-DAG: INT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[3].X
Matt Arsenaultfe453a72016-01-11 17:02:10 +000035define void @s_sint_to_fp_v2i32(<2 x float> addrspace(1)* %out, <2 x i32> %in) #0{
Tom Stellard0344cdf2013-08-01 15:23:42 +000036 %result = sitofp <2 x i32> %in to <2 x float>
37 store <2 x float> %result, <2 x float> addrspace(1)* %out
38 ret void
39}
40
Matt Arsenaultfe453a72016-01-11 17:02:10 +000041; FUNC-LABEL: {{^}}s_sint_to_fp_v4i32_to_v4f32:
42; SI: v_cvt_f32_i32_e32
43; SI: v_cvt_f32_i32_e32
44; SI: v_cvt_f32_i32_e32
45; SI: v_cvt_f32_i32_e32
46; SI: s_endpgm
Matt Arsenault1c4571e2014-09-30 01:05:29 +000047
Matt Arsenaultfe453a72016-01-11 17:02:10 +000048; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
49; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
50; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
51; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
52define void @s_sint_to_fp_v4i32_to_v4f32(<4 x float> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) #0 {
David Blaikiea79ac142015-02-27 21:17:42 +000053 %value = load <4 x i32>, <4 x i32> addrspace(1) * %in
Tom Stellard5a6b0d82013-04-19 02:10:53 +000054 %result = sitofp <4 x i32> %value to <4 x float>
55 store <4 x float> %result, <4 x float> addrspace(1)* %out
56 ret void
57}
Matt Arsenaultaeca2fa2014-05-31 06:47:42 +000058
Matt Arsenaultfe453a72016-01-11 17:02:10 +000059; FUNC-LABEL: {{^}}v_sint_to_fp_v4i32:
60; SI: v_cvt_f32_i32_e32
61; SI: v_cvt_f32_i32_e32
62; SI: v_cvt_f32_i32_e32
63; SI: v_cvt_f32_i32_e32
64
65; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
66; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
67; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
68; R600: INT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
69define void @v_sint_to_fp_v4i32(<4 x float> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) #0 {
70 %tid = call i32 @llvm.r600.read.tidig.x()
71 %in.gep = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 %tid
72 %out.gep = getelementptr <4 x float>, <4 x float> addrspace(1)* %out, i32 %tid
73 %value = load <4 x i32>, <4 x i32> addrspace(1)* %in.gep
74 %result = sitofp <4 x i32> %value to <4 x float>
75 store <4 x float> %result, <4 x float> addrspace(1)* %out.gep
76 ret void
77}
78
79; FUNC-LABEL: {{^}}s_sint_to_fp_i1_f32:
Tom Stellard326d6ec2014-11-05 14:50:53 +000080; SI: v_cmp_eq_i32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
Tom Stellard654d6692015-01-08 15:08:17 +000081; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0, [[CMP]]
Tom Stellard326d6ec2014-11-05 14:50:53 +000082; SI: buffer_store_dword [[RESULT]],
83; SI: s_endpgm
Matt Arsenaultfe453a72016-01-11 17:02:10 +000084define void @s_sint_to_fp_i1_f32(float addrspace(1)* %out, i32 %in) #0 {
Matt Arsenaultaeca2fa2014-05-31 06:47:42 +000085 %cmp = icmp eq i32 %in, 0
86 %fp = uitofp i1 %cmp to float
Matt Arsenaultfe453a72016-01-11 17:02:10 +000087 store float %fp, float addrspace(1)* %out
Matt Arsenaultaeca2fa2014-05-31 06:47:42 +000088 ret void
89}
90
Matt Arsenaultfe453a72016-01-11 17:02:10 +000091; FUNC-LABEL: {{^}}s_sint_to_fp_i1_f32_load:
Tom Stellard326d6ec2014-11-05 14:50:53 +000092; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, -1.0
93; SI: buffer_store_dword [[RESULT]],
94; SI: s_endpgm
Matt Arsenaultfe453a72016-01-11 17:02:10 +000095define void @s_sint_to_fp_i1_f32_load(float addrspace(1)* %out, i1 %in) #0 {
Matt Arsenaultaeca2fa2014-05-31 06:47:42 +000096 %fp = sitofp i1 %in to float
Matt Arsenaultfe453a72016-01-11 17:02:10 +000097 store float %fp, float addrspace(1)* %out
Matt Arsenaultaeca2fa2014-05-31 06:47:42 +000098 ret void
99}
Matt Arsenaultfe453a72016-01-11 17:02:10 +0000100
101; FUNC-LABEL: {{^}}v_sint_to_fp_i1_f32_load:
102; SI: {{buffer|flat}}_load_ubyte
103; SI: v_and_b32_e32 {{v[0-9]+}}, 1, {{v[0-9]+}}
104; SI: v_cmp_eq_i32
105; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, -1.0
Tom Stellard46937ca2016-02-12 17:57:54 +0000106; SI: {{buffer|flat}}_store_dword {{.*}}[[RESULT]]
Matt Arsenaultfe453a72016-01-11 17:02:10 +0000107; SI: s_endpgm
108define void @v_sint_to_fp_i1_f32_load(float addrspace(1)* %out, i1 addrspace(1)* %in) #0 {
109 %tid = call i32 @llvm.r600.read.tidig.x()
110 %in.gep = getelementptr i1, i1 addrspace(1)* %in, i32 %tid
111 %out.gep = getelementptr float, float addrspace(1)* %out, i32 %tid
112 %val = load i1, i1 addrspace(1)* %in.gep
113 %fp = sitofp i1 %val to float
114 store float %fp, float addrspace(1)* %out.gep
115 ret void
116}
117
118declare i32 @llvm.r600.read.tidig.x() #1
119
120attributes #0 = { nounwind }
121attributes #1 = { nounwind readnone }