1 ; RUN: llc -mtriple=amdgcn -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -mtriple=r600 -mcpu=redwood < %s | FileCheck -allow-deprecated-dag-overlap -check-prefix=R600 -check-prefix=FUNC %s
5 ; FUNC-LABEL: {{^}}s_uint_to_fp_i32_to_f32:
6 ; SI: v_cvt_f32_u32_e32
8 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].Z
9 define amdgpu_kernel void @s_uint_to_fp_i32_to_f32(ptr addrspace(1) %out, i32 %in) #0 {
10 %result = uitofp i32 %in to float
11 store float %result, ptr addrspace(1) %out
15 ; FUNC-LABEL: {{^}}v_uint_to_fp_i32_to_f32:
16 ; SI: v_cvt_f32_u32_e32 {{v[0-9]+}}, {{v[0-9]+$}}
19 define amdgpu_kernel void @v_uint_to_fp_i32_to_f32(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
20 %tid = call i32 @llvm.amdgcn.workitem.id.x()
21 %in.gep = getelementptr i32, ptr addrspace(1) %in, i32 %tid
22 %out.gep = getelementptr float, ptr addrspace(1) %out, i32 %tid
23 %val = load i32, ptr addrspace(1) %in.gep
24 %result = uitofp i32 %val to float
25 store float %result, ptr addrspace(1) %out.gep
29 ; FUNC-LABEL: {{^}}s_uint_to_fp_v2i32_to_v2f32:
30 ; SI: v_cvt_f32_u32_e32
31 ; SI: v_cvt_f32_u32_e32
33 ; R600-DAG: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].W
34 ; R600-DAG: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[3].X
35 define amdgpu_kernel void @s_uint_to_fp_v2i32_to_v2f32(ptr addrspace(1) %out, <2 x i32> %in) #0 {
36 %result = uitofp <2 x i32> %in to <2 x float>
37 store <2 x float> %result, ptr addrspace(1) %out
41 ; FUNC-LABEL: {{^}}s_uint_to_fp_v4i32_to_v4f32:
42 ; SI: v_cvt_f32_u32_e32
43 ; SI: v_cvt_f32_u32_e32
44 ; SI: v_cvt_f32_u32_e32
45 ; SI: v_cvt_f32_u32_e32
48 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
49 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
50 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
51 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
52 define amdgpu_kernel void @s_uint_to_fp_v4i32_to_v4f32(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
53 %value = load <4 x i32>, ptr addrspace(1) %in
54 %result = uitofp <4 x i32> %value to <4 x float>
55 store <4 x float> %result, ptr addrspace(1) %out
59 ; FUNC-LABEL: {{^}}v_uint_to_fp_v4i32:
60 ; SI: v_cvt_f32_u32_e32
61 ; SI: v_cvt_f32_u32_e32
62 ; SI: v_cvt_f32_u32_e32
63 ; SI: v_cvt_f32_u32_e32
65 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
66 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
67 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
68 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
69 define amdgpu_kernel void @v_uint_to_fp_v4i32(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
70 %tid = call i32 @llvm.amdgcn.workitem.id.x()
71 %in.gep = getelementptr <4 x i32>, ptr addrspace(1) %in, i32 %tid
72 %out.gep = getelementptr <4 x float>, ptr addrspace(1) %out, i32 %tid
73 %value = load <4 x i32>, ptr addrspace(1) %in.gep
74 %result = uitofp <4 x i32> %value to <4 x float>
75 store <4 x float> %result, ptr addrspace(1) %out.gep
79 ; FUNC-LABEL: {{^}}s_uint_to_fp_i1_to_f32:
81 ; SI: s_cselect_b64 [[CMP:s\[[0-9]+:[0-9]\]]], -1, 0
82 ; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0, [[CMP]]
83 ; SI: buffer_store_dword [[RESULT]],
85 define amdgpu_kernel void @s_uint_to_fp_i1_to_f32(ptr addrspace(1) %out, i32 %in) #0 {
86 %cmp = icmp eq i32 %in, 0
87 %fp = uitofp i1 %cmp to float
88 store float %fp, ptr addrspace(1) %out
92 ; FUNC-LABEL: {{^}}s_uint_to_fp_i1_to_f32_load:
93 ; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0
94 ; SI: buffer_store_dword [[RESULT]],
96 define amdgpu_kernel void @s_uint_to_fp_i1_to_f32_load(ptr addrspace(1) %out, i1 %in) #0 {
97 %fp = uitofp i1 %in to float
98 store float %fp, ptr addrspace(1) %out
102 ; FUNC-LABEL: {{^}}v_uint_to_fp_i1_f32_load:
103 ; SI: {{buffer|flat}}_load_ubyte
104 ; SI: v_and_b32_e32 {{v[0-9]+}}, 1, {{v[0-9]+}}
106 ; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0
107 ; SI: {{buffer|flat}}_store_dword {{.*}}[[RESULT]]
109 define amdgpu_kernel void @v_uint_to_fp_i1_f32_load(ptr addrspace(1) %out, ptr addrspace(1) %in) #0 {
110 %tid = call i32 @llvm.amdgcn.workitem.id.x()
111 %in.gep = getelementptr i1, ptr addrspace(1) %in, i32 %tid
112 %out.gep = getelementptr float, ptr addrspace(1) %out, i32 %tid
113 %val = load i1, ptr addrspace(1) %in.gep
114 %fp = uitofp i1 %val to float
115 store float %fp, ptr addrspace(1) %out.gep
119 ; FIXME: Repeated here to test r600
120 ; FUNC-LABEL: {{^}}s_uint_to_fp_i64_to_f32:
125 define amdgpu_kernel void @s_uint_to_fp_i64_to_f32(ptr addrspace(1) %out, i64 %in) #0 {
127 %cvt = uitofp i64 %in to float
128 store float %cvt, ptr addrspace(1) %out
132 declare i32 @llvm.amdgcn.workitem.id.x() #1
134 attributes #0 = { nounwind }
135 attributes #1 = { nounwind readnone }