From owner-svn-src-head@FreeBSD.ORG Sat Apr 7 03:59:13 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3BCA3106564A; Sat, 7 Apr 2012 03:59:13 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C81A8FC16; Sat, 7 Apr 2012 03:59:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q373xCMT040918; Sat, 7 Apr 2012 03:59:12 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q373xCF5040914; Sat, 7 Apr 2012 03:59:12 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201204070359.q373xCF5040914@svn.freebsd.org> From: David Schultz Date: Sat, 7 Apr 2012 03:59:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233973 - head/lib/msun/src X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Apr 2012 03:59:13 -0000 Author: das Date: Sat Apr 7 03:59:12 2012 New Revision: 233973 URL: http://svn.freebsd.org/changeset/base/233973 Log: Fix a bug in remquo{,f,l}, in which the quotient didn't always have the correct sign when the remainder was 0. Fix a separate bug in remquo alone, in which the remainder and quotient were both off by a bit in certain cases involving subnormal remainders. The bugs affected all platforms except amd64 and i386, on which the routines are implemented in assembly. PR: 166463 Submitted by: Ilya Burylov MFC after: 2 weeks Modified: head/lib/msun/src/s_remquo.c head/lib/msun/src/s_remquof.c head/lib/msun/src/s_remquol.c Modified: head/lib/msun/src/s_remquo.c ============================================================================== --- head/lib/msun/src/s_remquo.c Sat Apr 7 03:50:24 2012 (r233972) +++ head/lib/msun/src/s_remquo.c Sat Apr 7 03:59:12 2012 (r233973) @@ -51,7 +51,7 @@ remquo(double x, double y, int *quo) goto fixup; /* |x|<|y| return x or x-y */ } if(lx==ly) { - *quo = 1; + *quo = (sxy ? -1 : 1); return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/ } } @@ -114,6 +114,7 @@ remquo(double x, double y, int *quo) /* convert back to floating value and restore the sign */ if((hx|lx)==0) { /* return sign(x)*0 */ + q &= 0x7fffffff; *quo = (sxy ? -q : q); return Zero[(u_int32_t)sx>>31]; } @@ -129,9 +130,9 @@ remquo(double x, double y, int *quo) lx = (lx>>n)|((u_int32_t)hx<<(32-n)); hx >>= n; } else if (n<=31) { - lx = (hx<<(32-n))|(lx>>n); hx = sx; + lx = (hx<<(32-n))|(lx>>n); hx = 0; } else { - lx = hx>>(n-32); hx = sx; + lx = hx>>(n-32); hx = 0; } } fixup: Modified: head/lib/msun/src/s_remquof.c ============================================================================== --- head/lib/msun/src/s_remquof.c Sat Apr 7 03:50:24 2012 (r233972) +++ head/lib/msun/src/s_remquof.c Sat Apr 7 03:59:12 2012 (r233973) @@ -46,7 +46,7 @@ remquof(float x, float y, int *quo) q = 0; goto fixup; /* |x|<|y| return x or x-y */ } else if(hx==hy) { - *quo = 1; + *quo = (sxy ? -1 : 1); return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/ } @@ -88,6 +88,7 @@ remquof(float x, float y, int *quo) /* convert back to floating value and restore the sign */ if(hx==0) { /* return sign(x)*0 */ + q &= 0x7fffffff; *quo = (sxy ? -q : q); return Zero[(u_int32_t)sx>>31]; } Modified: head/lib/msun/src/s_remquol.c ============================================================================== --- head/lib/msun/src/s_remquol.c Sat Apr 7 03:50:24 2012 (r233972) +++ head/lib/msun/src/s_remquol.c Sat Apr 7 03:59:12 2012 (r233973) @@ -96,7 +96,7 @@ remquol(long double x, long double y, in goto fixup; /* |x|<|y| return x or x-y */ } if(ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl) { - *quo = 1; + *quo = (sxy ? -1 : 1); return Zero[sx]; /* |x|=|y| return x*0*/ } } @@ -138,6 +138,7 @@ remquol(long double x, long double y, in /* convert back to floating value and restore the sign */ if((hx|lx)==0) { /* return sign(x)*0 */ + q &= 0x7fffffff; *quo = (sxy ? -q : q); return Zero[sx]; }