2 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
6 * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
9 #include <machine/asm.h>
12 .section .rodata.cst8,"aM",@progbits,8
17 ASM_SIZE_DIRECTIVE(one)
18 /* It is not important that this constant is precise. It is only
19 a value which is known to be on the safe side for using the
20 fyl2xp1 instruction. */
23 ASM_SIZE_DIRECTIVE(limit)
27 # define MO(op) op##(%rip)
35 fldt 8(%rsp) // x : log(2)
38 fld %st // x : x : log(2)
40 jnz 3f // in case x is NaN or +-Inf
41 movzwl 8+8(%rsp), %eax
43 jae 6f // x <= -2, avoid overflow from -LDBL_MAX - 1.
44 4: fsubl MO(one) // x-1 : x : log(2)
45 6: fld %st // x-1 : x-1 : x : log(2)
46 fabs // |x-1| : x-1 : x : log(2)
47 fcompl MO(limit) // x-1 : x : log(2)
48 fnstsw // x-1 : x : log(2)
56 fabs // log(1) is +0 in all rounding modes.
57 5: fstp %st(1) // x-1 : log(2)
61 2: fstp %st(0) // x : log(2)
66 jnz 4b // in case x is +-Inf
75 fldt 8(%rsp) // x : log(2)
76 fld %st // x : x : log(2)
77 fsubl MO(one) // x-1 : x : log(2)
78 fld %st // x-1 : x-1 : x : log(2)
79 fabs // |x-1| : x-1 : x : log(2)
80 fcompl MO(limit) // x-1 : x : log(2)
81 fnstsw // x-1 : x : log(2)
84 fstp %st(1) // x-1 : log(2)