e_log10.S revision 5d4f0e6a26b66f1dab8d20a65af4469c6dd7370d
1/* 2Copyright (c) 2014, Intel Corporation 3All rights reserved. 4 5Redistribution and use in source and binary forms, with or without 6modification, are permitted provided that the following conditions are met: 7 8 * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 11 * Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 15 * Neither the name of Intel Corporation nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*/ 30 31/******************************************************************************/ 32// ALGORITHM DESCRIPTION 33// --------------------- 34// 35// Let x=2^k * mx, mx in [1,2) 36// 37// Get B~1/mx based on the output of rcpss instruction (B0) 38// B = int((B0*LH*2^7+0.5))/2^7 39// LH is a short approximation for log10(e) 40// 41// Reduced argument: r=B*mx-LH (computed accurately in high and low parts) 42// 43// Result: k*log10(2) - log(B) + p(r) 44// p(r) is a degree 7 polynomial 45// -log(B) read from data table (high, low parts) 46// Result is formed from high and low parts 47// 48// Special cases: 49// log10(0) = -INF with divide-by-zero exception raised 50// log10(1) = +0 51// log10(x) = NaN with invalid exception raised if x < -0, including -INF 52// log10(+INF) = +INF 53// 54/******************************************************************************/ 55 56#include <private/bionic_asm.h> 57# -- Begin static_func 58 .text 59 .align __bionic_asm_align 60 .type static_func, @function 61static_func: 62..B1.1: 63 call ..L2 64..L2: 65 popl %eax 66 lea _GLOBAL_OFFSET_TABLE_+[. - ..L2](%eax), %eax 67 lea static_const_table@GOTOFF(%eax), %eax 68 ret 69 .size static_func,.-static_func 70# -- End static_func 71 72# -- Begin log10 73ENTRY(log10) 74# parameter 1: 8 + %ebp 75..B2.1: 76..B2.2: 77 pushl %ebp 78 movl %esp, %ebp 79 subl $104, %esp 80 movl %ebx, 40(%esp) 81 call static_func 82 movl %eax, %ebx 83 xorpd %xmm2, %xmm2 84 movl $16368, %eax 85 pinsrw $3, %eax, %xmm2 86 movl $1054736384, %ecx 87 movd %ecx, %xmm7 88 xorpd %xmm3, %xmm3 89 movl $30704, %edx 90 pinsrw $3, %edx, %xmm3 91 movsd 112(%esp), %xmm0 92 movapd %xmm0, %xmm1 93 movl $32768, %edx 94 movd %edx, %xmm4 95 movapd 2128(%ebx), %xmm5 96 pextrw $3, %xmm0, %eax 97 orpd %xmm2, %xmm0 98 movl $16352, %ecx 99 psllq $5, %xmm0 100 movsd 2144(%ebx), %xmm2 101 psrlq $34, %xmm0 102 rcpss %xmm0, %xmm0 103 psllq $12, %xmm1 104 pshufd $78, %xmm5, %xmm6 105 psrlq $12, %xmm1 106 subl $16, %eax 107 cmpl $32736, %eax 108 jae .L_2TAG_PACKET_0.0.2 109.L_2TAG_PACKET_1.0.2: 110 mulss %xmm7, %xmm0 111 orpd %xmm3, %xmm1 112 andpd %xmm1, %xmm5 113 paddd %xmm4, %xmm0 114 subsd %xmm5, %xmm1 115 movd %xmm0, %edx 116 psllq $29, %xmm0 117 andpd %xmm6, %xmm0 118 andl $32752, %eax 119 subl %ecx, %eax 120 cvtsi2sdl %eax, %xmm7 121 mulpd %xmm0, %xmm5 122 mulsd %xmm0, %xmm1 123 movsd 2064(%ebx), %xmm6 124 movapd 2080(%ebx), %xmm3 125 subsd %xmm2, %xmm5 126 andl $16711680, %edx 127 shrl $12, %edx 128 movapd -1504(%ebx,%edx), %xmm0 129 movapd 2096(%ebx), %xmm4 130 addsd %xmm5, %xmm1 131 movapd 2112(%ebx), %xmm2 132 mulsd %xmm7, %xmm6 133 pshufd $68, %xmm1, %xmm5 134 mulsd 2072(%ebx), %xmm7 135 mulsd %xmm1, %xmm3 136 addsd %xmm6, %xmm0 137 mulpd %xmm5, %xmm4 138 movsd 2152(%ebx), %xmm6 139 mulpd %xmm5, %xmm5 140 addpd %xmm2, %xmm4 141 mulpd %xmm5, %xmm3 142 pshufd $228, %xmm0, %xmm2 143 addsd %xmm1, %xmm0 144 mulsd %xmm1, %xmm4 145 subsd %xmm0, %xmm2 146 mulsd %xmm1, %xmm6 147 addsd %xmm2, %xmm1 148 pshufd $238, %xmm0, %xmm2 149 mulsd %xmm5, %xmm5 150 addsd %xmm2, %xmm7 151 addsd %xmm6, %xmm1 152 addpd %xmm3, %xmm4 153 addsd %xmm7, %xmm1 154 mulpd %xmm5, %xmm4 155 addsd %xmm4, %xmm1 156 pshufd $238, %xmm4, %xmm5 157 addsd %xmm5, %xmm1 158 addsd %xmm1, %xmm0 159 jmp .L_2TAG_PACKET_2.0.2 160.L_2TAG_PACKET_0.0.2: 161 movsd 112(%esp), %xmm0 162 movapd %xmm0, %xmm1 163 addl $16, %eax 164 cmpl $32768, %eax 165 jae .L_2TAG_PACKET_3.0.2 166 cmpl $16, %eax 167 jb .L_2TAG_PACKET_4.0.2 168.L_2TAG_PACKET_5.0.2: 169 addsd %xmm0, %xmm0 170 jmp .L_2TAG_PACKET_2.0.2 171.L_2TAG_PACKET_6.0.2: 172 ja .L_2TAG_PACKET_5.0.2 173 cmpl $0, %edx 174 ja .L_2TAG_PACKET_5.0.2 175 jmp .L_2TAG_PACKET_7.0.2 176.L_2TAG_PACKET_3.0.2: 177 movd %xmm1, %edx 178 psrlq $32, %xmm1 179 movd %xmm1, %ecx 180 addl %ecx, %ecx 181 cmpl $-2097152, %ecx 182 jae .L_2TAG_PACKET_6.0.2 183 orl %ecx, %edx 184 cmpl $0, %edx 185 je .L_2TAG_PACKET_8.0.2 186.L_2TAG_PACKET_7.0.2: 187 xorpd %xmm1, %xmm1 188 xorpd %xmm0, %xmm0 189 movl $32752, %eax 190 pinsrw $3, %eax, %xmm1 191 movl $9, %edx 192 mulsd %xmm1, %xmm0 193.L_2TAG_PACKET_9.0.2: 194 movsd %xmm0, (%esp) 195 movsd 112(%esp), %xmm0 196 fldl (%esp) 197 jmp .L_2TAG_PACKET_10.0.2 198.L_2TAG_PACKET_8.0.2: 199 xorpd %xmm1, %xmm1 200 xorpd %xmm0, %xmm0 201 movl $49136, %eax 202 pinsrw $3, %eax, %xmm0 203 divsd %xmm1, %xmm0 204 movl $8, %edx 205 jmp .L_2TAG_PACKET_9.0.2 206.L_2TAG_PACKET_4.0.2: 207 movd %xmm1, %edx 208 psrlq $32, %xmm1 209 movd %xmm1, %ecx 210 orl %ecx, %edx 211 cmpl $0, %edx 212 je .L_2TAG_PACKET_8.0.2 213 xorpd %xmm1, %xmm1 214 movl $18416, %eax 215 pinsrw $3, %eax, %xmm1 216 mulsd %xmm1, %xmm0 217 xorpd %xmm2, %xmm2 218 movl $16368, %eax 219 pinsrw $3, %eax, %xmm2 220 movapd %xmm0, %xmm1 221 pextrw $3, %xmm0, %eax 222 orpd %xmm2, %xmm0 223 movl $18416, %ecx 224 psllq $5, %xmm0 225 movsd 2144(%ebx), %xmm2 226 psrlq $34, %xmm0 227 rcpss %xmm0, %xmm0 228 psllq $12, %xmm1 229 pshufd $78, %xmm5, %xmm6 230 psrlq $12, %xmm1 231 jmp .L_2TAG_PACKET_1.0.2 232.L_2TAG_PACKET_2.0.2: 233 movsd %xmm0, 24(%esp) 234 fldl 24(%esp) 235.L_2TAG_PACKET_10.0.2: 236 movl 40(%esp), %ebx 237 movl %ebp, %esp 238 popl %ebp 239 ret 240..B2.3: 241END(log10) 242# -- End log10 243 244# Start file scope ASM 245.weak log10l 246.equ log10l, log10 247# End file scope ASM 248 .section .rodata, "a" 249 .align 16 250 .align 16 251static_const_table: 252 .long 1352628224 253 .long 1070810131 254 .long 521319256 255 .long 1025503025 256 .long 2150839296 257 .long 1070801944 258 .long 3329350096 259 .long 3170190015 260 .long 1360613376 261 .long 1070793794 262 .long 2024059075 263 .long 1024991594 264 .long 1875350528 265 .long 1070785680 266 .long 2163882141 267 .long 3163564137 268 .long 2312126464 269 .long 1070777602 270 .long 1975711076 271 .long 1023674196 272 .long 1306336256 273 .long 1070769560 274 .long 3524899523 275 .long 3170508164 276 .long 1806334976 277 .long 1070761553 278 .long 4254777025 279 .long 1025238739 280 .long 2483193856 281 .long 1070753581 282 .long 3800671317 283 .long 3172916830 284 .long 2025350144 285 .long 1070745644 286 .long 1731514745 287 .long 1025501083 288 .long 3433285632 289 .long 1070737741 290 .long 2551857336 291 .long 3169662186 292 .long 1134317568 293 .long 1070729873 294 .long 3426297655 295 .long 3172637891 296 .long 2457152512 297 .long 1070722038 298 .long 63549415 299 .long 1025415416 300 .long 1861803008 301 .long 1070714237 302 .long 1910171636 303 .long 1023977580 304 .long 2414140416 305 .long 1070706469 306 .long 4002514337 307 .long 3170841618 308 .long 2900726784 309 .long 1070698734 310 .long 3268064083 311 .long 1022459609 312 .long 2123517952 313 .long 1070691032 314 .long 1767031218 315 .long 1022448156 316 .long 3194569728 317 .long 1070683362 318 .long 3402332618 319 .long 3171671160 320 .long 650882048 321 .long 1070675725 322 .long 4146023905 323 .long 3171023038 324 .long 1928988672 325 .long 1070668119 326 .long 1438617867 327 .long 1016360491 328 .long 1594908672 329 .long 1070660545 330 .long 971389377 331 .long 1024763979 332 .long 2818746368 333 .long 1070653002 334 .long 3555925341 335 .long 3172434821 336 .long 194584576 337 .long 1070645491 338 .long 943919215 339 .long 3172950063 340 .long 1215096832 341 .long 1070638010 342 .long 2283358588 343 .long 1022335098 344 .long 501519360 345 .long 1070630560 346 .long 480904295 347 .long 1024437959 348 .long 1278266368 349 .long 1070623140 350 .long 2755806066 351 .long 3172342012 352 .long 2487812096 353 .long 1070615750 354 .long 2489653202 355 .long 3172481099 356 .long 3085451264 357 .long 1070608390 358 .long 3759184951 359 .long 3172574892 360 .long 2039090176 361 .long 1070601060 362 .long 1361176676 363 .long 3172355319 364 .long 953057280 365 .long 1070591423 366 .long 1176587546 367 .long 3166422018 368 .long 3370524672 369 .long 1070576879 370 .long 3669570051 371 .long 1025376630 372 .long 749742080 373 .long 1070562394 374 .long 707700964 375 .long 3170814058 376 .long 4008353792 377 .long 1070547965 378 .long 3247327652 379 .long 1022431400 380 .long 2612455424 381 .long 1070533594 382 .long 2453457344 383 .long 3172322969 384 .long 3230920704 385 .long 1070519279 386 .long 1296781801 387 .long 1025115335 388 .long 3965253632 389 .long 1070505020 390 .long 373075289 391 .long 1017938528 392 .long 2593157120 393 .long 1070476669 394 .long 1068054086 395 .long 1021616576 396 .long 925962240 397 .long 1070448537 398 .long 850121213 399 .long 1023928989 400 .long 1732556800 401 .long 1070420620 402 .long 1305206740 403 .long 3172665570 404 .long 3815630848 405 .long 1070392915 406 .long 192642943 407 .long 3172699907 408 .long 2001758208 409 .long 1070365420 410 .long 2820786683 411 .long 1024704867 412 .long 16746496 413 .long 1070338131 414 .long 1399573110 415 .long 3171372773 416 .long 1886492672 417 .long 1070311044 418 .long 3621428075 419 .long 3172974358 420 .long 3338196992 421 .long 1070284157 422 .long 3793882035 423 .long 1025124701 424 .long 381769728 425 .long 1070257468 426 .long 3877933342 427 .long 3170195490 428 .long 2186491904 429 .long 1070230972 430 .long 1838687089 431 .long 1017927292 432 .long 1008330752 433 .long 1070204668 434 .long 2228321664 435 .long 1025352196 436 .long 2247065600 437 .long 1070178552 438 .long 1413900906 439 .long 3170902532 440 .long 2964070400 441 .long 1070152622 442 .long 3590454629 443 .long 1025016844 444 .long 465154048 445 .long 1070126876 446 .long 2079688550 447 .long 3172268183 448 .long 883615744 449 .long 1070101310 450 .long 989244452 451 .long 3171900485 452 .long 1993768960 453 .long 1070075922 454 .long 1124327841 455 .long 3172964992 456 .long 1794471936 457 .long 1070050710 458 .long 1140575046 459 .long 1022673726 460 .long 2797932544 461 .long 1070025671 462 .long 1894836933 463 .long 3172544059 464 .long 3433797632 465 .long 1070000803 466 .long 3221831166 467 .long 3171921685 468 .long 2338371584 469 .long 1069976104 470 .long 3732461053 471 .long 3164513518 472 .long 2644013056 473 .long 1069951571 474 .long 2519460462 475 .long 3172548740 476 .long 3383814144 477 .long 1069927202 478 .long 2290997657 479 .long 1025499649 480 .long 3781380096 481 .long 1069902995 482 .long 380479405 483 .long 1025184136 484 .long 3245785088 485 .long 1069878948 486 .long 1096398261 487 .long 3169885192 488 .long 1366712320 489 .long 1069855059 490 .long 2218343715 491 .long 3170281628 492 .long 2204717056 493 .long 1069831325 494 .long 2668334011 495 .long 1025264524 496 .long 1401772032 497 .long 1069807745 498 .long 4103993159 499 .long 1022925721 500 .long 3356721152 501 .long 1069784316 502 .long 3573790772 503 .long 3172186527 504 .long 4041148416 505 .long 1069761037 506 .long 4027691910 507 .long 3171276990 508 .long 3880151040 509 .long 1069737906 510 .long 4087118786 511 .long 3172710734 512 .long 3453364224 513 .long 1069714921 514 .long 99014299 515 .long 3172003077 516 .long 3491092480 517 .long 1069692080 518 .long 3801836701 519 .long 3172989287 520 .long 575580160 521 .long 1069669382 522 .long 1920406012 523 .long 3170874125 524 .long 22282240 525 .long 1069646824 526 .long 964193370 527 .long 1019363159 528 .long 2991429632 529 .long 1069624404 530 .long 3372589890 531 .long 1023425053 532 .long 2189645824 533 .long 1069602122 534 .long 2610503872 535 .long 1023652442 536 .long 3341467648 537 .long 1069579975 538 .long 1190292004 539 .long 1022425665 540 .long 3711293440 541 .long 1069557962 542 .long 1104795356 543 .long 1023625829 544 .long 1380401152 545 .long 1069524644 546 .long 1156998217 547 .long 1025100499 548 .long 765710336 549 .long 1069481144 550 .long 1736649113 551 .long 1024999439 552 .long 849412096 553 .long 1069437902 554 .long 2618178330 555 .long 3170853629 556 .long 1433104384 557 .long 1069394915 558 .long 43477267 559 .long 3170378811 560 .long 2548596736 561 .long 1069352180 562 .long 3967367063 563 .long 1025246584 564 .long 157577216 565 .long 1069309695 566 .long 100402533 567 .long 3172825502 568 .long 3326238720 569 .long 1069267455 570 .long 1176892909 571 .long 1025464099 572 .long 4155494400 573 .long 1069225459 574 .long 3713707617 575 .long 3172630046 576 .long 3545804800 577 .long 1069183704 578 .long 857007315 579 .long 1024965777 580 .long 2602520576 581 .long 1069142187 582 .long 2588758347 583 .long 1022463131 584 .long 2631196672 585 .long 1069100905 586 .long 2118424235 587 .long 1022490989 588 .long 838135808 589 .long 1069059856 590 .long 4117002727 591 .long 1024874520 592 .long 3210903552 593 .long 1069019036 594 .long 650070125 595 .long 3172012966 596 .long 3039211520 597 .long 1068978444 598 .long 438055812 599 .long 1017743757 600 .long 2385633280 601 .long 1068938077 602 .long 3011990369 603 .long 3171312044 604 .long 3491618816 605 .long 1068897932 606 .long 712813818 607 .long 3172720400 608 .long 183644160 609 .long 1068858008 610 .long 4287006742 611 .long 1022379728 612 .long 3639214080 613 .long 1068818300 614 .long 353762279 615 .long 3172980009 616 .long 3728416768 617 .long 1068778808 618 .long 1851367730 619 .long 1025486574 620 .long 3370094592 621 .long 1068739529 622 .long 4046594913 623 .long 3172567047 624 .long 1348407296 625 .long 1068700461 626 .long 143189675 627 .long 1025397632 628 .long 899403776 629 .long 1068661601 630 .long 3753687842 631 .long 3170772772 632 .long 1117708288 633 .long 1068622947 634 .long 1857340812 635 .long 3170782678 636 .long 1248276480 637 .long 1068584497 638 .long 1289858203 639 .long 1025222289 640 .long 683237376 641 .long 1068546249 642 .long 2356679608 643 .long 3171629170 644 .long 3253764096 645 .long 1068508200 646 .long 3267136556 647 .long 1018554987 648 .long 94478336 649 .long 1068441756 650 .long 1927868814 651 .long 3169378180 652 .long 3233144832 653 .long 1068366445 654 .long 2682188854 655 .long 1023964004 656 .long 2940297216 657 .long 1068291522 658 .long 275301289 659 .long 1023944679 660 .long 3677708288 661 .long 1068216982 662 .long 302658771 663 .long 1024465567 664 .long 1576968192 665 .long 1068142822 666 .long 3672035940 667 .long 3172254610 668 .long 1614069760 669 .long 1068069037 670 .long 480052905 671 .long 3172692062 672 .long 424435712 673 .long 1067995624 674 .long 2207869657 675 .long 3170965436 676 .long 3477782528 677 .long 1067922578 678 .long 2980661858 679 .long 3164990018 680 .long 3598401536 681 .long 1067849897 682 .long 1974393034 683 .long 3171357083 684 .long 2435235840 685 .long 1067777577 686 .long 1385289011 687 .long 1024615823 688 .long 1867333632 689 .long 1067705614 690 .long 3442236633 691 .long 1025334384 692 .long 3999301632 693 .long 1067634004 694 .long 3506472073 695 .long 1025132546 696 .long 2566971392 697 .long 1067562745 698 .long 1425757592 699 .long 3172358463 700 .long 112943104 701 .long 1067491833 702 .long 1693407156 703 .long 3172426603 704 .long 3079929856 705 .long 1067392159 706 .long 3999942455 707 .long 1018549369 708 .long 2443837440 709 .long 1067251701 710 .long 974534460 711 .long 1023963412 712 .long 359366656 713 .long 1067111917 714 .long 2204915018 715 .long 1013514416 716 .long 3564519424 717 .long 1066972799 718 .long 3977441659 719 .long 3170879860 720 .long 2011086848 721 .long 1066834343 722 .long 590145514 723 .long 1025390011 724 .long 3216982016 725 .long 1066696541 726 .long 3629120110 727 .long 1024330313 728 .long 2194128896 729 .long 1066559388 730 .long 2367098512 731 .long 3172260338 732 .long 2916220928 733 .long 1066422877 734 .long 2262431886 735 .long 1021229446 736 .long 2263941120 737 .long 1066172214 738 .long 3118507287 739 .long 1021484970 740 .long 3076292608 741 .long 1065901726 742 .long 1411737803 743 .long 3172957147 744 .long 1186136064 745 .long 1065632488 746 .long 3109349337 747 .long 1025397383 748 .long 3085303808 749 .long 1065364487 750 .long 584715031 751 .long 3172596519 752 .long 1821048832 753 .long 1064842211 754 .long 2182246895 755 .long 3172536214 756 .long 697368576 757 .long 1064311094 758 .long 3157561765 759 .long 3172716357 760 .long 894042112 761 .long 1063260131 762 .long 3237958154 763 .long 3172587292 764 .long 0 765 .long 0 766 .long 0 767 .long 0 768 .long 1352628224 769 .long 1066615827 770 .long 521319256 771 .long 1021308721 772 .long 3248877870 773 .long 1077250164 774 .long 1691676429 775 .long 3221787401 776 .long 945132465 777 .long 3223701783 778 .long 3700831335 779 .long 1073506818 780 .long 2141010593 781 .long 1075227551 782 .long 3698831637 783 .long 3220339442 784 .long 4160749568 785 .long 4294967295 786 .long 0 787 .long 4294959104 788 .long 0 789 .long 1071366144 790 .long 3207479560 791 .long 1062894188 792 .type static_const_table,@object 793 .size static_const_table,2160 794 .data 795 .section .note.GNU-stack, "" 796# End 797