diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-10-15 20:22:59 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-10-15 20:22:59 -0400 |
commit | bcf01e6d800e837622ddbc851b42b55fa99e5636 (patch) | |
tree | 5df0ae9971331105fe53de872895abb68d8276a5 /sysdeps/i386/fpu | |
parent | ba1a0d5938b53454a249d679ab90baf541cd91ad (diff) | |
download | glibc-bcf01e6d800e837622ddbc851b42b55fa99e5636.zip glibc-bcf01e6d800e837622ddbc851b42b55fa99e5636.tar.gz glibc-bcf01e6d800e837622ddbc851b42b55fa99e5636.tar.bz2 |
Optimize exp
Add __exp*_finite optimizations and rewrite some wrappers.
Diffstat (limited to 'sysdeps/i386/fpu')
-rw-r--r-- | sysdeps/i386/fpu/e_exp.S | 17 | ||||
-rw-r--r-- | sysdeps/i386/fpu/e_expf.S | 17 | ||||
-rw-r--r-- | sysdeps/i386/fpu/e_expl.c | 3 |
3 files changed, 34 insertions, 3 deletions
diff --git a/sysdeps/i386/fpu/e_exp.S b/sysdeps/i386/fpu/e_exp.S index 4a75fa1..2c331d9 100644 --- a/sysdeps/i386/fpu/e_exp.S +++ b/sysdeps/i386/fpu/e_exp.S @@ -5,7 +5,6 @@ #include <machine/asm.h> -RCSID("$NetBSD: e_exp.S,v 1.7 1996/07/03 17:31:28 jtc Exp $") /* e^x = 2^(x * log2(e)) */ ENTRY(__ieee754_exp) @@ -39,3 +38,19 @@ ENTRY(__ieee754_exp) fldz /* Set result to 0. */ 2: ret END (__ieee754_exp) + + +ENTRY(__exp_finite) + fldl2e + fmull 4(%esp) /* x * log2(e) */ + fld %st + frndint /* int(x * log2(e)) */ + fsubr %st,%st(1) /* fract(x * log2(e)) */ + fxch + f2xm1 /* 2^(fract(x * log2(e))) - 1 */ + fld1 + faddp /* 2^(fract(x * log2(e))) */ + fscale /* e^x */ + fstp %st(1) + ret +END(__exp_finite) diff --git a/sysdeps/i386/fpu/e_expf.S b/sysdeps/i386/fpu/e_expf.S index 5fd49b8..4e4f6a0 100644 --- a/sysdeps/i386/fpu/e_expf.S +++ b/sysdeps/i386/fpu/e_expf.S @@ -6,7 +6,6 @@ #include <machine/asm.h> -RCSID("$NetBSD: $") /* e^x = 2^(x * log2(e)) */ ENTRY(__ieee754_expf) @@ -40,3 +39,19 @@ ENTRY(__ieee754_expf) fldz /* Set result to 0. */ 2: ret END (__ieee754_expf) + + +ENTRY(__expf_finite) + fldl2e + fmuls 4(%esp) /* x * log2(e) */ + fld %st + frndint /* int(x * log2(e)) */ + fsubr %st,%st(1) /* fract(x * log2(e)) */ + fxch + f2xm1 /* 2^(fract(x * log2(e))) - 1 */ + fld1 + faddp /* 2^(fract(x * log2(e))) */ + fscale /* e^x */ + fstp %st(1) + ret +END(__expf_finite) diff --git a/sysdeps/i386/fpu/e_expl.c b/sysdeps/i386/fpu/e_expl.c index 2240cea..8dc9581 100644 --- a/sysdeps/i386/fpu/e_expl.c +++ b/sysdeps/i386/fpu/e_expl.c @@ -63,7 +63,7 @@ __ieee754_expl (long double x) "fld1\n\t" /* 4 1.0 */ "faddp\n\t" /* 3 2^(fract(x * log2(e))) */ "fstp %%st(1)\n\t" /* 2 */ - "fscale\n\t" /* 2 scale factor is st(1); e^x */ + "fscale\n\t" /* 2 scale factor is st(1); e^x */ "fstp %%st(1)\n\t" /* 1 */ "fstp %%st(1)\n\t" /* 0 */ "jmp 2f\n\t" @@ -75,3 +75,4 @@ __ieee754_expl (long double x) : "=t" (res) : "0" (x), "m" (c0), "m" (c1) : "ax", "dx"); return res; } +strong_alias (__ieee754_expl, __expl_finite) |