1 // RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(test-expand-math,convert-arith-to-llvm),convert-vector-to-scf,convert-scf-to-cf,convert-cf-to-llvm,convert-vector-to-llvm,func.func(convert-math-to-llvm),convert-func-to-llvm,reconcile-unrealized-casts)" \
2 // RUN: | mlir-cpu-runner \
3 // RUN: -e main -entry-point-result=void -O0 \
4 // RUN: -shared-libs=%mlir_c_runner_utils \
5 // RUN: -shared-libs=%mlir_runner_utils \
6 // RUN: -shared-libs=%mlir_float16_utils \
9 // -------------------------------------------------------------------------- //
11 // -------------------------------------------------------------------------- //
12 func.func @func_exp2f(%a : f64) {
13 %r = math.exp2 %a : f64
20 %a = arith.constant 1.0 : f64
21 call @func_exp2f(%a) : (f64) -> ()
24 %b = arith.constant 2.0 : f64
25 call @func_exp2f(%b) : (f64) -> ()
27 // CHECK-NEXT: 5.65685
28 %c = arith.constant 2.5 : f64
29 call @func_exp2f(%c) : (f64) -> ()
31 // CHECK-NEXT: 0.29730
32 %d = arith.constant -1.75 : f64
33 call @func_exp2f(%d) : (f64) -> ()
35 // CHECK-NEXT: 1.09581
36 %e = arith.constant 0.132 : f64
37 call @func_exp2f(%e) : (f64) -> ()
40 %f1 = arith.constant 0.00 : f64
41 %f2 = arith.constant 1.00 : f64
42 %f = arith.divf %f2, %f1 : f64
43 call @func_exp2f(%f) : (f64) -> ()
46 %g = arith.constant 5038939.0 : f64
47 call @func_exp2f(%g) : (f64) -> ()
50 %neg_inf = arith.constant 0xff80000000000000 : f64
51 call @func_exp2f(%neg_inf) : (f64) -> ()
54 %i = arith.constant 0x7fc0000000000000 : f64
55 call @func_exp2f(%i) : (f64) -> ()
59 // -------------------------------------------------------------------------- //
61 // -------------------------------------------------------------------------- //
62 func.func @func_roundf(%a : f32) {
63 %r = math.round %a : f32
68 func.func @func_roundf$bitcast_result_to_int(%a : f32) {
69 %b = math.round %a : f32
70 %c = arith.bitcast %b : f32 to i32
75 func.func @func_roundf$vector(%a : vector<1xf32>) {
76 %b = math.round %a : vector<1xf32>
77 vector.print %b : vector<1xf32>
83 %a = arith.constant 3.8 : f32
84 call @func_roundf(%a) : (f32) -> ()
87 %b = arith.constant -3.8 : f32
88 call @func_roundf(%b) : (f32) -> ()
91 %c = arith.constant -4.2 : f32
92 call @func_roundf(%c) : (f32) -> ()
95 %d = arith.constant -495.0 : f32
96 call @func_roundf(%d) : (f32) -> ()
99 %e = arith.constant 495.0 : f32
100 call @func_roundf(%e) : (f32) -> ()
103 %f = arith.constant 8.5 : f32
104 call @func_roundf(%f) : (f32) -> ()
107 %g = arith.constant -8.5 : f32
108 call @func_roundf(%g) : (f32) -> ()
111 %h = arith.constant -0.4 : f32
112 call @func_roundf(%h) : (f32) -> ()
114 // Special values: 0, -0, inf, -inf, nan, -nan
115 %cNeg0 = arith.constant -0.0 : f32
116 %c0 = arith.constant 0.0 : f32
117 %cInfInt = arith.constant 0x7f800000 : i32
118 %cInf = arith.bitcast %cInfInt : i32 to f32
119 %cNegInfInt = arith.constant 0xff800000 : i32
120 %cNegInf = arith.bitcast %cNegInfInt : i32 to f32
121 %cNanInt = arith.constant 0x7fc00000 : i32
122 %cNan = arith.bitcast %cNanInt : i32 to f32
123 %cNegNanInt = arith.constant 0xffc00000 : i32
124 %cNegNan = arith.bitcast %cNegNanInt : i32 to f32
127 call @func_roundf(%cNeg0) : (f32) -> ()
129 call @func_roundf(%c0) : (f32) -> ()
131 call @func_roundf(%cInf) : (f32) -> ()
133 call @func_roundf(%cNegInf) : (f32) -> ()
134 // Per IEEE 754-2008, sign is not required when printing a negative NaN, so
135 // print as an int to ensure input NaN is left unchanged.
136 // CHECK-NEXT: 2143289344
137 // CHECK-NEXT: 2143289344
138 call @func_roundf$bitcast_result_to_int(%cNan) : (f32) -> ()
139 vector.print %cNanInt : i32
140 // CHECK-NEXT: -4194304
141 // CHECK-NEXT: -4194304
142 call @func_roundf$bitcast_result_to_int(%cNegNan) : (f32) -> ()
143 vector.print %cNegNanInt : i32
145 // Very large values (greater than INT_64_MAX)
146 %c2To100 = arith.constant 1.268e30 : f32 // 2^100
147 // CHECK-NEXT: 1.268e+30
148 call @func_roundf(%c2To100) : (f32) -> ()
150 // Values above and below 2^23 = 8388608
151 %c8388606_5 = arith.constant 8388606.5 : f32
152 %c8388607 = arith.constant 8388607.0 : f32
153 %c8388607_5 = arith.constant 8388607.5 : f32
154 %c8388608 = arith.constant 8388608.0 : f32
155 %c8388609 = arith.constant 8388609.0 : f32
157 // Bitcast result to int to avoid printing in scientific notation,
158 // which does not display all significant digits.
160 // CHECK-NEXT: 1258291198
162 call @func_roundf$bitcast_result_to_int(%c8388606_5) : (f32) -> ()
163 // CHECK-NEXT: 1258291198
165 call @func_roundf$bitcast_result_to_int(%c8388607) : (f32) -> ()
166 // CHECK-NEXT: 1258291200
168 call @func_roundf$bitcast_result_to_int(%c8388607_5) : (f32) -> ()
169 // CHECK-NEXT: 1258291200
171 call @func_roundf$bitcast_result_to_int(%c8388608) : (f32) -> ()
172 // CHECK-NEXT: 1258291201
174 call @func_roundf$bitcast_result_to_int(%c8388609) : (f32) -> ()
176 // Check that vector type works
177 %cVec = arith.constant dense<[0.5]> : vector<1xf32>
179 call @func_roundf$vector(%cVec) : (vector<1xf32>) -> ()
184 // -------------------------------------------------------------------------- //
186 // -------------------------------------------------------------------------- //
187 func.func @func_powff64(%a : f64, %b : f64) {
188 %r = math.powf %a, %b : f64
189 vector.print %r : f64
193 func.func @func_powff32(%a : f32, %b : f32) {
194 %r = math.powf %a, %b : f32
195 vector.print %r : f32
201 %a = arith.constant 4.0 : f64
202 %a_p = arith.constant 2.0 : f64
203 call @func_powff64(%a, %a_p) : (f64, f64) -> ()
206 %b = arith.constant -3.0 : f64
207 %b_p = arith.constant 3.0 : f64
208 call @func_powff64(%b, %b_p) : (f64, f64) -> ()
211 %c = arith.constant 2.343 : f64
212 %c_p = arith.constant 1.000 : f64
213 call @func_powff64(%c, %c_p) : (f64, f64) -> ()
215 // CHECK-NEXT: 0.176171
216 %d = arith.constant 4.25 : f64
217 %d_p = arith.constant -1.2 : f64
218 call @func_powff64(%d, %d_p) : (f64, f64) -> ()
221 %e = arith.constant 4.385 : f64
222 %e_p = arith.constant 0.00 : f64
223 call @func_powff64(%e, %e_p) : (f64, f64) -> ()
225 // CHECK-NEXT: 6.62637
226 %f = arith.constant 4.835 : f64
227 %f_p = arith.constant 1.2 : f64
228 call @func_powff64(%f, %f_p) : (f64, f64) -> ()
231 %i = arith.constant 1.0 : f64
232 %h = arith.constant 0x7fffffffffffffff : f64
233 call @func_powff64(%i, %h) : (f64, f64) -> ()
236 %j = arith.constant 29385.0 : f64
237 %j_p = arith.constant 23598.0 : f64
238 call @func_powff64(%j, %j_p) : (f64, f64) -> ()
241 %k = arith.constant 1.0 : f64
242 %k_p = arith.constant 0xfff0000001000000 : f64
243 call @func_powff64(%k, %k_p) : (f64, f64) -> ()
246 %l = arith.constant 1.0 : f32
247 %l_p = arith.constant 0xffffffff : f32
248 call @func_powff32(%l, %l_p) : (f32, f32) -> ()
252 // -------------------------------------------------------------------------- //
254 // -------------------------------------------------------------------------- //
256 func.func @func_roundeven32(%a : f32) {
257 %b = math.roundeven %a : f32
258 vector.print %b : f32
262 func.func @func_roundeven32$bitcast_result_to_int(%a : f32) {
263 %b = math.roundeven %a : f32
264 %c = arith.bitcast %b : f32 to i32
265 vector.print %c : i32
269 func.func @func_roundeven32$vector(%a : vector<1xf32>) {
270 %b = math.roundeven %a : vector<1xf32>
271 vector.print %b : vector<1xf32>
275 func.func @roundeven32() {
276 %c0_25 = arith.constant 0.25 : f32
277 %c0_5 = arith.constant 0.5 : f32
278 %c0_75 = arith.constant 0.75 : f32
279 %c1 = arith.constant 1.0 : f32
280 %c1_25 = arith.constant 1.25 : f32
281 %c1_5 = arith.constant 1.5 : f32
282 %c1_75 = arith.constant 1.75 : f32
283 %c2 = arith.constant 2.0 : f32
284 %c2_25 = arith.constant 2.25 : f32
285 %c2_5 = arith.constant 2.5 : f32
286 %c2_75 = arith.constant 2.75 : f32
287 %c3 = arith.constant 3.0 : f32
288 %c3_25 = arith.constant 3.25 : f32
289 %c3_5 = arith.constant 3.5 : f32
290 %c3_75 = arith.constant 3.75 : f32
292 %cNeg0_25 = arith.constant -0.25 : f32
293 %cNeg0_5 = arith.constant -0.5 : f32
294 %cNeg0_75 = arith.constant -0.75 : f32
295 %cNeg1 = arith.constant -1.0 : f32
296 %cNeg1_25 = arith.constant -1.25 : f32
297 %cNeg1_5 = arith.constant -1.5 : f32
298 %cNeg1_75 = arith.constant -1.75 : f32
299 %cNeg2 = arith.constant -2.0 : f32
300 %cNeg2_25 = arith.constant -2.25 : f32
301 %cNeg2_5 = arith.constant -2.5 : f32
302 %cNeg2_75 = arith.constant -2.75 : f32
303 %cNeg3 = arith.constant -3.0 : f32
304 %cNeg3_25 = arith.constant -3.25 : f32
305 %cNeg3_5 = arith.constant -3.5 : f32
306 %cNeg3_75 = arith.constant -3.75 : f32
309 call @func_roundeven32(%c0_25) : (f32) -> ()
311 call @func_roundeven32(%c0_5) : (f32) -> ()
313 call @func_roundeven32(%c0_75) : (f32) -> ()
315 call @func_roundeven32(%c1) : (f32) -> ()
317 call @func_roundeven32(%c1_25) : (f32) -> ()
319 call @func_roundeven32(%c1_5) : (f32) -> ()
321 call @func_roundeven32(%c1_75) : (f32) -> ()
323 call @func_roundeven32(%c2) : (f32) -> ()
325 call @func_roundeven32(%c2_25) : (f32) -> ()
327 call @func_roundeven32(%c2_5) : (f32) -> ()
329 call @func_roundeven32(%c2_75) : (f32) -> ()
331 call @func_roundeven32(%c3) : (f32) -> ()
333 call @func_roundeven32(%c3_25) : (f32) -> ()
335 call @func_roundeven32(%c3_5) : (f32) -> ()
337 call @func_roundeven32(%c3_75) : (f32) -> ()
340 call @func_roundeven32(%cNeg0_25) : (f32) -> ()
342 call @func_roundeven32(%cNeg0_5) : (f32) -> ()
344 call @func_roundeven32(%cNeg0_75) : (f32) -> ()
346 call @func_roundeven32(%cNeg1) : (f32) -> ()
348 call @func_roundeven32(%cNeg1_25) : (f32) -> ()
350 call @func_roundeven32(%cNeg1_5) : (f32) -> ()
352 call @func_roundeven32(%cNeg1_75) : (f32) -> ()
354 call @func_roundeven32(%cNeg2) : (f32) -> ()
356 call @func_roundeven32(%cNeg2_25) : (f32) -> ()
358 call @func_roundeven32(%cNeg2_5) : (f32) -> ()
360 call @func_roundeven32(%cNeg2_75) : (f32) -> ()
362 call @func_roundeven32(%cNeg3) : (f32) -> ()
364 call @func_roundeven32(%cNeg3_25) : (f32) -> ()
366 call @func_roundeven32(%cNeg3_5) : (f32) -> ()
368 call @func_roundeven32(%cNeg3_75) : (f32) -> ()
370 // Special values: 0, -0, inf, -inf, nan, -nan
371 %cNeg0 = arith.constant -0.0 : f32
372 %c0 = arith.constant 0.0 : f32
373 %cInfInt = arith.constant 0x7f800000 : i32
374 %cInf = arith.bitcast %cInfInt : i32 to f32
375 %cNegInfInt = arith.constant 0xff800000 : i32
376 %cNegInf = arith.bitcast %cNegInfInt : i32 to f32
377 %cNanInt = arith.constant 0x7fc00000 : i32
378 %cNan = arith.bitcast %cNanInt : i32 to f32
379 %cNegNanInt = arith.constant 0xffc00000 : i32
380 %cNegNan = arith.bitcast %cNegNanInt : i32 to f32
383 call @func_roundeven32(%cNeg0) : (f32) -> ()
385 call @func_roundeven32(%c0) : (f32) -> ()
387 call @func_roundeven32(%cInf) : (f32) -> ()
389 call @func_roundeven32(%cNegInf) : (f32) -> ()
390 // Per IEEE 754-2008, sign is not required when printing a negative NaN, so
391 // print as an int to ensure input NaN is left unchanged.
392 // CHECK-NEXT: 2143289344
393 // CHECK-NEXT: 2143289344
394 call @func_roundeven32$bitcast_result_to_int(%cNan) : (f32) -> ()
395 vector.print %cNanInt : i32
396 // CHECK-NEXT: -4194304
397 // CHECK-NEXT: -4194304
398 call @func_roundeven32$bitcast_result_to_int(%cNegNan) : (f32) -> ()
399 vector.print %cNegNanInt : i32
402 // Values above and below 2^23 = 8388608
403 %c8388606_5 = arith.constant 8388606.5 : f32
404 %c8388607 = arith.constant 8388607.0 : f32
405 %c8388607_5 = arith.constant 8388607.5 : f32
406 %c8388608 = arith.constant 8388608.0 : f32
407 %c8388609 = arith.constant 8388609.0 : f32
409 // Bitcast result to int to avoid printing in scientific notation,
410 // which does not display all significant digits.
412 // CHECK-NEXT: 1258291196
414 call @func_roundeven32$bitcast_result_to_int(%c8388606_5) : (f32) -> ()
415 // CHECK-NEXT: 1258291198
417 call @func_roundeven32$bitcast_result_to_int(%c8388607) : (f32) -> ()
418 // CHECK-NEXT: 1258291200
420 call @func_roundeven32$bitcast_result_to_int(%c8388607_5) : (f32) -> ()
421 // CHECK-NEXT: 1258291200
423 call @func_roundeven32$bitcast_result_to_int(%c8388608) : (f32) -> ()
424 // CHECK-NEXT: 1258291201
426 call @func_roundeven32$bitcast_result_to_int(%c8388609) : (f32) -> ()
429 // Check that vector type works
430 %cVec = arith.constant dense<[0.5]> : vector<1xf32>
432 call @func_roundeven32$vector(%cVec) : (vector<1xf32>) -> ()
436 func.func @func_roundeven64(%a : f64) {
437 %b = math.roundeven %a : f64
438 vector.print %b : f64
442 func.func @func_roundeven64$bitcast_result_to_int(%a : f64) {
443 %b = math.roundeven %a : f64
444 %c = arith.bitcast %b : f64 to i64
445 vector.print %c : i64
449 func.func @func_roundeven64$vector(%a : vector<1xf64>) {
450 %b = math.roundeven %a : vector<1xf64>
451 vector.print %b : vector<1xf64>
455 func.func @roundeven64() {
456 %c0_25 = arith.constant 0.25 : f64
457 %c0_5 = arith.constant 0.5 : f64
458 %c0_75 = arith.constant 0.75 : f64
459 %c1 = arith.constant 1.0 : f64
460 %c1_25 = arith.constant 1.25 : f64
461 %c1_5 = arith.constant 1.5 : f64
462 %c1_75 = arith.constant 1.75 : f64
463 %c2 = arith.constant 2.0 : f64
464 %c2_25 = arith.constant 2.25 : f64
465 %c2_5 = arith.constant 2.5 : f64
466 %c2_75 = arith.constant 2.75 : f64
467 %c3 = arith.constant 3.0 : f64
468 %c3_25 = arith.constant 3.25 : f64
469 %c3_5 = arith.constant 3.5 : f64
470 %c3_75 = arith.constant 3.75 : f64
472 %cNeg0_25 = arith.constant -0.25 : f64
473 %cNeg0_5 = arith.constant -0.5 : f64
474 %cNeg0_75 = arith.constant -0.75 : f64
475 %cNeg1 = arith.constant -1.0 : f64
476 %cNeg1_25 = arith.constant -1.25 : f64
477 %cNeg1_5 = arith.constant -1.5 : f64
478 %cNeg1_75 = arith.constant -1.75 : f64
479 %cNeg2 = arith.constant -2.0 : f64
480 %cNeg2_25 = arith.constant -2.25 : f64
481 %cNeg2_5 = arith.constant -2.5 : f64
482 %cNeg2_75 = arith.constant -2.75 : f64
483 %cNeg3 = arith.constant -3.0 : f64
484 %cNeg3_25 = arith.constant -3.25 : f64
485 %cNeg3_5 = arith.constant -3.5 : f64
486 %cNeg3_75 = arith.constant -3.75 : f64
489 call @func_roundeven64(%c0_25) : (f64) -> ()
491 call @func_roundeven64(%c0_5) : (f64) -> ()
493 call @func_roundeven64(%c0_75) : (f64) -> ()
495 call @func_roundeven64(%c1) : (f64) -> ()
497 call @func_roundeven64(%c1_25) : (f64) -> ()
499 call @func_roundeven64(%c1_5) : (f64) -> ()
501 call @func_roundeven64(%c1_75) : (f64) -> ()
503 call @func_roundeven64(%c2) : (f64) -> ()
505 call @func_roundeven64(%c2_25) : (f64) -> ()
507 call @func_roundeven64(%c2_5) : (f64) -> ()
509 call @func_roundeven64(%c2_75) : (f64) -> ()
511 call @func_roundeven64(%c3) : (f64) -> ()
513 call @func_roundeven64(%c3_25) : (f64) -> ()
515 call @func_roundeven64(%c3_5) : (f64) -> ()
517 call @func_roundeven64(%c3_75) : (f64) -> ()
520 call @func_roundeven64(%cNeg0_25) : (f64) -> ()
522 call @func_roundeven64(%cNeg0_5) : (f64) -> ()
524 call @func_roundeven64(%cNeg0_75) : (f64) -> ()
526 call @func_roundeven64(%cNeg1) : (f64) -> ()
528 call @func_roundeven64(%cNeg1_25) : (f64) -> ()
530 call @func_roundeven64(%cNeg1_5) : (f64) -> ()
532 call @func_roundeven64(%cNeg1_75) : (f64) -> ()
534 call @func_roundeven64(%cNeg2) : (f64) -> ()
536 call @func_roundeven64(%cNeg2_25) : (f64) -> ()
538 call @func_roundeven64(%cNeg2_5) : (f64) -> ()
540 call @func_roundeven64(%cNeg2_75) : (f64) -> ()
542 call @func_roundeven64(%cNeg3) : (f64) -> ()
544 call @func_roundeven64(%cNeg3_25) : (f64) -> ()
546 call @func_roundeven64(%cNeg3_5) : (f64) -> ()
548 call @func_roundeven64(%cNeg3_75) : (f64) -> ()
550 // Special values: 0, -0, inf, -inf, nan, -nan
551 %cNeg0 = arith.constant -0.0 : f64
552 %c0 = arith.constant 0.0 : f64
553 %cInfInt = arith.constant 0x7FF0000000000000 : i64
554 %cInf = arith.bitcast %cInfInt : i64 to f64
555 %cNegInfInt = arith.constant 0xFFF0000000000000 : i64
556 %cNegInf = arith.bitcast %cNegInfInt : i64 to f64
557 %cNanInt = arith.constant 0x7FF0000000000001 : i64
558 %cNan = arith.bitcast %cNanInt : i64 to f64
559 %cNegNanInt = arith.constant 0xFFF0000000000001 : i64
560 %cNegNan = arith.bitcast %cNegNanInt : i64 to f64
563 call @func_roundeven64(%cNeg0) : (f64) -> ()
565 call @func_roundeven64(%c0) : (f64) -> ()
567 call @func_roundeven64(%cInf) : (f64) -> ()
569 call @func_roundeven64(%cNegInf) : (f64) -> ()
571 // Values above and below 2^52 = 4503599627370496
572 %c4503599627370494_5 = arith.constant 4503599627370494.5 : f64
573 %c4503599627370495 = arith.constant 4503599627370495.0 : f64
574 %c4503599627370495_5 = arith.constant 4503599627370495.5 : f64
575 %c4503599627370496 = arith.constant 4503599627370496.0 : f64
576 %c4503599627370497 = arith.constant 4503599627370497.0 : f64
578 // Bitcast result to int to avoid printing in scientific notation,
579 // which does not display all significant digits.
581 // CHECK-NEXT: 4841369599423283196
582 // hex: 0x432ffffffffffffc
583 call @func_roundeven64$bitcast_result_to_int(%c4503599627370494_5) : (f64) -> ()
584 // CHECK-NEXT: 4841369599423283198
585 // hex: 0x432ffffffffffffe
586 call @func_roundeven64$bitcast_result_to_int(%c4503599627370495) : (f64) -> ()
587 // CHECK-NEXT: 4841369599423283200
588 // hex: 0x4330000000000000
589 call @func_roundeven64$bitcast_result_to_int(%c4503599627370495_5) : (f64) -> ()
590 // CHECK-NEXT: 4841369599423283200
591 // hex: 0x10000000000000
592 call @func_roundeven64$bitcast_result_to_int(%c4503599627370496) : (f64) -> ()
593 // CHECK-NEXT: 4841369599423283201
594 // hex: 0x10000000000001
595 call @func_roundeven64$bitcast_result_to_int(%c4503599627370497) : (f64) -> ()
597 // Check that vector type works
598 %cVec = arith.constant dense<[0.5]> : vector<1xf64>
600 call @func_roundeven64$vector(%cVec) : (vector<1xf64>) -> ()
604 func.func @roundeven() {
605 call @roundeven32() : () -> ()
606 call @roundeven64() : () -> ()
610 // -------------------------------------------------------------------------- //
612 // -------------------------------------------------------------------------- //
614 func.func @sinh_f32(%a : f32) {
615 %r = math.sinh %a : f32
616 vector.print %r : f32
620 func.func @sinh_4xf32(%a : vector<4xf32>) {
621 %r = math.sinh %a : vector<4xf32>
622 vector.print %r : vector<4xf32>
626 func.func @sinh_8xf32(%a : vector<8xf32>) {
627 %r = math.sinh %a : vector<8xf32>
628 vector.print %r : vector<8xf32>
634 %f0 = arith.constant 1.25 : f32
635 call @sinh_f32(%f0) : (f32) -> ()
637 // CHECK: 0.252612, 0.822317, 1.1752, 1.60192
638 %v1 = arith.constant dense<[0.25, 0.75, 1.0, 1.25]> : vector<4xf32>
639 call @sinh_4xf32(%v1) : (vector<4xf32>) -> ()
641 // CHECK: 0.100167, 0.201336, 0.30452, 0.410752, 0.521095, 0.636654, 0.758584, 0.888106
642 %v2 = arith.constant dense<[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]> : vector<8xf32>
643 call @sinh_8xf32(%v2) : (vector<8xf32>) -> ()
645 // CHECK: -0.100167, -0.201336, -0.30452, -0.410752, -0.521095, -0.636654, -0.758584, -0.888106
646 %v3 = arith.constant dense<[-0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8]> : vector<8xf32>
647 call @sinh_8xf32(%v3) : (vector<8xf32>) -> ()
650 %nan = arith.constant 0x7fc00000 : f32
651 call @sinh_f32(%nan) : (f32) -> ()
656 // -------------------------------------------------------------------------- //
658 // -------------------------------------------------------------------------- //
660 func.func @cosh_f32(%a : f32) {
661 %r = math.cosh %a : f32
662 vector.print %r : f32
666 func.func @cosh_4xf32(%a : vector<4xf32>) {
667 %r = math.cosh %a : vector<4xf32>
668 vector.print %r : vector<4xf32>
672 func.func @cosh_8xf32(%a : vector<8xf32>) {
673 %r = math.cosh %a : vector<8xf32>
674 vector.print %r : vector<8xf32>
680 %f0 = arith.constant 1.25 : f32
681 call @cosh_f32(%f0) : (f32) -> ()
683 // CHECK: 1.03141, 1.29468, 1.54308, 1.88842
684 %v1 = arith.constant dense<[0.25, 0.75, 1.0, 1.25]> : vector<4xf32>
685 call @cosh_4xf32(%v1) : (vector<4xf32>) -> ()
687 // CHECK: 1.005, 1.02007, 1.04534, 1.08107, 1.12763, 1.18547, 1.25517, 1.33743
688 %v2 = arith.constant dense<[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]> : vector<8xf32>
689 call @cosh_8xf32(%v2) : (vector<8xf32>) -> ()
691 // CHECK: 1.005, 1.02007, 1.04534, 1.08107, 1.12763, 1.18547, 1.25517, 1.33743
692 %v3 = arith.constant dense<[-0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8]> : vector<8xf32>
693 call @cosh_8xf32(%v3) : (vector<8xf32>) -> ()
696 %nan = arith.constant 0x7fc00000 : f32
697 call @cosh_f32(%nan) : (f32) -> ()
702 // -------------------------------------------------------------------------- //
704 // -------------------------------------------------------------------------- //
706 func.func @tanh_8xf32(%a : vector<8xf32>) {
707 %r = math.tanh %a : vector<8xf32>
708 vector.print %r : vector<8xf32>
713 // CHECK: -1, -0.761594, -0.291313, 0, 0.291313, 0.761594, 1, 1
714 %v3 = arith.constant dense<[0xff800000, -1.0, -0.3, 0.0, 0.3, 1.0, 10.0, 0x7f800000]> : vector<8xf32>
715 call @tanh_8xf32(%v3) : (vector<8xf32>) -> ()
720 // -------------------------------------------------------------------------- //
722 // -------------------------------------------------------------------------- //
724 func.func @asinh_f32(%a : f32) {
725 %r = math.asinh %a : f32
726 vector.print %r : f32
730 func.func @asinh_3xf32(%a : vector<3xf32>) {
731 %r = math.asinh %a : vector<3xf32>
732 vector.print %r : vector<3xf32>
738 %zero = arith.constant 0.0 : f32
739 call @asinh_f32(%zero) : (f32) -> ()
742 %cst1 = arith.constant 1.0 : f32
743 call @asinh_f32(%cst1) : (f32) -> ()
746 %cst2 = arith.constant -1.0 : f32
747 call @asinh_f32(%cst2) : (f32) -> ()
750 %cst3 = arith.constant 3.0 : f32
751 call @asinh_f32(%cst3) : (f32) -> ()
753 // CHECK: 0.247466, 0.790169, 1.44364
754 %vec_x = arith.constant dense<[0.25, 0.875, 2.0]> : vector<3xf32>
755 call @asinh_3xf32(%vec_x) : (vector<3xf32>) -> ()
760 // -------------------------------------------------------------------------- //
762 // -------------------------------------------------------------------------- //
764 func.func @acosh_f32(%a : f32) {
765 %r = math.acosh %a : f32
766 vector.print %r : f32
770 func.func @acosh_3xf32(%a : vector<3xf32>) {
771 %r = math.acosh %a : vector<3xf32>
772 vector.print %r : vector<3xf32>
778 %zero = arith.constant 1.0 : f32
779 call @acosh_f32(%zero) : (f32) -> ()
782 %cst1 = arith.constant 2.0 : f32
783 call @acosh_f32(%cst1) : (f32) -> ()
786 %cst2 = arith.constant 10.0 : f32
787 call @acosh_f32(%cst2) : (f32) -> ()
789 // CHECK: 0.962424, 1.76275, 2.47789
790 %vec_x = arith.constant dense<[1.5, 3.0, 6.0]> : vector<3xf32>
791 call @acosh_3xf32(%vec_x) : (vector<3xf32>) -> ()
796 // -------------------------------------------------------------------------- //
798 // -------------------------------------------------------------------------- //
800 func.func @atanh_f32(%a : f32) {
801 %r = math.atanh %a : f32
802 vector.print %r : f32
806 func.func @atanh_3xf32(%a : vector<3xf32>) {
807 %r = math.atanh %a : vector<3xf32>
808 vector.print %r : vector<3xf32>
814 %zero = arith.constant 0.0 : f32
815 call @atanh_f32(%zero) : (f32) -> ()
818 %cst1 = arith.constant 0.5 : f32
819 call @atanh_f32(%cst1) : (f32) -> ()
822 %cst2 = arith.constant -0.5 : f32
823 call @atanh_f32(%cst2) : (f32) -> ()
826 %cst3 = arith.constant 1.0 : f32
827 call @atanh_f32(%cst3) : (f32) -> ()
829 // CHECK: 0.255413, 0.394229, 2.99448
830 %vec_x = arith.constant dense<[0.25, 0.375, 0.995]> : vector<3xf32>
831 call @atanh_3xf32(%vec_x) : (vector<3xf32>) -> ()
836 // -------------------------------------------------------------------------- //
838 // -------------------------------------------------------------------------- //
840 func.func @rsqrt_f32(%a : f32) {
841 %r = math.rsqrt %a : f32
842 vector.print %r : f32
846 func.func @rsqrt_3xf32(%a : vector<3xf32>) {
847 %r = math.rsqrt %a : vector<3xf32>
848 vector.print %r : vector<3xf32>
854 %zero = arith.constant 1.0 : f32
855 call @rsqrt_f32(%zero) : (f32) -> ()
858 %cst1 = arith.constant 2.0 : f32
859 call @rsqrt_f32(%cst1) : (f32) -> ()
862 %cst2 = arith.constant 0.0 : f32
863 call @rsqrt_f32(%cst2) : (f32) -> ()
866 %cst3 = arith.constant -1.0 : f32
867 call @rsqrt_f32(%cst3) : (f32) -> ()
869 // CHECK: 0.5, 1.41421, 0.57735
870 %vec_x = arith.constant dense<[4.0, 0.5, 3.0]> : vector<3xf32>
871 call @rsqrt_3xf32(%vec_x) : (vector<3xf32>) -> ()
877 call @exp2f() : () -> ()
878 call @roundf() : () -> ()
879 call @powf() : () -> ()
880 call @roundeven() : () -> ()
881 call @sinh() : () -> ()
882 call @cosh() : () -> ()
883 call @tanh() : () -> ()
884 call @asinh() : () -> ()
885 call @acosh() : () -> ()
886 call @atanh() : () -> ()
887 call @rsqrt() : () -> ()