]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/e_log10f.S
Optimize libm
[thirdparty/glibc.git] / sysdeps / i386 / fpu / e_log10f.S
1 /*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
5 *
6 * Changed to use fyl2xp1 for values near 1, <drepper@cygnus.com>.
7 */
8
9 #include <machine/asm.h>
10
11 #ifdef __ELF__
12 .section .rodata.cst8,"aM",@progbits,8
13 #else
14 .text
15 #endif
16 .p2align 3
17 ASM_TYPE_DIRECTIVE(one,@object)
18 one: .double 1.0
19 ASM_SIZE_DIRECTIVE(one)
20 /* It is not important that this constant is precise. It is only
21 a value which is known to be on the safe side for using the
22 fyl2xp1 instruction. */
23 ASM_TYPE_DIRECTIVE(limit,@object)
24 limit: .double 0.29
25 ASM_SIZE_DIRECTIVE(limit)
26
27
28 #ifdef PIC
29 # define MO(op) op##@GOTOFF(%edx)
30 #else
31 # define MO(op) op
32 #endif
33
34 .text
35 ENTRY(__ieee754_log10f)
36 fldlg2 // log10(2)
37 flds 4(%esp) // x : log10(2)
38 #ifdef PIC
39 LOAD_PIC_REG (dx)
40 #endif
41 fxam
42 fnstsw
43 fld %st // x : x : log10(2)
44 sahf
45 jc 3f // in case x is NaN or ±Inf
46 4: fsubl MO(one) // x-1 : x : log10(2)
47 fld %st // x-1 : x-1 : x : log10(2)
48 fabs // |x-1| : x-1 : x : log10(2)
49 fcompl MO(limit) // x-1 : x : log10(2)
50 fnstsw // x-1 : x : log10(2)
51 andb $0x45, %ah
52 jz 2f
53 fstp %st(1) // x-1 : log10(2)
54 fyl2xp1 // log10(x)
55 ret
56
57 2: fstp %st(0) // x : log10(2)
58 fyl2x // log10(x)
59 ret
60
61 3: jp 4b // in case x is ±Inf
62 fstp %st(1)
63 fstp %st(1)
64 ret
65 END (__ieee754_log10f)
66 strong_alias (__ieee754_log10f, __log10f_finite)