This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH]: PR29335 evaluate transcendentals at compile-time using MPFR
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 7 Oct 2006 17:39:28 +0000 (UTC)
- Subject: Re: [PATCH]: PR29335 evaluate transcendentals at compile-time using MPFR
- References: <Pine.GSO.firstname.lastname@example.org>
On Sat, 7 Oct 2006, Kaveh R. GHAZI wrote:
> Here's a proof-of-concept patch for PR middle-end/29335, evaluating
> transcendental functions at compile-time using MPFR.
> It'll depend on whether we include GMP/MPFR in the GCC repository as
> discussed here. We either need to do that or add configure goo to detect
> if we have MPFR. I'm in favor of including GMP/MPFR (but I need help!)
> The patch also needs testcases and more builtin functions to be converted.
> So far it does sin, cos and tan. But I made it very easy to add more, you
> only need a couple of lines of code for each one. The bulk of the work is
> done in do_mpfr_arg1 which should satisfy all one-argument math builtins.
> We can use it as a template for a do_mpfr_arg2 function for two-argument
> builtins when we do pow, etc.
I think doing this is a good idea.
If -frounding-math then it would be safest to disable the folding unless
MPFR tells you that the result is exact for that particular argument.
This is probably more significant for sqrt than for the transcendental
functions, since sqrt is an IEEE 754 operation that should follow the
rounding mode. I think switching the sqrt implementation to use MPFR
would be a good idea, since the present one may not get the last bit right
for IEEE quad long double.
By making the decimal-to-binary conversion of floating-point constants use
MPFR we should be able to fix bug 21718.
Joseph S. Myers