2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / fpu / s_log1pl.S
blob4bca67d6b0442e759c5f49e1f0383f194aab552b
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  */
8 #include <machine/asm.h>
10 RCSID("$NetBSD: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $")
12 #ifdef __ELF__
13         .section .rodata
14 #else
15         .text
16 #endif
17         .align ALIGNARG(4)
18         /* The fyl2xp1 can only be used for values in
19                 -1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2
20            0.29 is a safe value.
21         */
22 limit:  .tfloat 0.29
23         /* Please note:  we use a double value here.  Since 1.0 has
24            an exact representation this does not effect the accuracy
25            but it helps to optimize the code.  */
26 one:    .double 1.0
29  * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29,
30  * otherwise fyl2x with the needed extra computation.
31  */
32         .text
33 ENTRY(__log1pl)
34         fldln2
36         fldt    4(%esp)
38 #ifdef PIC
39         LOAD_PIC_REG (dx)
40 #endif
42         fxam
43         fnstsw
44         fld     %st
45         sahf
46         jc      3f              // in case x is NaN or ±Inf
48         fabs
49 #ifdef PIC
50         fldt    limit@GOTOFF(%edx)
51 #else
52         fldt    limit
53 #endif
54         fcompp
55         fnstsw
56         sahf
57         jnc     2f
59 #ifdef PIC
60         faddl   one@GOTOFF(%edx)
61 #else
62         faddl   one
63 #endif
64         fyl2x
65         ret
67 2:      fyl2xp1
68         ret
70 3:      jp      4b              // in case x is ±Inf
71         fstp    %st(1)
72         fstp    %st(1)
73         ret
75 END (__log1pl)
76 weak_alias (__log1pl, log1pl)