c12db507ca16b173417006ca5589dce5aa37d063
[oota-llvm.git] / test / CodeGen / AMDGPU / uint_to_fp.ll
1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
4
5 ; FUNC-LABEL: {{^}}s_uint_to_fp_i32_to_f32:
6 ; SI: v_cvt_f32_u32_e32
7
8 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].Z
9 define void @s_uint_to_fp_i32_to_f32(float addrspace(1)* %out, i32 %in) #0 {
10   %result = uitofp i32 %in to float
11   store float %result, float addrspace(1)* %out
12   ret void
13 }
14
15 ; FUNC-LABEL: {{^}}v_uint_to_fp_i32_to_f32:
16 ; SI: v_cvt_f32_u32_e32 {{v[0-9]+}}, {{v[0-9]+$}}
17
18 ; R600: INT_TO_FLT
19 define void @v_uint_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 = uitofp i32 %val to float
25   store float %result, float addrspace(1)* %out.gep
26   ret void
27 }
28
29 ; FUNC-LABEL: {{^}}s_uint_to_fp_v2i32_to_v2f32:
30 ; SI: v_cvt_f32_u32_e32
31 ; SI: v_cvt_f32_u32_e32
32
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 void @s_uint_to_fp_v2i32_to_v2f32(<2 x float> 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, <2 x float> addrspace(1)* %out
38   ret void
39 }
40
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
46 ; SI: s_endpgm
47
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 void @s_uint_to_fp_v4i32_to_v4f32(<4 x float> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) #0 {
53   %value = load <4 x i32>, <4 x i32> addrspace(1) * %in
54   %result = uitofp <4 x i32> %value to <4 x float>
55   store <4 x float> %result, <4 x float> addrspace(1)* %out
56   ret void
57 }
58
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
64
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 void @v_uint_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 = uitofp <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_uint_to_fp_i1_to_f32:
80 ; SI: v_cmp_eq_i32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
81 ; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0, [[CMP]]
82 ; SI: buffer_store_dword [[RESULT]],
83 ; SI: s_endpgm
84 define void @s_uint_to_fp_i1_to_f32(float addrspace(1)* %out, i32 %in) #0 {
85   %cmp = icmp eq i32 %in, 0
86   %fp = uitofp i1 %cmp to float
87   store float %fp, float addrspace(1)* %out
88   ret void
89 }
90
91 ; FUNC-LABEL: {{^}}s_uint_to_fp_i1_to_f32_load:
92 ; SI: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0
93 ; SI: buffer_store_dword [[RESULT]],
94 ; SI: s_endpgm
95 define void @s_uint_to_fp_i1_to_f32_load(float addrspace(1)* %out, i1 %in) #0 {
96   %fp = uitofp i1 %in to float
97   store float %fp, float addrspace(1)* %out
98   ret void
99 }
100
101 ; FUNC-LABEL: {{^}}v_uint_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
106 ; SI: {{buffer|flat}}_store_dword [[RESULT]],
107 ; SI: s_endpgm
108 define void @v_uint_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 = uitofp i1 %val to float
114   store float %fp, float addrspace(1)* %out.gep
115   ret void
116 }
117
118 ; FUNC-LABEL: {{^}}s_uint_to_fp_i64_to_f32:
119 ; SI: v_cvt_f32_u32_e32
120 ; SI: v_cvt_f32_u32_e32
121 ; SI: v_madmk_f32_e32 {{v[0-9]+}}, {{v[0-9]+}}, {{v[0-9]+}}, 0x4f800000
122 ; SI: s_endpgm
123
124 ; R600: UINT_TO_FLT
125 ; R600: UINT_TO_FLT
126 ; R600: MULADD_IEEE
127 define void @s_uint_to_fp_i64_to_f32(float addrspace(1)* %out, i64 %in) #0 {
128 entry:
129   %cvt = uitofp i64 %in to float
130   store float %cvt, float addrspace(1)* %out
131   ret void
132 }
133
134 declare i32 @llvm.r600.read.tidig.x() #1
135
136 attributes #0 = { nounwind }
137 attributes #1 = { nounwind readnone }