From owner-cvs-all@FreeBSD.ORG Tue Oct 25 12:13:38 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 32DDA16A41F; Tue, 25 Oct 2005 12:13:38 +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 F302C43D46; Tue, 25 Oct 2005 12:13: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 j9PCDbwJ010109; Tue, 25 Oct 2005 12:13:37 GMT (envelope-from bde@repoman.freebsd.org) Received: (from bde@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j9PCDbBp010108; Tue, 25 Oct 2005 12:13:37 GMT (envelope-from bde) Message-Id: <200510251213.j9PCDbBp010108@repoman.freebsd.org> From: Bruce Evans Date: Tue, 25 Oct 2005 12:13: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 e_rem_pio2f.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: Tue, 25 Oct 2005 12:13:38 -0000 bde 2005-10-25 12:13:37 UTC FreeBSD src repository Modified files: lib/msun/src e_rem_pio2f.c Log: More fixes for arg reduction near pi/2 on systems with broken assignment to floats (mainly i386's). All errors of more than 1 ulp for float precision trig functions were supposed to have been fixed; however, compiling with gcc -O2 uncovered 18250 more such errors for cosf(), with a maximum error of 1.409 ulps. Use essentially the same fix as in rev.1.8 of k_rem_pio2f.c (access a non-volatile variable as a volatile). Here the -O1 case apparently worked because the variable is in a 2-element array and it takes -O2 to mess up such a variable by putting it in a register. The maximum error for cosf() on i386 with gcc -O2 is now 0.5467 (it is still 0.5650 with gcc -O1). This shows that -O2 still causes some extra precision, but the extra precision is now good. Extra precision is harmful mainly for implementing extra precision in software. We want to represent x+y as w+r where both "+" operations are in infinite precision and r is tiny compared with w. There is a standard algorithm for this (Knuth (1981) 4.2.2 Theorem C), and fdlibm uses this routinely, but the algorithm requires w and r to have the same precision as x and y. w is just x+y (calculated in the same finite precision as x and y), and r is a tiny correction term. The i386 gcc bugs tend to give extra precision in w, and then using this extra precision in the calculation of r results in the correction mostly staying in w and being missing from r. There still tends to be no problem if the result is a simple expression involving w and r -- modulo spills, w keeps its extra precision and r remains the right correction for this wrong w. However, here we want to pass w and r to extern functions. Extra precision is not retained in function args, so w gets fixed up, but the change to the tiny r is tinier, so r almost remains as a wrong correction for the right w. Revision Changes Path 1.12 +8 -5 src/lib/msun/src/e_rem_pio2f.c