Implement fma in soft-fp
Joseph S. Myers
joseph@codesourcery.com
Tue Jun 25 17:53:00 GMT 2013
On Tue, 25 Jun 2013, Richard Henderson wrote:
> With the following patch, I get
>
> > testing long double (without inline functions)
> > Failure: fma (0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, 0x1p-16494): Exception "Underflow" set
> > Failure: fma (-0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, -0x1p-16494): Exception "Underflow" set
> > Failure: fma (0x1p-16494, -0x1p-16494, 0x1p-16382): Exception "Underflow" set
> > Failure: fma (0x1p-16494, 0x1p-16494, -0x1p-16382): Exception "Underflow" set
> > Failure: fma_downward (-0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, -0x1p-16494): Exception "Underflow" set
> > Failure: fma_downward (-0x1p-16494, 0x1.1p-1, -0x0.ffffffffffffffffffffffffffffp-16382): Exception "Underflow" set
> > Failure: fma_downward (0x1p-16494, 0x1p-16494, -0x1p-16382): Exception "Underflow" set
> > Failure: fma_upward (0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, 0x1p-16494): Exception "Underflow" set
> > Failure: fma_upward (0x1p-16494, 0x1.1p-1, 0x0.ffffffffffffffffffffffffffffp-16382): Exception "Underflow" set
> > Failure: fma_upward (0x1p-16494, -0x1p-16494, 0x1p-16382): Exception "Underflow" set
>
> but I thought you'd already committed the patch to solve this
> as commit 695c378f81263640618bdebf56eaa065f578251f ?
No, that fix was about incorrect results rather than exceptions. The
above is what I was referring to about soft-fp not supporting
after-rounding tininess detection. _FP_PACK_SEMIRAW and
_FP_PACK_CANONICAL will need, for results whose before-rounding exponent
is the largest underflowing exponent, to check some new soft-fp macro for
after-rounding architectures and if it's true then determine whether the
result would still underflow if rounded to the normal precision (*not* if
rounded to the subnormal precision with one less bit, so this involves an
extra trial rounding in a temporary variable to determine whether the
result counts as tiny). See what stdlib/strtod_l.c does in
round_and_return if (TININESS_AFTER_ROUNDING && shift == 1), for example.
(But soft-fp would use its own macro definition from sfp-machine.h instead
of the existing tininess.h since it's supposed to be usable outside glibc
and independent of glibc internal headers.)
MIPS is an after-rounding architecture but this issue doesn't cause test
failures there because the testsuite knows not to test exceptions for MIPS
software floating point (which uses fp-bit in libgcc), via math-tests.h.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list