From owner-cvs-all@FreeBSD.ORG Mon Oct 24 14:08:37 2005 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7AB5B16A421; Mon, 24 Oct 2005 14:08:37 +0000 (GMT) (envelope-from bde@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2B24243D48; Mon, 24 Oct 2005 14:08:37 +0000 (GMT) (envelope-from bde@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j9OE8b60011879; Mon, 24 Oct 2005 14:08:37 GMT (envelope-from bde@repoman.freebsd.org) Received: (from bde@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9OE8bLR011878; Mon, 24 Oct 2005 14:08:37 GMT (envelope-from bde) Message-Id: <200510241408.j9OE8bLR011878@repoman.freebsd.org> From: Bruce Evans Date: Mon, 24 Oct 2005 14:08:37 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: src/lib/msun/src k_cos.c k_cosf.c k_sin.c k_sinf.c s_cos.c s_cosf.c s_sin.c s_sinf.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2005 14:08:37 -0000 bde 2005-10-24 14:08:37 UTC FreeBSD src repository Modified files: lib/msun/src k_cos.c k_cosf.c k_sin.c k_sinf.c s_cos.c s_cosf.c s_sin.c s_sinf.c Log: Moved the optimization for tiny x from __kernel_{cos,sin}[f](x) to {cos_sin}[f](x) so that x doesn't need to be reclassified in the "kernel" functions to determine if it is tiny (it still needs to be reclassified in the cosine case for other reasons that will go away). This optimization is quite large for exponentially distributed x, since x is tiny for almost half of the domain, but it is a pessimization for uniformally distributed x since it takes a little time for all cases but rarely applies. Arg reduction on exponentially distributed x rarely gives a tiny x unless the reduction is null, so it is best to only do the optimization if the initial x is tiny, which is what this commit arranges. The imediate result is an average optimization of 1.4% relative to the previous version in a case that doesn't favour the optimization (double cos(x) on all float x) and a large pessimization for the relatively unimportant cases of lgamma[f][_r](x) on tiny, negative, exponentially distributed x. The optimization should be recovered for lgamma*() as part of fixing lgamma*()'s low-quality arg reduction. Fixed various wrong constants for the cutoff for "tiny". For cosine, the cutoff is when x**2/2! == {FLT or DBL}_EPSILON/2. We round down to an integral power of 2 (and for cos() reduce the power by another 1) because the exact cutoff doesn't matter and would take more work to determine. For sine, the exact cutoff is larger due to the ration of terms being x**2/3! instead of x**2/2!, but we use the same cutoff as for cosine. We now use a cutoff of 2**-27 for double precision and 2**-12 for single precision. 2**-27 was used in all cases but was misspelled 2**27 in comments. Wrong and sloppy cutoffs just cause missed optimizations (provided the rounding mode is to nearest -- other modes just aren't supported). Revision Changes Path 1.9 +0 -3 src/lib/msun/src/k_cos.c 1.9 +0 -3 src/lib/msun/src/k_cosf.c 1.9 +1 -5 src/lib/msun/src/k_sin.c 1.8 +1 -5 src/lib/msun/src/k_sinf.c 1.10 +5 -1 src/lib/msun/src/s_cos.c 1.8 +5 -3 src/lib/msun/src/s_cosf.c 1.10 +5 -1 src/lib/msun/src/s_sin.c 1.8 +5 -1 src/lib/msun/src/s_sinf.c