Gcc46 and 128 Bit Floating Point
Steve Kargl
sgk at troutmask.apl.washington.edu
Wed Feb 29 16:03:59 UTC 2012
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 <quadmath.h>
> >>>#include <stdio.h>
> >>>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
More information about the freebsd-amd64
mailing list