2 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
7 * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
8 * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
11 #include <machine/asm.h>
21 ASM_TYPE_DIRECTIVE(one,@object)
23 ASM_SIZE_DIRECTIVE(one)
24 /* It is not important that this constant is precise. It is only
25 a value which is known to be on the safe side for using the
26 fyl2xp1 instruction. */
27 ASM_TYPE_DIRECTIVE(limit,@object)
29 ASM_SIZE_DIRECTIVE(limit)
33 #define MO(op) op##(%rip)
39 ENTRY(__ieee754_log10l)
41 fldt 8(%rsp) // x : log10(2)
44 fld %st // x : x : log10(2)
46 jnz 3f // in case x is NaN or ±Inf
47 4: fsubl MO(one) // x-1 : x : log10(2)
48 fld %st // x-1 : x-1 : x : log10(2)
49 fabs // |x-1| : x-1 : x : log10(2)
50 fcompl MO(limit) // x-1 : x : log10(2)
51 fnstsw // x-1 : x : log10(2)
54 fstp %st(1) // x-1 : log10(2)
58 2: fstp %st(0) // x : log10(2)
63 jnz 4b // in case x is ±Inf