860 lines · plain
1// RUN: mlir-opt %s -pass-pipeline="builtin.module(func.func(test-math-polynomial-approximation),convert-vector-to-scf,convert-scf-to-cf,convert-vector-to-llvm,convert-to-llvm,reconcile-unrealized-casts)" \2// RUN: | mlir-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: | FileCheck %s7 8// -------------------------------------------------------------------------- //9// Tanh.10// -------------------------------------------------------------------------- //11 12func.func @tanh_f32(%a : f32) {13 %r = math.tanh %a : f3214 vector.print %r : f3215 return16}17 18func.func @tanh_4xf32(%a : vector<4xf32>) {19 %r = math.tanh %a : vector<4xf32>20 vector.print %r : vector<4xf32>21 return22}23 24func.func @tanh_8xf32(%a : vector<8xf32>) {25 %r = math.tanh %a : vector<8xf32>26 vector.print %r : vector<8xf32>27 return28}29 30func.func @tanh() {31 // CHECK: 0.84828432 %f0 = arith.constant 1.25 : f3233 call @tanh_f32(%f0) : (f32) -> ()34 35 // CHECK: 0.244919, 0.635149, 0.761594, 0.84828436 %v1 = arith.constant dense<[0.25, 0.75, 1.0, 1.25]> : vector<4xf32>37 call @tanh_4xf32(%v1) : (vector<4xf32>) -> ()38 39 // CHECK: 0.099668, 0.197375, 0.291313, 0.379949, 0.462117, 0.53705, 0.604368, 0.66403740 %v2 = arith.constant dense<[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]> : vector<8xf32>41 call @tanh_8xf32(%v2) : (vector<8xf32>) -> ()42 43 // CHECK: nan44 %nan = arith.constant 0x7fc00000 : f3245 call @tanh_f32(%nan) : (f32) -> ()46 47 return48}49 50// -------------------------------------------------------------------------- //51// Log.52// -------------------------------------------------------------------------- //53 54func.func @log_f32(%a : f32) {55 %r = math.log %a : f3256 vector.print %r : f3257 return58}59 60func.func @log_4xf32(%a : vector<4xf32>) {61 %r = math.log %a : vector<4xf32>62 vector.print %r : vector<4xf32>63 return64}65 66func.func @log_8xf32(%a : vector<8xf32>) {67 %r = math.log %a : vector<8xf32>68 vector.print %r : vector<8xf32>69 return70}71 72func.func @log() {73 // CHECK: 2.6470474 %f1 = arith.constant 14.112233 : f3275 call @log_f32(%f1) : (f32) -> ()76 77 // CHECK: -1.38629, -0.287682, 0, 0.22314478 %v1 = arith.constant dense<[0.25, 0.75, 1.0, 1.25]> : vector<4xf32>79 call @log_4xf32(%v1) : (vector<4xf32>) -> ()80 81 // CHECK: -2.30259, -1.60944, -1.20397, -0.916291, -0.693147, -0.510826, -0.356675, -0.22314482 %v2 = arith.constant dense<[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]> : vector<8xf32>83 call @log_8xf32(%v2) : (vector<8xf32>) -> ()84 85 // CHECK: -inf86 %zero = arith.constant 0.0 : f3287 call @log_f32(%zero) : (f32) -> ()88 89 // CHECK: nan90 %nan = arith.constant 0x7fc00000 : f3291 call @log_f32(%nan) : (f32) -> ()92 93 // CHECK: inf94 %inf = arith.constant 0x7f800000 : f3295 call @log_f32(%inf) : (f32) -> ()96 97 // CHECK: -inf, nan, inf, 0.69314798 %special_vec = arith.constant dense<[0.0, -1.0, 0x7f800000, 2.0]> : vector<4xf32>99 call @log_4xf32(%special_vec) : (vector<4xf32>) -> ()100 101 return102}103 104func.func @log2_f32(%a : f32) {105 %r = math.log2 %a : f32106 vector.print %r : f32107 return108}109 110func.func @log2_4xf32(%a : vector<4xf32>) {111 %r = math.log2 %a : vector<4xf32>112 vector.print %r : vector<4xf32>113 return114}115 116func.func @log2_8xf32(%a : vector<8xf32>) {117 %r = math.log2 %a : vector<8xf32>118 vector.print %r : vector<8xf32>119 return120}121 122func.func @log2() {123 // CHECK: 3.81887124 %f0 = arith.constant 14.112233 : f32125 call @log2_f32(%f0) : (f32) -> ()126 127 // CHECK: -2, -0.415037, 0, 0.321928128 %v1 = arith.constant dense<[0.25, 0.75, 1.0, 1.25]> : vector<4xf32>129 call @log2_4xf32(%v1) : (vector<4xf32>) -> ()130 131 // CHECK: -3.32193, -2.32193, -1.73697, -1.32193, -1, -0.736966, -0.514573, -0.321928132 %v2 = arith.constant dense<[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]> : vector<8xf32>133 call @log2_8xf32(%v2) : (vector<8xf32>) -> ()134 135 // CHECK: -inf136 %zero = arith.constant 0.0 : f32137 call @log2_f32(%zero) : (f32) -> ()138 139 // CHECK: nan140 %neg_one = arith.constant -1.0 : f32141 call @log2_f32(%neg_one) : (f32) -> ()142 143 // CHECK: inf144 %inf = arith.constant 0x7f800000 : f32145 call @log2_f32(%inf) : (f32) -> ()146 147 // CHECK: -inf, nan, inf, 1.58496148 %special_vec = arith.constant dense<[0.0, -1.0, 0x7f800000, 3.0]> : vector<4xf32>149 call @log2_4xf32(%special_vec) : (vector<4xf32>) -> ()150 151 return152}153 154func.func @log1p_f32(%a : f32) {155 %r = math.log1p %a : f32156 vector.print %r : f32157 return158}159 160func.func @log1p_4xf32(%a : vector<4xf32>) {161 %r = math.log1p %a : vector<4xf32>162 vector.print %r : vector<4xf32>163 return164}165 166func.func @log1p_8xf32(%a : vector<8xf32>) {167 %r = math.log1p %a : vector<8xf32>168 vector.print %r : vector<8xf32>169 return170}171 172func.func @log1p() {173 // CHECK: 0.00995033174 %f0 = arith.constant 0.01 : f32175 call @log1p_f32(%f0) : (f32) -> ()176 177 178 // CHECK: -4.60517, -0.693147, 0, 1.38629179 %v1 = arith.constant dense<[-0.99, -0.5, 0.0, 3.0]> : vector<4xf32>180 call @log1p_4xf32(%v1) : (vector<4xf32>) -> ()181 182 // CHECK: 0.0953102, 0.182322, 0.262364, 0.336472, 0.405465, 0.470004, 0.530628, 0.587787183 %v2 = arith.constant dense<[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]> : vector<8xf32>184 call @log1p_8xf32(%v2) : (vector<8xf32>) -> ()185 186 // CHECK: -inf187 %neg_one = arith.constant -1.0 : f32188 call @log1p_f32(%neg_one) : (f32) -> ()189 190 // CHECK: nan191 %neg_two = arith.constant -2.0 : f32192 call @log1p_f32(%neg_two) : (f32) -> ()193 194 // CHECK: inf195 %inf = arith.constant 0x7f800000 : f32196 call @log1p_f32(%inf) : (f32) -> ()197 198 // CHECK: -inf, nan, inf, 9.99995e-06199 %special_vec = arith.constant dense<[-1.0, -1.1, 0x7f800000, 0.00001]> : vector<4xf32>200 call @log1p_4xf32(%special_vec) : (vector<4xf32>) -> ()201 202 return203}204 205// -------------------------------------------------------------------------- //206// Erf.207// -------------------------------------------------------------------------- //208func.func @erf_f32(%a : f32) {209 %r = math.erf %a : f32210 vector.print %r : f32211 return212}213 214func.func @erf_4xf32(%a : vector<4xf32>) {215 %r = math.erf %a : vector<4xf32>216 vector.print %r : vector<4xf32>217 return218}219 220func.func @erf() {221 // CHECK: -0.000274406222 %val1 = arith.constant -2.431864e-4 : f32223 call @erf_f32(%val1) : (f32) -> ()224 225 // CHECK: 0.742095226 %val2 = arith.constant 0.79999 : f32227 call @erf_f32(%val2) : (f32) -> ()228 229 // CHECK: 0.742101230 %val3 = arith.constant 0.8 : f32231 call @erf_f32(%val3) : (f32) -> ()232 233 // CHECK: 0.995322234 %val4 = arith.constant 1.99999 : f32235 call @erf_f32(%val4) : (f32) -> ()236 237 // CHECK: 0.995322238 %val5 = arith.constant 2.0 : f32239 call @erf_f32(%val5) : (f32) -> ()240 241 // CHECK: 1242 %val6 = arith.constant 3.74999 : f32243 call @erf_f32(%val6) : (f32) -> ()244 245 // CHECK: 1246 %val7 = arith.constant 3.75 : f32247 call @erf_f32(%val7) : (f32) -> ()248 249 // CHECK: -1250 %negativeInf = arith.constant 0xff800000 : f32251 call @erf_f32(%negativeInf) : (f32) -> ()252 253 // CHECK: -1, -1, -0.913759, -0.731446254 %vecVals1 = arith.constant dense<[-3.4028235e+38, -4.54318, -1.2130899, -7.8234202e-01]> : vector<4xf32>255 call @erf_4xf32(%vecVals1) : (vector<4xf32>) -> ()256 257 // CHECK: -1.3264e-38, 0, 1.3264e-38, 0.121319258 %vecVals2 = arith.constant dense<[-1.1754944e-38, 0.0, 1.1754944e-38, 1.0793410e-01]> : vector<4xf32>259 call @erf_4xf32(%vecVals2) : (vector<4xf32>) -> ()260 261 // CHECK: 0.919477, 0.999069, 1, 1262 %vecVals3 = arith.constant dense<[1.23578, 2.34093, 3.82342, 3.4028235e+38]> : vector<4xf32>263 call @erf_4xf32(%vecVals3) : (vector<4xf32>) -> ()264 265 // CHECK: 1266 %inf = arith.constant 0x7f800000 : f32267 call @erf_f32(%inf) : (f32) -> ()268 269 // CHECK: nan270 %nan = arith.constant 0x7fc00000 : f32271 call @erf_f32(%nan) : (f32) -> ()272 273 return274}275 276// -------------------------------------------------------------------------- //277// Erfc.278// -------------------------------------------------------------------------- //279func.func @erfc_f32(%a : f32) {280 %r = math.erfc %a : f32281 vector.print %r : f32282 return283}284 285func.func @erfc_4xf32(%a : vector<4xf32>) {286 %r = math.erfc %a : vector<4xf32>287 vector.print %r : vector<4xf32>288 return289}290 291func.func @erfc() {292 // CHECK: 1.00027293 %val1 = arith.constant -2.431864e-4 : f32294 call @erfc_f32(%val1) : (f32) -> ()295 296 // CHECK: 0.257905297 %val2 = arith.constant 0.79999 : f32298 call @erfc_f32(%val2) : (f32) -> ()299 300 // CHECK: 0.257899301 %val3 = arith.constant 0.8 : f32302 call @erfc_f32(%val3) : (f32) -> ()303 304 // CHECK: 0.00467794305 %val4 = arith.constant 1.99999 : f32306 call @erfc_f32(%val4) : (f32) -> ()307 308 // CHECK: 0.00467774309 %val5 = arith.constant 2.0 : f32310 call @erfc_f32(%val5) : (f32) -> ()311 312 // CHECK: 1.13736e-07313 %val6 = arith.constant 3.74999 : f32314 call @erfc_f32(%val6) : (f32) -> ()315 316 // CHECK: 1.13727e-07317 %val7 = arith.constant 3.75 : f32318 call @erfc_f32(%val7) : (f32) -> ()319 320 // CHECK: 2321 %negativeInf = arith.constant 0xff800000 : f32322 call @erfc_f32(%negativeInf) : (f32) -> ()323 324 // CHECK: 2, 2, 1.91376, 1.73145325 %vecVals1 = arith.constant dense<[-3.4028235e+38, -4.54318, -1.2130899, -7.8234202e-01]> : vector<4xf32>326 call @erfc_4xf32(%vecVals1) : (vector<4xf32>) -> ()327 328 // CHECK: 1, 1, 1, 0.878681329 %vecVals2 = arith.constant dense<[-1.1754944e-38, 0.0, 1.1754944e-38, 1.0793410e-01]> : vector<4xf32>330 call @erfc_4xf32(%vecVals2) : (vector<4xf32>) -> ()331 332 // CHECK: 0.0805235, 0.000931045, 6.40418e-08, 0333 %vecVals3 = arith.constant dense<[1.23578, 2.34093, 3.82342, 3.4028235e+38]> : vector<4xf32>334 call @erfc_4xf32(%vecVals3) : (vector<4xf32>) -> ()335 336 // CHECK: 0337 %inf = arith.constant 0x7f800000 : f32338 call @erfc_f32(%inf) : (f32) -> ()339 340 // CHECK: nan341 %nan = arith.constant 0x7fc00000 : f32342 call @erfc_f32(%nan) : (f32) -> ()343 344 return345}346 347// -------------------------------------------------------------------------- //348// Exp.349// -------------------------------------------------------------------------- //350func.func @exp_f32(%a : f32) {351 %r = math.exp %a : f32352 vector.print %r : f32353 return354}355 356func.func @exp_4xf32(%a : vector<4xf32>) {357 %r = math.exp %a : vector<4xf32>358 vector.print %r : vector<4xf32>359 return360}361 362func.func @exp() {363 // CHECK: 2.71828364 %f0 = arith.constant 1.0 : f32365 call @exp_f32(%f0) : (f32) -> ()366 367 // CHECK: 0.778801, 2.117, 2.71828, 3.85743368 %v1 = arith.constant dense<[-0.25, 0.75, 1.0, 1.35]> : vector<4xf32>369 call @exp_4xf32(%v1) : (vector<4xf32>) -> ()370 371 // CHECK: 1372 %zero = arith.constant 0.0 : f32373 call @exp_f32(%zero) : (f32) -> ()374 375 // CHECK: 0, 1.38879e-11, 7.20049e+10, inf376 %special_vec = arith.constant dense<[-89.0, -25.0, 25.0, 89.0]> : vector<4xf32>377 call @exp_4xf32(%special_vec) : (vector<4xf32>) -> ()378 379 // CHECK: inf380 %inf = arith.constant 0x7f800000 : f32381 call @exp_f32(%inf) : (f32) -> ()382 383 // CHECK: 0384 %negative_inf = arith.constant 0xff800000 : f32385 call @exp_f32(%negative_inf) : (f32) -> ()386 387 // CHECK: nan388 %nan = arith.constant 0x7fc00000 : f32389 call @exp_f32(%nan) : (f32) -> ()390 391 return392}393 394func.func @expm1_f32(%a : f32) {395 %r = math.expm1 %a : f32396 vector.print %r : f32397 return398}399 400func.func @expm1_3xf32(%a : vector<3xf32>) {401 %r = math.expm1 %a : vector<3xf32>402 vector.print %r : vector<3xf32>403 return404}405 406func.func @expm1_4xf32(%a : vector<4xf32>) {407 %r = math.expm1 %a : vector<4xf32>408 vector.print %r : vector<4xf32>409 return410}411 412func.func @expm1_8xf32(%a : vector<8xf32>) {413 %r = math.expm1 %a : vector<8xf32>414 vector.print %r : vector<8xf32>415 return416}417 418func.func @expm1() {419 // CHECK: 1e-10420 %f0 = arith.constant 1.0e-10 : f32421 call @expm1_f32(%f0) : (f32) -> ()422 423 // CHECK: -0.00995017, 0.0100502, 0.648721, 6.38906424 %v1 = arith.constant dense<[-0.01, 0.01, 0.5, 2.0]> : vector<4xf32>425 call @expm1_4xf32(%v1) : (vector<4xf32>) -> ()426 427 // CHECK: -0.181269, 0, 0.221403, 0.491825, 0.822119, 1.22554, 1.71828, 2.32012428 %v2 = arith.constant dense<[-0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2]> : vector<8xf32>429 call @expm1_8xf32(%v2) : (vector<8xf32>) -> ()430 431 // CHECK: -1432 %neg_inf = arith.constant 0xff800000 : f32433 call @expm1_f32(%neg_inf) : (f32) -> ()434 435 // CHECK: inf436 %inf = arith.constant 0x7f800000 : f32437 call @expm1_f32(%inf) : (f32) -> ()438 439 // CHECK: -1, inf, 1e-10440 %special_vec = arith.constant dense<[0xff800000, 0x7f800000, 1.0e-10]> : vector<3xf32>441 call @expm1_3xf32(%special_vec) : (vector<3xf32>) -> ()442 443 // CHECK: nan444 %nan = arith.constant 0x7fc00000 : f32445 call @expm1_f32(%nan) : (f32) -> ()446 447 return448}449// -------------------------------------------------------------------------- //450// Sin.451// -------------------------------------------------------------------------- //452func.func @sin_f32(%a : f32) {453 %r = math.sin %a : f32454 vector.print %r : f32455 return456}457 458func.func @sin_3xf32(%a : vector<3xf32>) {459 %r = math.sin %a : vector<3xf32>460 vector.print %r : vector<3xf32>461 return462}463 464func.func @sin() {465 // CHECK: 0466 %zero = arith.constant 0.0 : f32467 call @sin_f32(%zero) : (f32) -> ()468 469 // CHECK: 0.707107470 %pi_over_4 = arith.constant 0.78539816339 : f32471 call @sin_f32(%pi_over_4) : (f32) -> ()472 473 // CHECK: 1474 %pi_over_2 = arith.constant 1.57079632679 : f32475 call @sin_f32(%pi_over_2) : (f32) -> ()476 477 // CHECK: 0478 %pi = arith.constant 3.14159265359 : f32479 call @sin_f32(%pi) : (f32) -> ()480 481 // CHECK: -1482 %pi_3_over_2 = arith.constant 4.71238898038 : f32483 call @sin_f32(%pi_3_over_2) : (f32) -> ()484 485 // CHECK: 0, 0.866025, -1486 %vec_x = arith.constant dense<[9.42477796077, 2.09439510239, -1.57079632679]> : vector<3xf32>487 call @sin_3xf32(%vec_x) : (vector<3xf32>) -> ()488 489 return490}491 492// -------------------------------------------------------------------------- //493// cos.494// -------------------------------------------------------------------------- //495func.func @cos_f32(%a : f32) {496 %r = math.cos %a : f32497 vector.print %r : f32498 return499}500 501func.func @cos_3xf32(%a : vector<3xf32>) {502 %r = math.cos %a : vector<3xf32>503 vector.print %r : vector<3xf32>504 return505}506 507func.func @cos() {508 // CHECK: 1509 %zero = arith.constant 0.0 : f32510 call @cos_f32(%zero) : (f32) -> ()511 512 // CHECK: 0.707107513 %pi_over_4 = arith.constant 0.78539816339 : f32514 call @cos_f32(%pi_over_4) : (f32) -> ()515 516 // CHECK: 0517 %pi_over_2 = arith.constant 1.57079632679 : f32518 call @cos_f32(%pi_over_2) : (f32) -> ()519 520 // CHECK: -1521 %pi = arith.constant 3.14159265359 : f32522 call @cos_f32(%pi) : (f32) -> ()523 524 // CHECK: 0525 %pi_3_over_2 = arith.constant 4.71238898038 : f32526 call @cos_f32(%pi_3_over_2) : (f32) -> ()527 528 // CHECK: -1, -0.5, 0529 %vec_x = arith.constant dense<[9.42477796077, 2.09439510239, -1.57079632679]> : vector<3xf32>530 call @cos_3xf32(%vec_x) : (vector<3xf32>) -> ()531 532 return533}534 535// -------------------------------------------------------------------------- //536// Asin.537// -------------------------------------------------------------------------- //538func.func @asin_f32(%a : f32) {539 %r = math.asin %a : f32540 vector.print %r : f32541 return542}543 544func.func @asin_3xf32(%a : vector<3xf32>) {545 %r = math.asin %a : vector<3xf32>546 vector.print %r : vector<3xf32>547 return548}549 550func.func @asin() {551 // CHECK: 0552 %zero = arith.constant 0.0 : f32553 call @asin_f32(%zero) : (f32) -> ()554 555 // CHECK: -0.597406556 %cst1 = arith.constant -0.5625 : f32557 call @asin_f32(%cst1) : (f32) -> ()558 559 // CHECK: -0.384397560 %cst2 = arith.constant -0.375 : f32561 call @asin_f32(%cst2) : (f32) -> ()562 563 // CHECK: -0.25268564 %cst3 = arith.constant -0.25 : f32565 call @asin_f32(%cst3) : (f32) -> ()566 567 // CHECK: -1.1197568 %cst4 = arith.constant -0.90 : f32569 call @asin_f32(%cst4) : (f32) -> ()570 571 // CHECK: 0.25268, 0.384397, 0.597406572 %vec_x = arith.constant dense<[0.25, 0.375, 0.5625]> : vector<3xf32>573 call @asin_3xf32(%vec_x) : (vector<3xf32>) -> ()574 575 return576}577 578// -------------------------------------------------------------------------- //579// Acos.580// -------------------------------------------------------------------------- //581func.func @acos_f32(%a : f32) {582 %r = math.acos %a : f32583 vector.print %r : f32584 return585}586 587func.func @acos_3xf32(%a : vector<3xf32>) {588 %r = math.acos %a : vector<3xf32>589 vector.print %r : vector<3xf32>590 return591}592 593func.func @acos() {594 // CHECK: 1.5708595 %zero = arith.constant 0.0 : f32596 call @acos_f32(%zero) : (f32) -> ()597 598 // CHECK: 2.1682599 %cst1 = arith.constant -0.5625 : f32600 call @acos_f32(%cst1) : (f32) -> ()601 602 // CHECK: 1.95519603 %cst2 = arith.constant -0.375 : f32604 call @acos_f32(%cst2) : (f32) -> ()605 606 // CHECK: 1.82348607 %cst3 = arith.constant -0.25 : f32608 call @acos_f32(%cst3) : (f32) -> ()609 610 // CHECK: 1.31812, 1.1864, 0.97339611 %vec_x = arith.constant dense<[0.25, 0.375, 0.5625]> : vector<3xf32>612 call @acos_3xf32(%vec_x) : (vector<3xf32>) -> ()613 614 return615}616 617// -------------------------------------------------------------------------- //618// Atan.619// -------------------------------------------------------------------------- //620func.func @atan_f32(%a : f32) {621 %r = math.atan %a : f32622 vector.print %r : f32623 return624}625 626func.func @atan() {627 // CHECK: -0.785398628 %0 = arith.constant -1.0 : f32629 call @atan_f32(%0) : (f32) -> ()630 631 // CHECK: 0.785398632 %1 = arith.constant 1.0 : f32633 call @atan_f32(%1) : (f32) -> ()634 635 // CHECK: -0.463648636 %2 = arith.constant -0.5 : f32637 call @atan_f32(%2) : (f32) -> ()638 639 // CHECK: 0.463648640 %3 = arith.constant 0.5 : f32641 call @atan_f32(%3) : (f32) -> ()642 643 // CHECK: 0644 %4 = arith.constant 0.0 : f32645 call @atan_f32(%4) : (f32) -> ()646 647 // CHECK: -1.10715648 %5 = arith.constant -2.0 : f32649 call @atan_f32(%5) : (f32) -> ()650 651 // CHECK: 1.10715652 %6 = arith.constant 2.0 : f32653 call @atan_f32(%6) : (f32) -> ()654 655 return656}657 658 659// -------------------------------------------------------------------------- //660// Atan2.661// -------------------------------------------------------------------------- //662func.func @atan2_f32(%a : f32, %b : f32) {663 %r = math.atan2 %a, %b : f32664 vector.print %r : f32665 return666}667 668func.func @atan2() {669 %zero = arith.constant 0.0 : f32670 %one = arith.constant 1.0 : f32671 %two = arith.constant 2.0 : f32672 %neg_one = arith.constant -1.0 : f32673 %neg_two = arith.constant -2.0 : f32674 675 // CHECK: 0676 call @atan2_f32(%zero, %one) : (f32, f32) -> ()677 678 // CHECK: 1.5708679 call @atan2_f32(%one, %zero) : (f32, f32) -> ()680 681 // CHECK: 3.14159682 call @atan2_f32(%zero, %neg_one) : (f32, f32) -> ()683 684 // CHECK: -1.5708685 call @atan2_f32(%neg_one, %zero) : (f32, f32) -> ()686 687 // CHECK: nan688 call @atan2_f32(%zero, %zero) : (f32, f32) -> ()689 690 // CHECK: 1.10715691 call @atan2_f32(%two, %one) : (f32, f32) -> ()692 693 // CHECK: 2.03444694 %x6 = arith.constant -1.0 : f32695 %y6 = arith.constant 2.0 : f32696 call @atan2_f32(%two, %neg_one) : (f32, f32) -> ()697 698 // CHECK: -2.03444699 call @atan2_f32(%neg_two, %neg_one) : (f32, f32) -> ()700 701 // CHECK: -1.10715702 call @atan2_f32(%neg_two, %one) : (f32, f32) -> ()703 704 // CHECK: 0.463648705 call @atan2_f32(%one, %two) : (f32, f32) -> ()706 707 // CHECK: 2.67795708 %x10 = arith.constant -2.0 : f32709 %y10 = arith.constant 1.0 : f32710 call @atan2_f32(%one, %neg_two) : (f32, f32) -> ()711 712 // CHECK: -2.67795713 %x11 = arith.constant -2.0 : f32714 %y11 = arith.constant -1.0 : f32715 call @atan2_f32(%neg_one, %neg_two) : (f32, f32) -> ()716 717 // CHECK: -0.463648718 call @atan2_f32(%neg_one, %two) : (f32, f32) -> ()719 720 return721}722 723 724// -------------------------------------------------------------------------- //725// Cbrt.726// -------------------------------------------------------------------------- //727 728func.func @cbrt_f32(%a : f32) {729 %r = math.cbrt %a : f32730 vector.print %r : f32731 return732}733 734func.func @cbrt() {735 // CHECK: 1736 %a = arith.constant 1.0 : f32737 call @cbrt_f32(%a) : (f32) -> ()738 739 // CHECK: -1740 %b = arith.constant -1.0 : f32741 call @cbrt_f32(%b) : (f32) -> ()742 743 // CHECK: 0744 %c = arith.constant 0.0 : f32745 call @cbrt_f32(%c) : (f32) -> ()746 747 // CHECK: -0748 %d = arith.constant -0.0 : f32749 call @cbrt_f32(%d) : (f32) -> ()750 751 // CHECK: 10752 %e = arith.constant 1000.0 : f32753 call @cbrt_f32(%e) : (f32) -> ()754 755 // CHECK: -10756 %f = arith.constant -1000.0 : f32757 call @cbrt_f32(%f) : (f32) -> ()758 759 // CHECK: 2.57128760 %g = arith.constant 17.0 : f32761 call @cbrt_f32(%g) : (f32) -> ()762 763 return764}765 766// -------------------------------------------------------------------------- //767// floor.768// -------------------------------------------------------------------------- //769func.func @func_floorf32(%a : f32) {770 %r = math.floor %a : f32771 vector.print %r : f32772 return773}774 775func.func @floorf() {776 // CHECK: 3777 %a = arith.constant 3.8 : f32778 call @func_floorf32(%a) : (f32) -> ()779 780 // CHECK: -4781 %b = arith.constant -3.8 : f32782 call @func_floorf32(%b) : (f32) -> ()783 784 // CHECK: 0785 %c = arith.constant 0.0 : f32786 call @func_floorf32(%c) : (f32) -> ()787 788 // CHECK: -5789 %d = arith.constant -4.2 : f32790 call @func_floorf32(%d) : (f32) -> ()791 792 // CHECK: -2793 %e = arith.constant -2.0 : f32794 call @func_floorf32(%e) : (f32) -> ()795 796 // CHECK: 2797 %f = arith.constant 2.0 : f32798 call @func_floorf32(%f) : (f32) -> ()799 800 return801}802 803// -------------------------------------------------------------------------- //804// ceil.805// -------------------------------------------------------------------------- //806func.func @func_ceilf32(%a : f32) {807 %r = math.ceil %a : f32808 vector.print %r : f32809 return810}811 812func.func @ceilf() {813 // CHECK: 4814 %a = arith.constant 3.8 : f32815 call @func_ceilf32(%a) : (f32) -> ()816 817 // CHECK: -3818 %b = arith.constant -3.8 : f32819 call @func_ceilf32(%b) : (f32) -> ()820 821 // CHECK: 0822 %c = arith.constant 0.0 : f32823 call @func_ceilf32(%c) : (f32) -> ()824 825 // CHECK: -4826 %d = arith.constant -4.2 : f32827 call @func_ceilf32(%d) : (f32) -> ()828 829 // CHECK: -495830 %e = arith.constant -495.0 : f32831 call @func_ceilf32(%e) : (f32) -> ()832 833 // CHECK: 495834 %f = arith.constant 495.0 : f32835 call @func_ceilf32(%f) : (f32) -> ()836 837 return838}839 840func.func @main() {841 call @tanh(): () -> ()842 call @log(): () -> ()843 call @log2(): () -> ()844 call @log1p(): () -> ()845 call @erf(): () -> ()846 call @erfc(): () -> ()847 call @exp(): () -> ()848 call @expm1(): () -> ()849 call @sin(): () -> ()850 call @cos(): () -> ()851 call @asin(): () -> ()852 call @acos(): () -> ()853 call @atan() : () -> ()854 call @atan2() : () -> ()855 call @cbrt() : () -> ()856 call @floorf() : () -> ()857 call @ceilf() : () -> ()858 return859}860