[Bug middle-end/29335] transcendental functions with constant arguments should be resolved at compile-time

kargl at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Oct 6 14:40:00 GMT 2006



------- Comment #4 from kargl at gcc dot gnu dot org  2006-10-06 14:40 -------
(In reply to comment #3)
> (In reply to comment #2)
>> (In reply to comment #0)
>>> 
>>> 1.  Whether a certain minimum version of GMP/MPFR is required to
>>> avoid known bugs, etc.
>> See my recent patch to toplevel configure.in.  THe minimum required 
>> versions should be gmp-4.1.x and mpfr-2.2.0.
> 
> I see that, but when configure detects the "broken" mpfr, it just prints
> out a message and proceeds happily.  It doesn't disable anything. (???)

It's simply a warning to a user that there are known problems with the
version of MPFR on the system.  gfortran will work correctly with the
buggy mpfr with the exception of some corner cases and PRs that I've
fixed using newer features.  In particular, there are problems with
the old hackish way that gfortran handled subnormal numbers.  gfortran
also uses functions that are in 2.2.0 that are not available in some
of the older versions.

See simplify.c(gfc_simplify_nearest).

>> If you haven't read fortran/{arith.c,simplify.c}, then I'd suggest
>> that you take a look to see what gmp/mpfr can do.
> 
> I looked through those and read through the mpfr docs so I think I have a good
> idea of what mpfr can do.  My main area of concern right now is converting
> between gcc's REAL_VALUE_TYPE and mpfr_t.  I found gfc_conv_mpfr_to_tree() in
> trans-const.c which uses a string as an intermediate type, is that the most
> efficient way to convert?

I didn't write that function, and so I have experimented with a replacement.
There is mpfr_get_ld(), which converts to a long double.  If the data type
never exceeds the properties of long double, then one may be able to
use mpfr_get_ld() and then fold_convert() the result to the proper type.

> Also where is the function that does the reverse,
> i.e. tree or REAL_VALUE_TYPE to mpfr_t?

gfortran doesn't have a need of going in the opposite direction.
gmp/mpfr are used in the frontend for the internal representation
of data types.  By the time gfortran reaches the functions in
trans-*.c, it has done all the constant folding and manipulation
of the data types that it can.  The trans-*.c functions simply
convert gfortran's black and red trees into the tree-ssa form.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29335



More information about the Gcc-bugs mailing list