1 ; RUN: llc -O0 %s -mtriple=spirv32-unknown-unknown -o - | FileCheck %s
3 declare float @llvm.fabs.f32(float)
4 declare float @llvm.rint.f32(float)
5 declare float @llvm.nearbyint.f32(float)
6 declare float @llvm.floor.f32(float)
7 declare float @llvm.ceil.f32(float)
8 declare float @llvm.round.f32(float)
9 declare float @llvm.trunc.f32(float)
10 declare float @llvm.sqrt.f32(float)
11 declare float @llvm.sin.f32(float)
12 declare float @llvm.cos.f32(float)
13 declare float @llvm.exp2.f32(float)
14 declare float @llvm.log.f32(float)
15 declare float @llvm.log10.f32(float)
16 declare float @llvm.log2.f32(float)
17 declare float @llvm.minnum.f32(float, float)
18 declare float @llvm.maxnum.f32(float, float)
19 declare <2 x half> @llvm.fabs.v2f16(<2 x half>)
20 declare <2 x half> @llvm.rint.v2f16(<2 x half>)
21 declare <2 x half> @llvm.nearbyint.v2f16(<2 x half>)
22 declare <2 x half> @llvm.floor.v2f16(<2 x half>)
23 declare <2 x half> @llvm.ceil.v2f16(<2 x half>)
24 declare <2 x half> @llvm.round.v2f16(<2 x half>)
25 declare <2 x half> @llvm.trunc.v2f16(<2 x half>)
26 declare <2 x half> @llvm.sqrt.v2f16(<2 x half>)
27 declare <2 x half> @llvm.sin.v2f16(<2 x half>)
28 declare <2 x half> @llvm.cos.v2f16(<2 x half>)
29 declare <2 x half> @llvm.exp2.v2f16(<2 x half>)
30 declare <2 x half> @llvm.log.v2f16(<2 x half>)
31 declare <2 x half> @llvm.log10.v2f16(<2 x half>)
32 declare <2 x half> @llvm.log2.v2f16(<2 x half>)
34 ; CHECK-DAG: OpName %[[#SCALAR_FABS:]] "scalar_fabs"
35 ; CHECK-DAG: OpName %[[#SCALAR_RINT:]] "scalar_rint"
36 ; CHECK-DAG: OpName %[[#SCALAR_NEARBYINT:]] "scalar_nearbyint"
37 ; CHECK-DAG: OpName %[[#SCALAR_FLOOR:]] "scalar_floor"
38 ; CHECK-DAG: OpName %[[#SCALAR_CEIL:]] "scalar_ceil"
39 ; CHECK-DAG: OpName %[[#SCALAR_ROUND:]] "scalar_round"
40 ; CHECK-DAG: OpName %[[#SCALAR_TRUNC:]] "scalar_trunc"
41 ; CHECK-DAG: OpName %[[#SCALAR_SQRT:]] "scalar_sqrt"
42 ; CHECK-DAG: OpName %[[#SCALAR_SIN:]] "scalar_sin"
43 ; CHECK-DAG: OpName %[[#SCALAR_COS:]] "scalar_cos"
44 ; CHECK-DAG: OpName %[[#SCALAR_EXP2:]] "scalar_exp2"
45 ; CHECK-DAG: OpName %[[#SCALAR_LOG:]] "scalar_log"
46 ; CHECK-DAG: OpName %[[#SCALAR_LOG10:]] "scalar_log10"
47 ; CHECK-DAG: OpName %[[#SCALAR_LOG2:]] "scalar_log2"
48 ; CHECK-DAG: OpName %[[#SCALAR_MINNUM:]] "scalar_minnum"
49 ; CHECK-DAG: OpName %[[#SCALAR_MAXNUM:]] "scalar_maxnum"
50 ; CHECK-DAG: OpName %[[#VECTOR_FABS:]] "vector_fabs"
51 ; CHECK-DAG: OpName %[[#VECTOR_RINT:]] "vector_rint"
52 ; CHECK-DAG: OpName %[[#VECTOR_NEARBYINT:]] "vector_nearbyint"
53 ; CHECK-DAG: OpName %[[#VECTOR_FLOOR:]] "vector_floor"
54 ; CHECK-DAG: OpName %[[#VECTOR_CEIL:]] "vector_ceil"
55 ; CHECK-DAG: OpName %[[#VECTOR_ROUND:]] "vector_round"
56 ; CHECK-DAG: OpName %[[#VECTOR_TRUNC:]] "vector_trunc"
57 ; CHECK-DAG: OpName %[[#VECTOR_SQRT:]] "vector_sqrt"
58 ; CHECK-DAG: OpName %[[#VECTOR_SIN:]] "vector_sin"
59 ; CHECK-DAG: OpName %[[#VECTOR_COS:]] "vector_cos"
60 ; CHECK-DAG: OpName %[[#VECTOR_EXP2:]] "vector_exp2"
61 ; CHECK-DAG: OpName %[[#VECTOR_LOG:]] "vector_log"
62 ; CHECK-DAG: OpName %[[#VECTOR_LOG10:]] "vector_log10"
63 ; CHECK-DAG: OpName %[[#VECTOR_LOG2:]] "vector_log2"
65 ; CHECK-DAG: %[[#CLEXT:]] = OpExtInstImport "OpenCL.std"
67 ; CHECK: %[[#SCALAR_FABS]] = OpFunction
68 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
70 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] fabs %[[#A]]
71 ; CHECK: OpReturnValue %[[#R]]
72 ; CHECK-NEXT: OpFunctionEnd
73 define float @scalar_fabs(float %a) {
74 %r = call float @llvm.fabs.f32(float %a)
78 ; CHECK: %[[#SCALAR_RINT]] = OpFunction
79 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
81 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] rint %[[#A]]
82 ; CHECK: OpReturnValue %[[#R]]
83 ; CHECK-NEXT: OpFunctionEnd
84 define float @scalar_rint(float %a) {
85 %r = call float @llvm.rint.f32(float %a)
89 ; CHECK: %[[#SCALAR_NEARBYINT]] = OpFunction
90 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
92 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] rint %[[#A]]
93 ; CHECK: OpReturnValue %[[#R]]
94 ; CHECK-NEXT: OpFunctionEnd
95 define float @scalar_nearbyint(float %a) {
96 %r = call float @llvm.nearbyint.f32(float %a)
100 ; CHECK: %[[#SCALAR_FLOOR]] = OpFunction
101 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
103 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] floor %[[#A]]
104 ; CHECK: OpReturnValue %[[#R]]
105 ; CHECK-NEXT: OpFunctionEnd
106 define float @scalar_floor(float %a) {
107 %r = call float @llvm.floor.f32(float %a)
111 ; CHECK: %[[#SCALAR_CEIL]] = OpFunction
112 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
114 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] ceil %[[#A]]
115 ; CHECK: OpReturnValue %[[#R]]
116 ; CHECK-NEXT: OpFunctionEnd
117 define float @scalar_ceil(float %a) {
118 %r = call float @llvm.ceil.f32(float %a)
122 ; CHECK: %[[#SCALAR_ROUND]] = OpFunction
123 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
125 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] round %[[#A]]
126 ; CHECK: OpReturnValue %[[#R]]
127 ; CHECK-NEXT: OpFunctionEnd
128 define float @scalar_round(float %a) {
129 %r = call float @llvm.round.f32(float %a)
133 ; CHECK: %[[#SCALAR_TRUNC]] = OpFunction
134 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
136 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] trunc %[[#A]]
137 ; CHECK: OpReturnValue %[[#R]]
138 ; CHECK-NEXT: OpFunctionEnd
139 define float @scalar_trunc(float %a) {
140 %r = call float @llvm.trunc.f32(float %a)
144 ; CHECK: %[[#SCALAR_SQRT]] = OpFunction
145 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
147 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] sqrt %[[#A]]
148 ; CHECK: OpReturnValue %[[#R]]
149 ; CHECK-NEXT: OpFunctionEnd
150 define float @scalar_sqrt(float %a) {
151 %r = call float @llvm.sqrt.f32(float %a)
155 ; CHECK: %[[#SCALAR_SIN]] = OpFunction
156 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
158 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] sin %[[#A]]
159 ; CHECK: OpReturnValue %[[#R]]
160 ; CHECK-NEXT: OpFunctionEnd
161 define float @scalar_sin(float %a) {
162 %r = call float @llvm.sin.f32(float %a)
166 ; CHECK: %[[#SCALAR_COS]] = OpFunction
167 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
169 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] cos %[[#A]]
170 ; CHECK: OpReturnValue %[[#R]]
171 ; CHECK-NEXT: OpFunctionEnd
172 define float @scalar_cos(float %a) {
173 %r = call float @llvm.cos.f32(float %a)
177 ; CHECK: %[[#SCALAR_EXP2]] = OpFunction
178 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
180 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] exp2 %[[#A]]
181 ; CHECK: OpReturnValue %[[#R]]
182 ; CHECK-NEXT: OpFunctionEnd
183 define float @scalar_exp2(float %a) {
184 %r = call float @llvm.exp2.f32(float %a)
188 ; CHECK: %[[#SCALAR_LOG]] = OpFunction
189 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
191 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] log %[[#A]]
192 ; CHECK: OpReturnValue %[[#R]]
193 ; CHECK-NEXT: OpFunctionEnd
194 define float @scalar_log(float %a) {
195 %r = call float @llvm.log.f32(float %a)
199 ; CHECK: %[[#SCALAR_LOG10]] = OpFunction
200 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
202 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] log10 %[[#A]]
203 ; CHECK: OpReturnValue %[[#R]]
204 ; CHECK-NEXT: OpFunctionEnd
205 define float @scalar_log10(float %a) {
206 %r = call float @llvm.log10.f32(float %a)
210 ; CHECK: %[[#SCALAR_LOG2]] = OpFunction
211 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
213 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] log2 %[[#A]]
214 ; CHECK: OpReturnValue %[[#R]]
215 ; CHECK-NEXT: OpFunctionEnd
216 define float @scalar_log2(float %a) {
217 %r = call float @llvm.log2.f32(float %a)
221 ; CHECK: %[[#VECTOR_FABS]] = OpFunction
222 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
224 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] fabs %[[#A]]
225 ; CHECK: OpReturnValue %[[#R]]
226 ; CHECK-NEXT: OpFunctionEnd
227 define <2 x half> @vector_fabs(<2 x half> %a) {
228 %r = call <2 x half> @llvm.fabs.v2f16(<2 x half> %a)
232 ; CHECK: %[[#VECTOR_RINT]] = OpFunction
233 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
235 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] rint %[[#A]]
236 ; CHECK: OpReturnValue %[[#R]]
237 ; CHECK-NEXT: OpFunctionEnd
238 define <2 x half> @vector_rint(<2 x half> %a) {
239 %r = call <2 x half> @llvm.rint.v2f16(<2 x half> %a)
243 ; CHECK: %[[#VECTOR_NEARBYINT]] = OpFunction
244 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
246 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] rint %[[#A]]
247 ; CHECK: OpReturnValue %[[#R]]
248 ; CHECK-NEXT: OpFunctionEnd
249 define <2 x half> @vector_nearbyint(<2 x half> %a) {
250 %r = call <2 x half> @llvm.nearbyint.v2f16(<2 x half> %a)
254 ; CHECK: %[[#VECTOR_FLOOR]] = OpFunction
255 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
257 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] floor %[[#A]]
258 ; CHECK: OpReturnValue %[[#R]]
259 ; CHECK-NEXT: OpFunctionEnd
260 define <2 x half> @vector_floor(<2 x half> %a) {
261 %r = call <2 x half> @llvm.floor.v2f16(<2 x half> %a)
265 ; CHECK: %[[#VECTOR_CEIL]] = OpFunction
266 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
268 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] ceil %[[#A]]
269 ; CHECK: OpReturnValue %[[#R]]
270 ; CHECK-NEXT: OpFunctionEnd
271 define <2 x half> @vector_ceil(<2 x half> %a) {
272 %r = call <2 x half> @llvm.ceil.v2f16(<2 x half> %a)
276 ; CHECK: %[[#VECTOR_ROUND]] = OpFunction
277 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
279 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] round %[[#A]]
280 ; CHECK: OpReturnValue %[[#R]]
281 ; CHECK-NEXT: OpFunctionEnd
282 define <2 x half> @vector_round(<2 x half> %a) {
283 %r = call <2 x half> @llvm.round.v2f16(<2 x half> %a)
287 ; CHECK: %[[#VECTOR_TRUNC]] = OpFunction
288 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
290 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] trunc %[[#A]]
291 ; CHECK: OpReturnValue %[[#R]]
292 ; CHECK-NEXT: OpFunctionEnd
293 define <2 x half> @vector_trunc(<2 x half> %a) {
294 %r = call <2 x half> @llvm.trunc.v2f16(<2 x half> %a)
298 ; CHECK: %[[#VECTOR_SQRT]] = OpFunction
299 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
301 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] sqrt %[[#A]]
302 ; CHECK: OpReturnValue %[[#R]]
303 ; CHECK-NEXT: OpFunctionEnd
304 define <2 x half> @vector_sqrt(<2 x half> %a) {
305 %r = call <2 x half> @llvm.sqrt.v2f16(<2 x half> %a)
309 ; CHECK: %[[#VECTOR_SIN]] = OpFunction
310 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
312 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] sin %[[#A]]
313 ; CHECK: OpReturnValue %[[#R]]
314 ; CHECK-NEXT: OpFunctionEnd
315 define <2 x half> @vector_sin(<2 x half> %a) {
316 %r = call <2 x half> @llvm.sin.v2f16(<2 x half> %a)
320 ; CHECK: %[[#VECTOR_COS]] = OpFunction
321 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
323 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] cos %[[#A]]
324 ; CHECK: OpReturnValue %[[#R]]
325 ; CHECK-NEXT: OpFunctionEnd
326 define <2 x half> @vector_cos(<2 x half> %a) {
327 %r = call <2 x half> @llvm.cos.v2f16(<2 x half> %a)
331 ; CHECK: %[[#VECTOR_EXP2]] = OpFunction
332 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
334 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] exp2 %[[#A]]
335 ; CHECK: OpReturnValue %[[#R]]
336 ; CHECK-NEXT: OpFunctionEnd
337 define <2 x half> @vector_exp2(<2 x half> %a) {
338 %r = call <2 x half> @llvm.exp2.v2f16(<2 x half> %a)
342 ; CHECK: %[[#VECTOR_LOG]] = OpFunction
343 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
345 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] log %[[#A]]
346 ; CHECK: OpReturnValue %[[#R]]
347 ; CHECK-NEXT: OpFunctionEnd
348 define <2 x half> @vector_log(<2 x half> %a) {
349 %r = call <2 x half> @llvm.log.v2f16(<2 x half> %a)
353 ; CHECK: %[[#VECTOR_LOG10]] = OpFunction
354 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
356 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] log10 %[[#A]]
357 ; CHECK: OpReturnValue %[[#R]]
358 ; CHECK-NEXT: OpFunctionEnd
359 define <2 x half> @vector_log10(<2 x half> %a) {
360 %r = call <2 x half> @llvm.log10.v2f16(<2 x half> %a)
364 ; CHECK: %[[#VECTOR_LOG2]] = OpFunction
365 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
367 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] log2 %[[#A]]
368 ; CHECK: OpReturnValue %[[#R]]
369 ; CHECK-NEXT: OpFunctionEnd
370 define <2 x half> @vector_log2(<2 x half> %a) {
371 %r = call <2 x half> @llvm.log2.v2f16(<2 x half> %a)
375 ; CHECK: %[[#SCALAR_MINNUM]] = OpFunction
376 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
377 ; CHECK-NEXT: %[[#B:]] = OpFunctionParameter
379 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] fmin %[[#A]] %[[#B]]
380 ; CHECK: OpReturnValue %[[#R]]
381 ; CHECK-NEXT: OpFunctionEnd
382 define float @scalar_minnum(float %A, float %B) {
383 %r = call float @llvm.minnum.f32(float %A, float %B)
387 ; CHECK: %[[#SCALAR_MAXNUM]] = OpFunction
388 ; CHECK-NEXT: %[[#A:]] = OpFunctionParameter
389 ; CHECK-NEXT: %[[#B:]] = OpFunctionParameter
391 ; CHECK: %[[#R:]] = OpExtInst %[[#]] %[[#CLEXT]] fmax %[[#A]] %[[#B]]
392 ; CHECK: OpReturnValue %[[#R]]
393 ; CHECK-NEXT: OpFunctionEnd
394 define float @scalar_maxnum(float %A, float %B) {
395 %r = call float @llvm.maxnum.f32(float %A, float %B)