Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Oct 2011 06:30:43 +0000 (UTC)
From:      David Schultz <das@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226601 - head/lib/msun/src
Message-ID:  <201110210630.p9L6UhjO010032@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: das
Date: Fri Oct 21 06:30:43 2011
New Revision: 226601
URL: http://svn.freebsd.org/changeset/base/226601

Log:
  Fix a regression introduced in r226371: When the high part of x*y
  exactly cancels with z, return the low part of x*y instead of
  discarding it.

Modified:
  head/lib/msun/src/s_fma.c
  head/lib/msun/src/s_fmal.c

Modified: head/lib/msun/src/s_fma.c
==============================================================================
--- head/lib/msun/src/s_fma.c	Fri Oct 21 06:30:16 2011	(r226600)
+++ head/lib/msun/src/s_fma.c	Fri Oct 21 06:30:43 2011	(r226601)
@@ -250,6 +250,8 @@ fma(double x, double y, double z)
 	xy = dd_mul(xs, ys);
 	r = dd_add(xy.hi, zs);
 
+	spread = ex + ey;
+
 	if (r.hi == 0.0) {
 		/*
 		 * When the addends cancel to 0, ensure that the result has
@@ -257,11 +259,9 @@ fma(double x, double y, double z)
 		 */
 		fesetround(oround);
 		volatile double vzs = zs; /* XXX gcc CSE bug workaround */
-		return (xy.hi + vzs);
+		return (xy.hi + vzs + ldexp(xy.lo, spread));
 	}
 
-	spread = ex + ey;
-
 	if (oround != FE_TONEAREST) {
 		/*
 		 * There is no need to worry about double rounding in directed

Modified: head/lib/msun/src/s_fmal.c
==============================================================================
--- head/lib/msun/src/s_fmal.c	Fri Oct 21 06:30:16 2011	(r226600)
+++ head/lib/msun/src/s_fmal.c	Fri Oct 21 06:30:43 2011	(r226601)
@@ -238,6 +238,8 @@ fmal(long double x, long double y, long 
 	xy = dd_mul(xs, ys);
 	r = dd_add(xy.hi, zs);
 
+	spread = ex + ey;
+
 	if (r.hi == 0.0) {
 		/*
 		 * When the addends cancel to 0, ensure that the result has
@@ -245,11 +247,9 @@ fmal(long double x, long double y, long 
 		 */
 		fesetround(oround);
 		volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
-		return (xy.hi + vzs);
+		return (xy.hi + vzs + ldexpl(xy.lo, spread));
 	}
 
-	spread = ex + ey;
-
 	if (oround != FE_TONEAREST) {
 		/*
 		 * There is no need to worry about double rounding in directed



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110210630.p9L6UhjO010032>