From owner-freebsd-standards Sat Feb 8 2: 3:52 2003 Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 604A237B401; Sat, 8 Feb 2003 02:03:50 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1575343F75; Sat, 8 Feb 2003 02:03:49 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA26880; Sat, 8 Feb 2003 21:03:26 +1100 Date: Sat, 8 Feb 2003 21:03:30 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Garrett Wollman Cc: Mike Barcroft , Subject: Re: fpclassify() for review In-Reply-To: <200302071825.h17IP4s7081758@khavrinen.lcs.mit.edu> Message-ID: <20030208201529.E16550-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 7 Feb 2003, Garrett Wollman wrote: > I think that, if we had some help from the compiler, it ought to be > possible to implement FLT_EVAL_METHOD == 2 for i386, and that's > probably the closest to the actual hardware implementation. Something This is intentionally not done. i386.md intentionally claims that the hardware implements method 0 (float + float -> float, etc.). This is a bad efficiency hack. Since the hardware actually implements float + float -> pseudo-float := , etc., this gives various bugs. The bugs are intentionally reduced by changing the precision from its hardware default of 64 bits to 53 bits. > similar to Kahan's PARANOIA ought to be able to distinguish the > various methods and thereby serve as a regression test. gcc/enquire.c is better for this. PARANIOA is better for detecting broken clipping of excess precision. Both ENQUIRE and PARANOIA are sensitive to precision, but PARANIOA expects precision errors to some extent so the errors are easier to isolate. Changing the FreeBSD default back to the hardware default causes the following regressions in PARANOIA output: %%% --- paranonia-53bitprecision.out Sat Feb 8 20:42:54 2003 +++ paranonia-64bitprecision.out Sat Feb 8 20:42:50 2003 @@ -98,2 +98,6 @@ The number of significant digits of the Radix is 53.000000 . +Some subexpressions appear to be calculated extra +precisely with about 11 extra B-digits, i.e. +roughly 3.31133 extra significant decimals. +That feature is not tested further by this program. @@ -110,7 +114,8 @@ Checking rounding on multiply, divide and add/subtract. -Multiplication appears to round correctly. -Division appears to round correctly. -Addition/Subtraction appears to round correctly. -Checking for sticky bit. -Sticky bit apparently used correctly. +* is neither chopped nor correctly rounded. +/ is neither chopped nor correctly rounded. +Addition/Subtraction neither rounds nor chops. +Sticky bit used incorrectly or not at all. +FLAW: lack(s) of guard digits or failure(s) to correctly round or chop +(noted above) count as one flaw in the final tally below. @@ -124,3 +129,4 @@ Testing whether sqrt is rounded or chopped. -Square root appears to be correctly rounded. +Square root is neither chopped nor correctly rounded. +Observed errors run from -5.0000000e-01 to 5.0000000e-01 ulps. @@ -184,7 +190,5 @@ +The number of FLAWs discovered = 1. -No failures, defects nor flaws have been discovered. -Rounding appears to conform to the proposed IEEE standard P754, -except for possibly Double Rounding during Gradual Underflow. -The arithmetic diagnosed appears to be Excellent! +The arithmetic diagnosed seems Satisfactory though flawed. END OF TEST. %%% This is with a 1988 version of paranoia.c. The gcc bugs are at least as old. Note that the bug is not extra precision; it is misimplementation of extra precision. PARANIOA understands extra precision and assigns the results of expressions to variables to get rid of it, but gcc doesn't perform the necessary conversions for these assignments because of the hacks in i386.md. PARANIOA works right when compiled with -ffloat-store since it doesn't trust casts and always uses assignments to clip the extra precision. Casts and assignments are supposed to cause the same conversions, but the -ffloat-store hack only works for assignments. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message