2.9
[glibc/nacl-glibc.git] / sysdeps / x86_64 / fpu / s_log1pl.S
blobac2bd22a4fc5fc31b758beafff689fb73fe070a2
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  */
9 #include <machine/asm.h>
11 RCSID("$NetBSD: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $")
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
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
39         .text
40 ENTRY(__log1pl)
41         fldln2
43         fldt    8(%rsp)
45         fxam
46         fnstsw
47         fld     %st
48         testb   $1, %ah
49         jnz     3f              // in case x is NaN or ±Inf
51         fabs
52         fldt    MO(limit)
53         fcompp
54         fnstsw
55         andb    $1,%ah
56         jz      2f
58         faddl   MO(one)
59         fyl2x
60         ret
62 2:      fyl2xp1
63         ret
65 3:      testb   $4, %ah
66         jnz     4b              // in case x is ±Inf
67         fstp    %st(1)
68         fstp    %st(1)
69         ret
71 END (__log1pl)
72 weak_alias (__log1pl, log1pl)