2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Adapted for use as log2 by Ulrich Drepper <drepper@cygnus.com>.
6 * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
7 * Adapted for x86-64 by Andreas Jaeger <aj@suse.de>.
10 #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)
33 ENTRY(__ieee754_log2l)
40 jnz 3f // in case x is NaN or ±Inf
41 4: fsub %st(2), %st // x-1 : x : 1
42 fld %st // x-1 : x-1 : x : 1
43 fabs // |x-1| : x-1 : x : 1
44 fcompl MO(limit) // x-1 : x : 1
53 fabs // log2(1) is +0 in all rounding modes.
54 5: fstp %st(1) // x-1 : 1
58 2: fstp %st(0) // x : 1
63 jnz 4b // in case x is ±Inf
75 fsub %st(2), %st // x-1 : x : 1
76 fld %st // x-1 : x-1 : x : 1
77 fabs // |x-1| : x-1 : x : 1
78 fcompl MO(limit) // x-1 : x : 1
87 fabs // log2(1) is +0 in all rounding modes.
88 6: fstp %st(1) // x-1 : 1