mirror of git://sourceware.org/git/glibc.git
Fix powerpc software sqrtf (bug 17967).
Similarly to sqrt in <https://sourceware.org/ml/libc-alpha/2015-02/msg00353.html>, the powerpc sqrtf implementation for when _ARCH_PPCSQ is not defined also relies on a * b + c being contracted into a fused multiply-add. Although this contraction is not explicitly disabled for e_sqrtf.c, it still seems appropriate to make the file explicit about its requirements by using __builtin_fmaf; this patch does so. Furthermore, it turns out that doing so fixes the observed inaccuracy and missing exceptions (that is, that without explicit __builtin_fmaf usage, it was not being compiled as intended). Tested for powerpc32 (hard float). [BZ #17967] * sysdeps/powerpc/fpu/e_sqrtf.c (__slow_ieee754_sqrtf): Use __builtin_fmaf instead of relying on contraction of a * b + c.
This commit is contained in:
parent
3f293d614c
commit
95c26233a1
|
@ -1,3 +1,9 @@
|
||||||
|
2015-02-13 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
[BZ #17967]
|
||||||
|
* sysdeps/powerpc/fpu/e_sqrtf.c (__slow_ieee754_sqrtf): Use
|
||||||
|
__builtin_fmaf instead of relying on contraction of a * b + c.
|
||||||
|
|
||||||
2015-02-12 J William Piggott <elseifthen@gmx.com>
|
2015-02-12 J William Piggott <elseifthen@gmx.com>
|
||||||
|
|
||||||
[BZ #17969]
|
[BZ #17969]
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -10,7 +10,7 @@ Version 2.22
|
||||||
* The following bugs are resolved with this release:
|
* The following bugs are resolved with this release:
|
||||||
|
|
||||||
4719, 15467, 15790, 16560, 17912, 17932, 17944, 17949, 17964, 17965,
|
4719, 15467, 15790, 16560, 17912, 17932, 17944, 17949, 17964, 17965,
|
||||||
17969.
|
17967, 17969.
|
||||||
|
|
||||||
Version 2.21
|
Version 2.21
|
||||||
|
|
||||||
|
|
|
@ -87,26 +87,28 @@ __slow_ieee754_sqrtf (float x)
|
||||||
/* Here we have three Newton-Raphson iterations each of a
|
/* Here we have three Newton-Raphson iterations each of a
|
||||||
division and a square root and the remainder of the
|
division and a square root and the remainder of the
|
||||||
argument reduction, all interleaved. */
|
argument reduction, all interleaved. */
|
||||||
sd = -(sg * sg - sx);
|
sd = -__builtin_fmaf (sg, sg, -sx);
|
||||||
fsgi = (xi + 0x40000000) >> 1 & 0x7f800000;
|
fsgi = (xi + 0x40000000) >> 1 & 0x7f800000;
|
||||||
sy2 = sy + sy;
|
sy2 = sy + sy;
|
||||||
sg = sy * sd + sg; /* 16-bit approximation to sqrt(sx). */
|
sg = __builtin_fmaf (sy, sd, sg); /* 16-bit approximation to
|
||||||
e = -(sy * sg - almost_half);
|
sqrt(sx). */
|
||||||
|
e = -__builtin_fmaf (sy, sg, -almost_half);
|
||||||
SET_FLOAT_WORD (fsg, fsgi);
|
SET_FLOAT_WORD (fsg, fsgi);
|
||||||
sd = -(sg * sg - sx);
|
sd = -__builtin_fmaf (sg, sg, -sx);
|
||||||
sy = sy + e * sy2;
|
sy = __builtin_fmaf (e, sy2, sy);
|
||||||
if ((xi & 0x7f800000) == 0)
|
if ((xi & 0x7f800000) == 0)
|
||||||
goto denorm;
|
goto denorm;
|
||||||
shx = sx * fsg;
|
shx = sx * fsg;
|
||||||
sg = sg + sy * sd; /* 32-bit approximation to sqrt(sx),
|
sg = __builtin_fmaf (sy, sd, sg); /* 32-bit approximation to
|
||||||
but perhaps rounded incorrectly. */
|
sqrt(sx), but perhaps
|
||||||
|
rounded incorrectly. */
|
||||||
sy2 = sy + sy;
|
sy2 = sy + sy;
|
||||||
g = sg * fsg;
|
g = sg * fsg;
|
||||||
e = -(sy * sg - almost_half);
|
e = -__builtin_fmaf (sy, sg, -almost_half);
|
||||||
d = -(g * sg - shx);
|
d = -__builtin_fmaf (g, sg, -shx);
|
||||||
sy = sy + e * sy2;
|
sy = __builtin_fmaf (e, sy2, sy);
|
||||||
fesetenv_register (fe);
|
fesetenv_register (fe);
|
||||||
return g + sy * d;
|
return __builtin_fmaf (sy, d, g);
|
||||||
denorm:
|
denorm:
|
||||||
/* For denormalised numbers, we normalise, calculate the
|
/* For denormalised numbers, we normalise, calculate the
|
||||||
square root, and return an adjusted result. */
|
square root, and return an adjusted result. */
|
||||||
|
|
Loading…
Reference in New Issue