master
 1/**
 2 * This file has no copyright assigned and is placed in the Public Domain.
 3 * This file is part of the mingw-w64 runtime package.
 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
 5 */
 6#include <_mingw_mac.h>
 7
 8	.file	"log2f.S"
 9	.text
10#ifdef __x86_64__
11	.align 8
12#else
13	.align 4
14#endif
15one:	.double 1.0
16	/* It is not important that this constant is precise.  It is only
17	   a value which is known to be on the safe side for using the
18	   fyl2xp1 instruction.  */
19limit:	.double 0.29
20
21.globl __MINGW_USYMBOL(log2f)
22	.def	__MINGW_USYMBOL(log2f);	.scl	2;	.type	32;	.endef
23__MINGW_USYMBOL(log2f):
24#ifdef __x86_64__
25	movss	%xmm0,-12(%rsp)
26	fldl	one(%rip)
27	flds	-12(%rsp)		// x : 1
28	fxam
29	fnstsw
30	fld	%st		// x : x : 1
31	sahf
32	jc	3f		// in case x is NaN or Inf
334:	fsub	%st(2), %st	// x-1 : x : 1
34	fld	%st		// x-1 : x-1 : x : 1
35	fabs			// |x-1| : x-1 : x : 1
36	fcompl	limit(%rip)	// x-1 : x : 1
37	fnstsw			// x-1 : x : 1
38	andb	$0x45, %ah
39	jz	2f
40	fstp	%st(1)		// x-1 : 1
41	fyl2xp1			// log(x)
42	fstps	-12(%rsp)
43	movss	-12(%rsp),%xmm0
44	ret
45
462:	fstp	%st(0)		// x : 1
47	fyl2x			// log(x)
48	fstps	-12(%rsp)
49	movss	-12(%rsp),%xmm0
50	ret
51
523:	jp	4b		// in case x is Inf
53	fstp	%st(1)
54	fstp	%st(1)
55	fstps	-12(%rsp)
56	movss	-12(%rsp),%xmm0
57	ret
58#else
59	fldl	one
60	flds	4(%esp)		// x : 1
61	fxam
62	fnstsw
63	fld	%st		// x : x : 1
64	sahf
65	jc	3f		// in case x is NaN or Inf
664:	fsub	%st(2), %st	// x-1 : x : 1
67	fld	%st		// x-1 : x-1 : x : 1
68	fabs			// |x-1| : x-1 : x : 1
69	fcompl	limit		// x-1 : x : 1
70	fnstsw			// x-1 : x : 1
71	andb	$0x45, %ah
72	jz	2f
73	fstp	%st(1)		// x-1 : 1
74	fyl2xp1			// log(x)
75	ret
76
772:	fstp	%st(0)		// x : 1
78	fyl2x			// log(x)
79	ret
80
813:	jp	4b		// in case x is Inf
82	fstp	%st(1)
83	fstp	%st(1)
84	ret
85#endif