This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] RFC for patch to add C99 fma/fmaf/fmal builtins
On Tue, 5 Oct 2010, Geert Bosch wrote:
> An algorithm for the correctly rounded FMA using just regular floating
> point instructions has been published in the IEEE TRANSACTIONS ON
> COMPUTERS, VOL. 57, NO. 4, APRIL 2008. There is no real short-cut
Is this FMA for all rounding modes, or for round-to-nearest only? I
didn't see a clear statement of this in a quick look over that paper.
> Still, I think it would be good in general for GCC to have such arithmetic
> functions in its libgcc. The reason is that they are still self-contained,
> relatively simple pure functions of their arguments, and it just doesn't
> make sense having GCC do the compile-time evaluation of this function
> correctly, but not the run-time evaluation.
Typically such algorithms require setting round-to-nearest for
intermediate computations, saving the previous exception state, and
restoring exception state (and rounding mode) just before the end to avoid
raising spurious exceptions. These things are tricky to do in libgcc,
which must not depend on libm (where the fenv.h functions are located).
--
Joseph S. Myers
joseph@codesourcery.com