Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/llvm-intrinsics/fp-intrinsics.ll

raw
1 ; RUN: llvm-as %s -o %t.bc
2 ; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s
3 ; RUN: llvm-spirv %t.bc -o %t.spv
4 ; RUN: spirv-val %t.spv
5
6 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
7 target triple = "spir64-unknown-unknown"
8
9 ; CHECK: ExtInstImport [[extinst_id:[0-9]+]] "OpenCL.std"
10
11 ; CHECK: 3 TypeFloat [[var0:[0-9]+]] 16
12 ; CHECK: 3 TypeFloat [[var1:[0-9]+]] 32
13 ; CHECK: 3 TypeFloat [[var2:[0-9]+]] 64
14 ; CHECK: 4 TypeVector [[var3:[0-9]+]] [[var1]] 4
15
16 ; CHECK: Function
17 ; CHECK: ExtInst [[var0]] {{[0-9]+}} [[extinst_id]] fabs
18 ; CHECK: FunctionEnd
19
20 define spir_func half @TestFabs16(half %x) local_unnamed_addr {
21 entry:
22 %t = tail call half @llvm.fabs.f16(half %x)
23 ret half %t
24 }
25
26 ; CHECK: Function
27 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] fabs
28 ; CHECK: FunctionEnd
29
30 define spir_func float @TestFabs32(float %x) local_unnamed_addr {
31 entry:
32 %t = tail call float @llvm.fabs.f32(float %x)
33 ret float %t
34 }
35
36 ; CHECK: Function
37 ; CHECK: ExtInst [[var2]] {{[0-9]+}} [[extinst_id]] fabs
38 ; CHECK: FunctionEnd
39
40 define spir_func double @TestFabs64(double %x) local_unnamed_addr {
41 entry:
42 %t = tail call double @llvm.fabs.f64(double %x)
43 ret double %t
44 }
45
46 ; CHECK: Function
47 ; CHECK: ExtInst [[var3]] {{[0-9]+}} [[extinst_id]] fabs
48 ; CHECK: FunctionEnd
49
50 ; Function Attrs: nounwind readnone
51 define spir_func <4 x float> @TestFabsVec(<4 x float> %x) local_unnamed_addr {
52 entry:
53 %t = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %x)
54 ret <4 x float> %t
55 }
56
57 declare half @llvm.fabs.f16(half)
58 declare float @llvm.fabs.f32(float)
59 declare double @llvm.fabs.f64(double)
60 declare <4 x float> @llvm.fabs.v4f32(<4 x float>)
61
62 ; We checked several types with fabs, but the type check works the same for
63 ; all intrinsics being translated, so for the rest we'll just test one type.
64
65 ; CHECK: Function
66 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] ceil
67 ; CHECK: FunctionEnd
68
69 define spir_func float @TestCeil(float %x) local_unnamed_addr {
70 entry:
71 %t = tail call float @llvm.ceil.f32(float %x)
72 ret float %t
73 }
74
75 declare float @llvm.ceil.f32(float)
76
77 ; CHECK: Function
78 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
79 ; CHECK: FunctionParameter {{[0-9]+}} [[n:[0-9]+]]
80 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] pown [[x]] [[n]]
81 ; CHECK: FunctionEnd
82
83 define spir_func float @TestPowi(float %x, i32 %n) local_unnamed_addr {
84 entry:
85 %t = tail call float @llvm.powi.f32(float %x, i32 %n)
86 ret float %t
87 }
88
89 declare float @llvm.powi.f32(float, i32)
90
91 ; CHECK: Function
92 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] sin
93 ; CHECK: FunctionEnd
94
95 define spir_func float @TestSin(float %x) local_unnamed_addr {
96 entry:
97 %t = tail call float @llvm.sin.f32(float %x)
98 ret float %t
99 }
100
101 declare float @llvm.sin.f32(float)
102
103 ; CHECK: Function
104 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] cos
105 ; CHECK: FunctionEnd
106
107 define spir_func float @TestCos(float %x) local_unnamed_addr {
108 entry:
109 %t = tail call float @llvm.cos.f32(float %x)
110 ret float %t
111 }
112
113 declare float @llvm.cos.f32(float)
114
115 ; CHECK: Function
116 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
117 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
118 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] pow [[x]] [[y]]
119 ; CHECK: FunctionEnd
120
121 define spir_func float @TestPow(float %x, float %y) local_unnamed_addr {
122 entry:
123 %t = tail call float @llvm.pow.f32(float %x, float %y)
124 ret float %t
125 }
126
127 declare float @llvm.pow.f32(float, float)
128
129 ; CHECK: Function
130 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] exp
131 ; CHECK: FunctionEnd
132
133 define spir_func float @TestExp(float %x) local_unnamed_addr {
134 entry:
135 %t = tail call float @llvm.exp.f32(float %x)
136 ret float %t
137 }
138
139 declare float @llvm.exp.f32(float)
140
141 ; CHECK: Function
142 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] exp2
143 ; CHECK: FunctionEnd
144
145 define spir_func float @TestExp2(float %x) local_unnamed_addr {
146 entry:
147 %t = tail call float @llvm.exp2.f32(float %x)
148 ret float %t
149 }
150
151 declare float @llvm.exp2.f32(float)
152
153 ; CHECK: Function
154 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] log
155 ; CHECK: FunctionEnd
156
157 define spir_func float @TestLog(float %x) local_unnamed_addr {
158 entry:
159 %t = tail call float @llvm.log.f32(float %x)
160 ret float %t
161 }
162
163 declare float @llvm.log.f32(float)
164
165 ; CHECK: Function
166 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] log10
167 ; CHECK: FunctionEnd
168
169 define spir_func float @TestLog10(float %x) local_unnamed_addr {
170 entry:
171 %t = tail call float @llvm.log10.f32(float %x)
172 ret float %t
173 }
174
175 declare float @llvm.log10.f32(float)
176
177 ; CHECK: Function
178 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] log2
179 ; CHECK: FunctionEnd
180
181 define spir_func float @TestLog2(float %x) local_unnamed_addr {
182 entry:
183 %t = tail call float @llvm.log2.f32(float %x)
184 ret float %t
185 }
186
187 declare float @llvm.log2.f32(float)
188
189 ; CHECK: Function
190 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
191 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
192 ; CHECK: ExtInst {{[0-9]+}} [[res:[0-9]+]] {{[0-9]+}} fmin [[x]] [[y]]
193 ; CHECK: ReturnValue [[res]]
194
195 define spir_func float @TestMinNum(float %x, float %y) {
196 entry:
197 %t = call float @llvm.minnum.f32(float %x, float %y)
198 ret float %t
199 }
200
201 declare float @llvm.minnum.f32(float, float)
202
203 ; CHECK: Function
204 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
205 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
206 ; CHECK: ExtInst {{[0-9]+}} [[res:[0-9]+]] {{[0-9]+}} fmax [[x]] [[y]]
207 ; CHECK: ReturnValue [[res]]
208
209 define spir_func float @TestMaxNum(float %x, float %y) {
210 entry:
211 %t = call float @llvm.maxnum.f32(float %x, float %y)
212 ret float %t
213 }
214
215 declare float @llvm.maxnum.f32(float, float)
216
217 ; CHECK: Function
218 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
219 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
220 ; CHECK: ExtInst {{[0-9]+}} [[res:[0-9]+]] {{[0-9]+}} fmin [[x]] [[y]]
221 ; CHECK: ReturnValue [[res]]
222
223 define spir_func float @TestMinimum(float %x, float %y) {
224 entry:
225 %t = call float @llvm.minimum.f32(float %x, float %y)
226 ret float %t
227 }
228
229 declare float @llvm.minimum.f32(float, float)
230
231 ; CHECK: Function
232 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
233 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
234 ; CHECK: ExtInst {{[0-9]+}} [[res:[0-9]+]] {{[0-9]+}} fmax [[x]] [[y]]
235 ; CHECK: ReturnValue [[res]]
236
237 define spir_func float @TestMaximum(float %x, float %y) {
238 entry:
239 %t = call float @llvm.maximum.f32(float %x, float %y)
240 ret float %t
241 }
242
243 declare float @llvm.maximum.f32(float, float)
244
245 ; CHECK: Function
246 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
247 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
248 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] copysign [[x]] [[y]]
249 ; CHECK: FunctionEnd
250
251 define spir_func float @TestCopysign(float %x, float %y) local_unnamed_addr {
252 entry:
253 %t = tail call float @llvm.copysign.f32(float %x, float %y)
254 ret float %t
255 }
256
257 declare float @llvm.copysign.f32(float, float)
258
259 ; CHECK: Function
260 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] floor
261 ; CHECK: FunctionEnd
262
263 define spir_func float @TestFloor(float %x) local_unnamed_addr {
264 entry:
265 %t = tail call float @llvm.floor.f32(float %x)
266 ret float %t
267 }
268
269 declare float @llvm.floor.f32(float)
270
271 ; CHECK: Function
272 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] trunc
273 ; CHECK: FunctionEnd
274
275 define spir_func float @TestTrunc(float %x) local_unnamed_addr {
276 entry:
277 %t = tail call float @llvm.trunc.f32(float %x)
278 ret float %t
279 }
280
281 declare float @llvm.trunc.f32(float)
282
283 ; CHECK: Function
284 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] rint
285 ; CHECK: FunctionEnd
286
287 define spir_func float @TestRint(float %x) local_unnamed_addr {
288 entry:
289 %t = tail call float @llvm.rint.f32(float %x)
290 ret float %t
291 }
292
293 declare float @llvm.rint.f32(float)
294
295 ; It is intentional that nearbyint translates to rint.
296 ; CHECK: Function
297 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] rint
298 ; CHECK: FunctionEnd
299
300 define spir_func float @TestNearbyint(float %x) local_unnamed_addr {
301 entry:
302 %t = tail call float @llvm.nearbyint.f32(float %x)
303 ret float %t
304 }
305
306 declare float @llvm.nearbyint.f32(float)
307
308 ; CHECK: Function
309 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] round
310 ; CHECK: FunctionEnd
311
312 define spir_func float @TestRound(float %x) local_unnamed_addr {
313 entry:
314 %t = tail call float @llvm.round.f32(float %x)
315 ret float %t
316 }
317
318 declare float @llvm.round.f32(float)
319
320 ; It is intentional that roundeven translates to rint.
321 ; CHECK: Function
322 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] rint
323 ; CHECK: FunctionEnd
324
325 define spir_func float @TestRoundEven(float %x) local_unnamed_addr {
326 entry:
327 %t = tail call float @llvm.roundeven.f32(float %x)
328 ret float %t
329 }
330
331 declare float @llvm.roundeven.f32(float)
332
333 ; CHECK: Function
334 ; CHECK: FunctionParameter {{[0-9]+}} [[x:[0-9]+]]
335 ; CHECK: FunctionParameter {{[0-9]+}} [[y:[0-9]+]]
336 ; CHECK: FunctionParameter {{[0-9]+}} [[z:[0-9]+]]
337 ; CHECK: ExtInst [[var1]] {{[0-9]+}} [[extinst_id]] fma [[x]] [[y]] [[z]]
338 ; CHECK: FunctionEnd
339
340 define spir_func float @TestFma(float %x, float %y, float %z) {
341 entry:
342 %t = tail call float @llvm.fma.f32(float %x, float %y, float %z)
343 ret float %t
344 }
345
346 declare float @llvm.fma.f32(float, float, float)