1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; CHECK-DAG: OpName [[TRUNC32_16:%.*]] "f32tof16"
4 ; CHECK-DAG: OpName [[EXT16_32:%.*]] "f16tof32"
6 ; CHECK-DAG: OpName [[TRUNC32_16v3:%.*]] "f32tof16v3"
7 ; CHECK-DAG: OpName [[EXT16_32v3:%.*]] "f16tof32v3"
9 ; CHECK-DAG: OpName [[F32toS32:%.*]] "f32tos32"
10 ; CHECK-DAG: OpName [[F32toS16:%.*]] "f32tos16"
11 ; CHECK-DAG: OpName [[F32toS8:%.*]] "f32tos8"
12 ; CHECK-DAG: OpName [[F16toS32:%.*]] "f16tos32"
13 ; CHECK-DAG: OpName [[F16toS16:%.*]] "f16tos16"
14 ; CHECK-DAG: OpName [[F16toS8:%.*]] "f16tos8"
16 ; CHECK-DAG: OpName [[F32toU32v2:%.*]] "f32tou32v2"
17 ; CHECK-DAG: OpName [[F32toU16v2:%.*]] "f32tou16v2"
18 ; CHECK-DAG: OpName [[F32toU8v2:%.*]] "f32tou8v2"
19 ; CHECK-DAG: OpName [[F16toU32v2:%.*]] "f16tou32v2"
20 ; CHECK-DAG: OpName [[F16toU16v2:%.*]] "f16tou16v2"
21 ; CHECK-DAG: OpName [[F16toU8v2:%.*]] "f16tou8v2"
23 ; CHECK-DAG: [[F32:%.*]] = OpTypeFloat 32
24 ; CHECK-DAG: [[F16:%.*]] = OpTypeFloat 16
25 ; CHECK-DAG: [[F32v2:%.*]] = OpTypeVector [[F32]] 2
26 ; CHECK-DAG: [[F16v2:%.*]] = OpTypeVector [[F16]] 2
27 ; CHECK-DAG: [[F32v3:%.*]] = OpTypeVector [[F32]] 3
28 ; CHECK-DAG: [[F16v3:%.*]] = OpTypeVector [[F16]] 3
29 ; CHECK-DAG: [[U32:%.*]] = OpTypeInt 32 0
30 ; CHECK-DAG: [[U16:%.*]] = OpTypeInt 16 0
31 ; CHECK-DAG: [[U8:%.*]] = OpTypeInt 8 0
32 ; CHECK-DAG: [[U32v2:%.*]] = OpTypeVector [[U32]] 2
33 ; CHECK-DAG: [[U16v2:%.*]] = OpTypeVector [[U16]] 2
34 ; CHECK-DAG: [[U8v2:%.*]] = OpTypeVector [[U8]] 2
37 ; CHECK: [[TRUNC32_16]] = OpFunction [[F16]]
38 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32]]
40 ; CHECK: [[R:%.*]] = OpFConvert [[F16]] [[A]]
41 ; CHECK: OpReturnValue [[R]]
42 ; CHECK-NEXT: OpFunctionEnd
43 define half @f32tof16(float %a) {
44 %r = fptrunc float %a to half
48 ; CHECK: [[EXT16_32]] = OpFunction [[F32]]
49 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16]]
51 ; CHECK: [[R:%.*]] = OpFConvert [[F32]] [[A]]
52 ; CHECK: OpReturnValue [[R]]
53 ; CHECK-NEXT: OpFunctionEnd
54 define float @f16tof32(half %a) {
55 %r = fpext half %a to float
59 ; CHECK: [[TRUNC32_16v3]] = OpFunction [[F16v3]]
60 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32v3]]
62 ; CHECK: [[R:%.*]] = OpFConvert [[F16v3]] [[A]]
63 ; CHECK: OpReturnValue [[R]]
64 ; CHECK-NEXT: OpFunctionEnd
65 define <3 x half> @f32tof16v3(<3 x float> %a) {
66 %r = fptrunc <3 x float> %a to <3 x half>
70 ; CHECK: [[EXT16_32v3]] = OpFunction [[F32v3]]
71 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16v3]]
73 ; CHECK: [[R:%.*]] = OpFConvert [[F32v3]] [[A]]
74 ; CHECK: OpReturnValue [[R]]
75 ; CHECK-NEXT: OpFunctionEnd
76 define <3 x float> @f16tof32v3(<3 x half> %a) {
77 %r = fpext <3 x half> %a to <3 x float>
81 ; CHECK: [[F32toS32]] = OpFunction [[U32]]
82 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32]]
84 ; CHECK: [[R:%.*]] = OpConvertFToS [[U32]] [[A]]
85 ; CHECK: OpReturnValue [[R]]
86 ; CHECK-NEXT: OpFunctionEnd
87 define i32 @f32tos32(float %a) {
88 %r = fptosi float %a to i32
92 ; CHECK: [[F32toS16]] = OpFunction [[U16]]
93 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32]]
95 ; CHECK: [[R:%.*]] = OpConvertFToS [[U16]] [[A]]
96 ; CHECK: OpReturnValue [[R]]
97 ; CHECK-NEXT: OpFunctionEnd
98 define i16 @f32tos16(float %a) {
99 %r = fptosi float %a to i16
103 ; CHECK: [[F32toS8]] = OpFunction [[U8]]
104 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32]]
106 ; CHECK: [[R:%.*]] = OpConvertFToS [[U8]] [[A]]
107 ; CHECK: OpReturnValue [[R]]
108 ; CHECK-NEXT: OpFunctionEnd
109 define i8 @f32tos8(float %a) {
110 %r = fptosi float %a to i8
114 ; CHECK: [[F16toS32]] = OpFunction [[U32]]
115 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16]]
117 ; CHECK: [[R:%.*]] = OpConvertFToS [[U32]] [[A]]
118 ; CHECK: OpReturnValue [[R]]
119 ; CHECK-NEXT: OpFunctionEnd
120 define i32 @f16tos32(half %a) {
121 %r = fptosi half %a to i32
125 ; CHECK: [[F16toS16]] = OpFunction [[U16]]
126 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16]]
128 ; CHECK: [[R:%.*]] = OpConvertFToS [[U16]] [[A]]
129 ; CHECK: OpReturnValue [[R]]
130 ; CHECK-NEXT: OpFunctionEnd
131 define i16 @f16tos16(half %a) {
132 %r = fptosi half %a to i16
136 ; CHECK: [[F16toS8]] = OpFunction [[U8]]
137 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16]]
139 ; CHECK: [[R:%.*]] = OpConvertFToS [[U8]] [[A]]
140 ; CHECK: OpReturnValue [[R]]
141 ; CHECK-NEXT: OpFunctionEnd
142 define i8 @f16tos8(half %a) {
143 %r = fptosi half %a to i8
147 ; CHECK: [[F32toU32v2]] = OpFunction [[U32v2]]
148 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32v2]]
150 ; CHECK: [[R:%.*]] = OpConvertFToU [[U32v2]] [[A]]
151 ; CHECK: OpReturnValue [[R]]
152 ; CHECK-NEXT: OpFunctionEnd
153 define <2 x i32> @f32tou32v2(<2 x float> %a) {
154 %r = fptoui <2 x float> %a to <2 x i32>
158 ; CHECK: [[F32toU16v2]] = OpFunction [[U16v2]]
159 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32v2]]
161 ; CHECK: [[R:%.*]] = OpConvertFToU [[U16v2]] [[A]]
162 ; CHECK: OpReturnValue [[R]]
163 ; CHECK-NEXT: OpFunctionEnd
164 define <2 x i16> @f32tou16v2(<2 x float> %a) {
165 %r = fptoui <2 x float> %a to <2 x i16>
169 ; CHECK: [[F32toU8v2]] = OpFunction [[U8v2]]
170 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F32v2]]
172 ; CHECK: [[R:%.*]] = OpConvertFToU [[U8v2]] [[A]]
173 ; CHECK: OpReturnValue [[R]]
174 ; CHECK-NEXT: OpFunctionEnd
175 define <2 x i8> @f32tou8v2(<2 x float> %a) {
176 %r = fptoui <2 x float> %a to <2 x i8>
180 ; CHECK: [[F16toU32v2]] = OpFunction [[U32v2]]
181 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16v2]]
183 ; CHECK: [[R:%.*]] = OpConvertFToU [[U32v2]] [[A]]
184 ; CHECK: OpReturnValue [[R]]
185 ; CHECK-NEXT: OpFunctionEnd
186 define <2 x i32> @f16tou32v2(<2 x half> %a) {
187 %r = fptoui <2 x half> %a to <2 x i32>
191 ; CHECK: [[F16toU16v2]] = OpFunction [[U16v2]]
192 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16v2]]
194 ; CHECK: [[R:%.*]] = OpConvertFToU [[U16v2]] [[A]]
195 ; CHECK: OpReturnValue [[R]]
196 ; CHECK-NEXT: OpFunctionEnd
197 define <2 x i16> @f16tou16v2(<2 x half> %a) {
198 %r = fptoui <2 x half> %a to <2 x i16>
202 ; CHECK: [[F16toU8v2]] = OpFunction [[U8v2]]
203 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter [[F16v2]]
205 ; CHECK: [[R:%.*]] = OpConvertFToU [[U8v2]] [[A]]
206 ; CHECK: OpReturnValue [[R]]
207 ; CHECK-NEXT: OpFunctionEnd
208 define <2 x i8> @f16tou8v2(<2 x half> %a) {
209 %r = fptoui <2 x half> %a to <2 x i8>