This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: PR29335 use MPFR for builtins fma, fmin and fmax

On Tue, 7 Nov 2006, Andrew Pinski wrote:

> Do you know how much precision fma gets for mpfr?
> Andrew Pinski

My understanding is that mpfr is supposed to always yield exact (AKA
correctly) rounded results for the requested precision.  For the case of
fma, here's the code that implements it:

  /* if we take prec(u) >= prec(x) + prec(y), the product
     u <- x*y is always exact */
  mpfr_init2 (u, MPFR_PREC(x) + MPFR_PREC(y));
  mpfr_mul (u, x, y, GMP_RNDN); /* always exact */
  inexact = mpfr_add (s, z, u, rnd_mode);

In this case x, y and z are the supplied args and they all have a
precision of the underlying types (float, double or long double.)

We see that u is given a precision equal to prec(x) + prec(y), which is
supposed to allow the multiplication x*y to be exact.  The addition of z
occurs in the precision of the resulting type (again float, double, long
double) and that is rounded once.  I believe that's as good as you can

Kaveh R. Ghazi

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]