Import the subset of J.T. Conklin's single-precision x86-optimized

math routines that appear to be (a) correct and (b) faster than their
MI counterparts on my Pentium 4.

Obtained from:	NetBSD
This commit is contained in:
David Schultz 2005-01-13 18:58:25 +00:00
parent 6920b9cc54
commit fe69257da2
17 changed files with 280 additions and 2 deletions

View File

@ -54,8 +54,10 @@ ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_fmod.S e_log.S e_log10.S \
e_remainder.S e_scalb.S e_sqrt.S s_atan.S s_ceil.S s_copysign.S \
s_cos.S s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \
s_rint.S s_scalbn.S s_significand.S s_sin.S s_tan.S
# Broken:
# ARCH_SRCS+= s_log1p.S
# float counterparts
ARCH_SRCS+= e_atan2f.S e_log10f.S e_logf.S e_remainderf.S e_scalbf.S \
e_sqrtf.S s_ceilf.S s_copysignf.S s_cosf.S s_floorf.S s_logbf.S \
s_rintf.S s_scalbnf.S s_significandf.S s_sinf.S s_tanf.S
.endif
ARCH_SUBDIR?= ${MACHINE_ARCH}

15
lib/msun/i387/e_atan2f.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: e_atan2f.S,v 1.1 1995/05/08 23:35:10 jtc Exp $") */
ENTRY(__ieee754_atan2f)
flds 4(%esp)
flds 8(%esp)
fpatan
ret

15
lib/msun/i387/e_log10f.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: e_log10f.S,v 1.1 1996/07/03 16:50:22 jtc Exp $") */
ENTRY(__ieee754_log10f)
fldlg2
flds 4(%esp)
fyl2x
ret

15
lib/msun/i387/e_logf.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: e_logf.S,v 1.2 1996/07/06 00:15:45 jtc Exp $") */
ENTRY(__ieee754_logf)
fldln2
flds 4(%esp)
fyl2x
ret

View File

@ -0,0 +1,19 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: e_remainderf.S,v 1.2 1995/05/08 23:49:47 jtc Exp $") */
ENTRY(__ieee754_remainderf)
flds 8(%esp)
flds 4(%esp)
1: fprem1
fstsw %ax
sahf
jp 1b
fstp %st(1)
ret

15
lib/msun/i387/e_scalbf.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: e_scalbf.S,v 1.1 1996/07/03 16:50:24 jtc Exp $") */
ENTRY(__ieee754_scalbf)
flds 8(%esp)
flds 4(%esp)
fscale
ret

14
lib/msun/i387/e_sqrtf.S Normal file
View File

@ -0,0 +1,14 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: e_sqrtf.S,v 1.2 1995/05/08 23:50:14 jtc Exp $") */
ENTRY(__ieee754_sqrtf)
flds 4(%esp)
fsqrt
ret

29
lib/msun/i387/s_ceilf.S Normal file
View File

@ -0,0 +1,29 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") */
ENTRY(ceilf)
pushl %ebp
movl %esp,%ebp
subl $8,%esp
fstcw -12(%ebp) /* store fpu control word */
movw -12(%ebp),%dx
orw $0x0800,%dx /* round towards +oo */
andw $0xfbff,%dx
movw %dx,-16(%ebp)
fldcw -16(%ebp) /* load modfied control word */
flds 8(%ebp); /* round */
frndint
fldcw -12(%ebp) /* restore original control word */
leave
ret

View File

@ -0,0 +1,19 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_copysignf.S,v 1.3 1995/05/08 23:53:25 jtc Exp $") */
ENTRY(copysignf)
movl 8(%esp),%edx
andl $0x80000000,%edx
movl 4(%esp),%eax
andl $0x7fffffff,%eax
orl %edx,%eax
movl %eax,4(%esp)
flds 4(%esp)
ret

15
lib/msun/i387/s_cosf.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_cosf.S,v 1.4 1999/07/02 15:37:34 simonb Exp $") */
/* A float's domain isn't large enough to require argument reduction. */
ENTRY(cosf)
flds 4(%esp)
fcos
ret

29
lib/msun/i387/s_floorf.S Normal file
View File

@ -0,0 +1,29 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") */
ENTRY(floorf)
pushl %ebp
movl %esp,%ebp
subl $8,%esp
fstcw -12(%ebp) /* store fpu control word */
movw -12(%ebp),%dx
orw $0x0400,%dx /* round towards -oo */
andw $0xf7ff,%dx
movw %dx,-16(%ebp)
fldcw -16(%ebp) /* load modfied control word */
flds 8(%ebp); /* round */
frndint
fldcw -12(%ebp) /* restore original control word */
leave
ret

15
lib/msun/i387/s_logbf.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_logbf.S,v 1.3 1995/05/09 00:15:12 jtc Exp $") */
ENTRY(logbf)
flds 4(%esp)
fxtract
fstp %st
ret

14
lib/msun/i387/s_rintf.S Normal file
View File

@ -0,0 +1,14 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_rintf.S,v 1.3 1995/05/09 00:17:22 jtc Exp $") */
ENTRY(rintf)
flds 4(%esp)
frndint
ret

16
lib/msun/i387/s_scalbnf.S Normal file
View File

@ -0,0 +1,16 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */
ENTRY(scalbnf)
fildl 8(%esp)
flds 4(%esp)
fscale
fstp %st(1) /* bug fix for fp stack overflow */
ret

View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_significandf.S,v 1.3 1995/05/09 00:24:07 jtc Exp $") */
ENTRY(significandf)
flds 4(%esp)
fxtract
fstp %st(1)
ret

15
lib/msun/i387/s_sinf.S Normal file
View File

@ -0,0 +1,15 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_sinf.S,v 1.3 1995/05/09 00:27:53 jtc Exp $") */
/* A float's domain isn't large enough to require argument reduction. */
ENTRY(sinf)
flds 4(%esp)
fsin
ret

16
lib/msun/i387/s_tanf.S Normal file
View File

@ -0,0 +1,16 @@
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
/* RCSID("$NetBSD: s_tanf.S,v 1.3 1995/05/09 00:31:09 jtc Exp $") */
/* A float's domain isn't large enough to require argument reduction. */
ENTRY(tanf)
flds 4(%esp)
fptan
fstp %st(0)
ret