Fix dbl-64 atan2 in non-default rounding modes (bug 18210, bug 18211).
[glibc.git] / sysdeps / i386 / fpu / e_exp2l.S
blob2bf9a25727c5991879ac66999272eed75bb52c2a
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Adapted for exp2 by Ulrich Drepper <drepper@cygnus.com>.
4  * Public domain.
5  */
7 #include <machine/asm.h>
9 ENTRY(__ieee754_exp2l)
10         fldt    4(%esp)
11 /* I added the following ugly construct because exp(+-Inf) resulted
12    in NaN.  The ugliness results from the bright minds at Intel.
13    For the i686 the code can be written better.
14    -- drepper@cygnus.com.  */
15         fxam                            /* Is NaN or +-Inf?  */
16         fstsw   %ax
17         movb    $0x45, %dh
18         andb    %ah, %dh
19         cmpb    $0x05, %dh
20         je      1f                      /* Is +-Inf, jump.  */
21         movzwl  4+8(%esp), %eax
22         andl    $0x7fff, %eax
23         cmpl    $0x3fbe, %eax
24         jge     3f
25         /* Argument's exponent below -65, result rounds to 1.  */
26         fld1
27         faddp
28         ret
29 3:      fld     %st
30         frndint                         /* int(x) */
31         fsubr   %st,%st(1)              /* fract(x) */
32         fxch
33         f2xm1                           /* 2^(fract(x)) - 1 */
34         fld1
35         faddp                           /* 2^(fract(x)) */
36         fscale                          /* e^x */
37         fstp    %st(1)
38         ret
40 1:      testl   $0x200, %eax            /* Test sign.  */
41         jz      2f                      /* If positive, jump.  */
42         fstp    %st
43         fldz                            /* Set result to 0.  */
44 2:      ret
45 END (__ieee754_exp2l)
46 strong_alias (__ieee754_exp2l, __exp2l_finite)