Blame sysdeps/x86_64/fpu/e_exp2l.S
|
Packit |
6c4009 |
/*
|
|
Packit |
6c4009 |
* Written by J.T. Conklin <jtc@netbsd.org>.
|
|
Packit |
6c4009 |
* Adapted for exp2 by Ulrich Drepper <drepper@cygnus.com>.
|
|
Packit |
6c4009 |
* Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
|
|
Packit |
6c4009 |
* Public domain.
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <machine/asm.h>
|
|
Packit |
6c4009 |
#include <x86_64-math-asm.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
DEFINE_LDBL_MIN
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef PIC
|
|
Packit |
6c4009 |
# define MO(op) op##(%rip)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define MO(op) op
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
ENTRY(__ieee754_exp2l)
|
|
Packit |
6c4009 |
fldt 8(%rsp)
|
|
Packit |
6c4009 |
/* I added the following ugly construct because exp(+-Inf) resulted
|
|
Packit |
6c4009 |
in NaN. The ugliness results from the bright minds at Intel.
|
|
Packit |
6c4009 |
For the i686 the code can be written better.
|
|
Packit |
6c4009 |
-- drepper@cygnus.com. */
|
|
Packit |
6c4009 |
fxam /* Is NaN or +-Inf? */
|
|
Packit |
6c4009 |
fstsw %ax
|
|
Packit |
6c4009 |
movb $0x45, %dh
|
|
Packit |
6c4009 |
andb %ah, %dh
|
|
Packit |
6c4009 |
cmpb $0x05, %dh
|
|
Packit |
6c4009 |
je 1f /* Is +-Inf, jump. */
|
|
Packit |
6c4009 |
movzwl 8+8(%rsp), %eax
|
|
Packit |
6c4009 |
andl $0x7fff, %eax
|
|
Packit |
6c4009 |
cmpl $0x3fbe, %eax
|
|
Packit |
6c4009 |
jge 3f
|
|
Packit |
6c4009 |
/* Argument's exponent below -65, result rounds to 1. */
|
|
Packit |
6c4009 |
fld1
|
|
Packit |
6c4009 |
faddp
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
3: fld %st
|
|
Packit |
6c4009 |
frndint /* int(x) */
|
|
Packit |
6c4009 |
fsubr %st,%st(1) /* fract(x) */
|
|
Packit |
6c4009 |
fxch
|
|
Packit |
6c4009 |
f2xm1 /* 2^(fract(x)) - 1 */
|
|
Packit |
6c4009 |
fld1
|
|
Packit |
6c4009 |
faddp /* 2^(fract(x)) */
|
|
Packit |
6c4009 |
fscale /* e^x */
|
|
Packit |
6c4009 |
fstp %st(1)
|
|
Packit |
6c4009 |
LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
1: testl $0x200, %eax /* Test sign. */
|
|
Packit |
6c4009 |
jz 2f /* If positive, jump. */
|
|
Packit |
6c4009 |
fstp %st
|
|
Packit |
6c4009 |
fldz /* Set result to 0. */
|
|
Packit |
6c4009 |
2: ret
|
|
Packit |
6c4009 |
END (__ieee754_exp2l)
|
|
Packit |
6c4009 |
strong_alias (__ieee754_exp2l, __exp2l_finite)
|