Support mcount/gprof test with GCC defaulting to PIE
[glibc.git] / sysdeps / i386 / fpu / e_exp2f.S
blob30623cd85017d5a5a70e2a6d77f4d093b05b8f5c
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>
8 #include <i386-math-asm.h>
10 DEFINE_FLT_MIN
12 #ifdef PIC
13 # define MO(op) op##@GOTOFF(%ecx)
14 #else
15 # define MO(op) op
16 #endif
18         .text
19 ENTRY(__ieee754_exp2f)
20 #ifdef  PIC
21         LOAD_PIC_REG (cx)
22 #endif
23         flds    4(%esp)
24 /* I added the following ugly construct because exp(+-Inf) resulted
25    in NaN.  The ugliness results from the bright minds at Intel.
26    For the i686 the code can be written better.
27    -- drepper@cygnus.com.  */
28         fxam                            /* Is NaN or +-Inf?  */
29         fstsw   %ax
30         movb    $0x45, %dh
31         andb    %ah, %dh
32         cmpb    $0x05, %dh
33         je      1f                      /* Is +-Inf, jump.  */
34         fld     %st
35         frndint                         /* int(x) */
36         fsubr   %st,%st(1)              /* fract(x) */
37         fxch
38         f2xm1                           /* 2^(fract(x)) - 1 */
39         fld1
40         faddp                           /* 2^(fract(x)) */
41         fscale                          /* e^x */
42         fstp    %st(1)
43         FLT_NARROW_EVAL_UFLOW_NONNEG_NAN
44         ret
46 1:      testl   $0x200, %eax            /* Test sign.  */
47         jz      2f                      /* If positive, jump.  */
48         fstp    %st
49         fldz                            /* Set result to 0.  */
50 2:      ret
51 END (__ieee754_exp2f)
52 strong_alias (__ieee754_exp2f, __exp2f_finite)