diff options
Diffstat (limited to 'sysdeps/i386/fpu/e_exp.S')
-rw-r--r-- | sysdeps/i386/fpu/e_exp.S | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/sysdeps/i386/fpu/e_exp.S b/sysdeps/i386/fpu/e_exp.S index 2c331d9ed6..c00beedfe5 100644 --- a/sysdeps/i386/fpu/e_exp.S +++ b/sysdeps/i386/fpu/e_exp.S @@ -5,9 +5,25 @@ #include <machine/asm.h> + .section .rodata.cst8,"aM",@progbits,8 + .p2align 3 + .type dbl_min,@object +dbl_min: .byte 0, 0, 0, 0, 0, 0, 0x10, 0 + ASM_SIZE_DIRECTIVE(dbl_min) + +#ifdef PIC +# define MO(op) op##@GOTOFF(%ecx) +#else +# define MO(op) op +#endif + + .text /* e^x = 2^(x * log2(e)) */ ENTRY(__ieee754_exp) +#ifdef PIC + LOAD_PIC_REG (cx) +#endif fldl 4(%esp) /* I added the following ugly construct because exp(+-Inf) resulted in NaN. The ugliness results from the bright minds at Intel. @@ -30,7 +46,22 @@ ENTRY(__ieee754_exp) faddp /* 2^(fract(x * log2(e))) */ fscale /* e^x */ fstp %st(1) - ret + fldl MO(dbl_min) + fld %st(1) + fucompp + fnstsw + sahf + jnc 3f + subl $8, %esp + cfi_adjust_cfa_offset (8) + fld %st(0) + fmul %st(0) + fstpl (%esp) + fstpl (%esp) + fldl (%esp) + addl $8, %esp + cfi_adjust_cfa_offset (-8) +3: ret 1: testl $0x200, %eax /* Test sign. */ jz 2f /* If positive, jump. */ @@ -41,6 +72,9 @@ END (__ieee754_exp) ENTRY(__exp_finite) +#ifdef PIC + LOAD_PIC_REG (cx) +#endif fldl2e fmull 4(%esp) /* x * log2(e) */ fld %st @@ -52,5 +86,20 @@ ENTRY(__exp_finite) faddp /* 2^(fract(x * log2(e))) */ fscale /* e^x */ fstp %st(1) - ret + fldl MO(dbl_min) + fld %st(1) + fucompp + fnstsw + sahf + jnc 4f + subl $8, %esp + cfi_adjust_cfa_offset (8) + fld %st(0) + fmul %st(0) + fstpl (%esp) + fstpl (%esp) + fldl (%esp) + addl $8, %esp + cfi_adjust_cfa_offset (-8) +4: ret END(__exp_finite) |