]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/x86_64/fpu/s_log1pl.S
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483,...
[thirdparty/glibc.git] / sysdeps / x86_64 / fpu / s_log1pl.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: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $")
12
13 #ifdef __ELF__
14 .section .rodata
15 #else
16 .text
17 #endif
18 .align ALIGNARG(4)
19 /* The fyl2xp1 can only be used for values in
20 -1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2
21 0.29 is a safe value.
22 */
23 limit: .tfloat 0.29
24 /* Please note: we use a double value here. Since 1.0 has
25 an exact representation this does not effect the accuracy
26 but it helps to optimize the code. */
27 one: .double 1.0
28
29 /*
30 * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29,
31 * otherwise fyl2x with the needed extra computation.
32 */
33 #ifdef PIC
34 #define MO(op) op##(%rip)
35 #else
36 #define MO(op) op
37 #endif
38
39 .text
40 ENTRY(__log1pl)
41 fldln2
42
43 fldt 8(%rsp)
44
45 fxam
46 fnstsw
47 fld %st
48 andb $1,%ah
49 jnz 3f // in case x is NaN or ±Inf
50 4:
51 fabs
52 fldt MO(limit)
53 fcompp
54 fnstsw
55 andb $1,%ah
56 jz 2f
57
58 faddl MO(one)
59 fyl2x
60 ret
61
62 2: fyl2xp1
63 ret
64
65 3: jp 4b // in case x is ±Inf
66 fstp %st(1)
67 fstp %st(1)
68 ret
69
70 END (__log1pl)
71 weak_alias (__log1pl, log1pl)