From owner-freebsd-amd64@FreeBSD.ORG Wed Feb 29 16:03:59 2012 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A50D41065672 for ; Wed, 29 Feb 2012 16:03:59 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by mx1.freebsd.org (Postfix) with ESMTP id 647378FC16 for ; Wed, 29 Feb 2012 16:03:59 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id q1TG3wr2032362; Wed, 29 Feb 2012 08:03:58 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id q1TG3wFe032361; Wed, 29 Feb 2012 08:03:58 -0800 (PST) (envelope-from sgk) Date: Wed, 29 Feb 2012 08:03:58 -0800 From: Steve Kargl To: Bruce Evans Message-ID: <20120229160358.GA32337@troutmask.apl.washington.edu> References: <4F3EA37F.9010207@speakeasy.org> <4F3EC0B4.6050107@speakeasy.org> <4F4DA398.6070703@speakeasy.org> <20120229161408.G2514@besplex.bde.org> <4F4DD942.8070106@speakeasy.org> <20120229191750.Y3167@besplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120229191750.Y3167@besplex.bde.org> User-Agent: Mutt/1.4.2.3i Cc: freebsd-amd64@freebsd.org Subject: Re: Gcc46 and 128 Bit Floating Point X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Feb 2012 16:03:59 -0000 On Wed, Feb 29, 2012 at 07:23:36PM +1100, Bruce Evans wrote: > On Tue, 28 Feb 2012, Thomas D. Dean wrote: > > >On 02/28/12 22:03, Bruce Evans wrote: > >> > >>>#include > >>>#include > >>>int main() { > >>>char buf[128]; > >>>__float128 x = sqrtq(2.0Q); > >>>quadmath_snprintf(buf, sizeof buf, "%.45Qf",x); > >>>printf("sin(%s) = ",buf); > >>>quadmath_snprintf(buf, sizeof buf, "%.45Qf",sinq(x)); > >>>printf("%s\n",buf); > >>>return 0; > >>>} > >>> > >>>gcc46 math.c -o math /usr/local/lib/gcc46/libquadmath.a /usr/lib/libm.a > > > >>objdump -d math | grep fsqrt > > 4014fd: d9 fa fsqrt > > 407bb4: d9 fa fsqrt > > > >Comes from the libs. > > It's not unreasonable in the libraries. A lower-precision sqrt gives > a good place to start for a Newton approximation method. I wouldn't > have expected fsqrt to be a better place to start that a 64-bit sqrt > using SSE though. SSE also provides 32-bit sqrt and an even > lower-precision but much faster reciprocal square root to start from. > >From libquadmath/math/sqrtq.c if (x <= DBL_MAX && x >= DBL_MIN) { /* Use double result as starting point. */ y = sqrt ((double) x); /* Two Newton iterations. */ y -= 0.5q * (y - x / y); y -= 0.5q * (y - x / y); return y; } This probably explains the presences of fsqrt. There's a similar block for LDBL_MAX and LDBL_MIN. -- Steve