]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/x86_64/fpu/e_logl.S
.
[thirdparty/glibc.git] / sysdeps / x86_64 / fpu / e_logl.S
1 /*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 *
5 * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
6 * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
7 */
8
9 #include <machine/asm.h>
10
11 RCSID("$NetBSD: $")
12
13
14 #ifdef __ELF__
15 .section .rodata
16 #else
17 .text
18 #endif
19 .align ALIGNARG(4)
20 ASM_TYPE_DIRECTIVE(one,@object)
21 one: .double 1.0
22 ASM_SIZE_DIRECTIVE(one)
23 /* It is not important that this constant is precise. It is only
24 a value which is known to be on the safe side for using the
25 fyl2xp1 instruction. */
26 ASM_TYPE_DIRECTIVE(limit,@object)
27 limit: .double 0.29
28 ASM_SIZE_DIRECTIVE(limit)
29
30
31 #ifdef PIC
32 #define MO(op) op##(%rip)
33 #else
34 #define MO(op) op
35 #endif
36
37 .text
38 ENTRY(__ieee754_logl)
39 fldln2 // log(2)
40 fldt 8(%rsp) // x : log(2)
41 fxam
42 fnstsw
43 fld %st // x : x : log(2)
44 testb $1, %ah
45 jnz 3f // in case x is NaN or +-Inf
46 4: fsubl MO(one) // x-1 : x : log(2)
47 fld %st // x-1 : x-1 : x : log(2)
48 fabs // |x-1| : x-1 : x : log(2)
49 fcompl MO(limit) // x-1 : x : log(2)
50 fnstsw // x-1 : x : log(2)
51 andb $0x45, %ah
52 jz 2f
53 fstp %st(1) // x-1 : log(2)
54 fyl2xp1 // log(x)
55 ret
56
57 2: fstp %st(0) // x : log(2)
58 fyl2x // log(x)
59 ret
60
61 3: testb $4, %ah
62 jnz 4b // in case x is +-Inf
63 fstp %st(1)
64 fstp %st(1)
65 ret
66 END (__ieee754_logl)