2.9
[glibc/nacl-glibc.git] / sysdeps / x86_64 / fpu / e_exp2l.S
blob336b989098ba9fa35eb878d672beda46a6d8d382
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Adapted for exp2 by Ulrich Drepper <drepper@cygnus.com>.
4  * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
5  * Public domain.
6  */
8 #include <machine/asm.h>
10 ENTRY(__ieee754_exp2l)
11         fldt    8(%rsp)
12 /* I added the following ugly construct because exp(+-Inf) resulted
13    in NaN.  The ugliness results from the bright minds at Intel.
14    For the i686 the code can be written better.
15    -- drepper@cygnus.com.  */
16         fxam                            /* Is NaN or +-Inf?  */
17         fstsw   %ax
18         movb    $0x45, %dh
19         andb    %ah, %dh
20         cmpb    $0x05, %dh
21         je      1f                      /* Is +-Inf, jump.  */
22         fld     %st
23         frndint                         /* int(x) */
24         fsubr   %st,%st(1)              /* fract(x) */
25         fxch
26         f2xm1                           /* 2^(fract(x)) - 1 */
27         fld1
28         faddp                           /* 2^(fract(x)) */
29         fscale                          /* e^x */
30         fstp    %st(1)
31         ret
33 1:      testl   $0x200, %eax            /* Test sign.  */
34         jz      2f                      /* If positive, jump.  */
35         fstp    %st
36         fldz                            /* Set result to 0.  */
37 2:      ret
38 END (__ieee754_exp2l)