Update.
[glibc.git] / sysdeps / x86_64 / fpu / e_logl.S
bloba0bed663c848dfca13e36132f2d416ccf160bdba
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: $")
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)
31 #ifdef PIC
32 #define MO(op) op##(%rip)
33 #else
34 #define MO(op) op
35 #endif
37         .text
38 ENTRY(__ieee754_logl)
39         fldln2                  // log(2)
40         fldt    8(%rsp)         // x : log(2)
41         fld     %st             // x : x : log(2)
42         fsubl   MO(one)         // x-1 : x : log(2)
43         fld     %st             // x-1 : x-1 : x : log(2)
44         fabs                    // |x-1| : x-1 : x : log(2)
45         fcompl  MO(limit)       // x-1 : x : log(2)
46         fnstsw                  // x-1 : x : log(2)
47         andb    $0x45, %ah
48         jz      2f
49         fstp    %st(1)          // x-1 : log(2)
50         fyl2xp1                 // log(x)
51         ret
53 2:      fstp    %st(0)          // x : log(2)
54         fyl2x                   // log(x)
55         ret
56 END (__ieee754_logl)