2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / fpu / s_log1p.S
blobec777fdf933832bdb679851e576a65fd10797774
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  */
6 #include <machine/asm.h>
8 RCSID("$NetBSD: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $")
10 #ifdef __ELF__
11         .section .rodata
12 #else
13         .text
14 #endif
15         .align ALIGNARG(4)
16         /* The fyl2xp1 can only be used for values in
17                 -1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2
18            0.29 is a safe value.
19         */
20 limit:  .double 0.29
21 one:    .double 1.0
24  * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29,
25  * otherwise fyl2x with the needed extra computation.
26  */
27         .text
28 ENTRY(__log1p)
29         fldln2
31         fldl    4(%esp)
33 #ifdef  PIC
34         LOAD_PIC_REG (dx)
35 #endif
37         fxam
38         fnstsw
39         fld     %st
40         sahf
41         jc      3f              // in case x is NaN or ±Inf
42 4:      fabs
43 #ifdef PIC
44         fcompl  limit@GOTOFF(%edx)
45 #else
46         fcompl  limit
47 #endif
48         fnstsw
49         sahf
50         jc      2f
52 #ifdef PIC
53         faddl   one@GOTOFF(%edx)
54 #else
55         faddl   one
56 #endif
57         fyl2x
58         ret
60 2:      fyl2xp1
61         ret
63 3:      jp      4b              // in case x is ±Inf
64         fstp    %st(1)
65         fstp    %st(1)
66         ret
68 END (__log1p)
69 weak_alias (__log1p, log1p)