Bug 92463 - Cleanups due to minimum MPFR version bump to 3.1.0
Summary: Cleanups due to minimum MPFR version bump to 3.1.0
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: go (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords: internal-improvement
Depends on: 91828
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-11 19:01 UTC by Janne Blomqvist
Modified: 2020-01-27 20:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-01-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janne Blomqvist 2019-11-11 19:01:25 UTC
As part of resolving PR 91828, the minimum MPFR version required to build GCC was bumped to 3.1.0 from the previous 2.4.0. 

This enables a bunch of cleanups, mostly in the Fortran frontend (hence assigning this bug to the fortran component).

From https://gcc.gnu.org/ml/gcc-patches/2016-04/msg01544.html :

> For example, you could justify a move to requiring MPFR 3.0.0 or later 
with cleanups to use MPFR_RND* instead of the older GMP_RND*, and 
similarly mpfr_rnd_t instead of the older mp_rnd_t and likewise mpfr_exp_t 
and mpfr_prec_t in fortran/.  You could justify a move to requiring MPC 
1.0.0 (or 1.0.2) by optimizing clog10 using mpc_log10.  I don't know what 
if any newer GMP interfaces would be beneficial in GCC.  And as always in 
such cases, it's a good idea to look at e.g. how widespread the newer 
versions are in GNU/Linux distributions, which indicates how many people 
might be affected by an increase in the version requirement.
Comment 1 Janne Blomqvist 2019-11-14 20:23:06 UTC
Seems r269139 can be reverted, that's apparently a patch to fix some accidental breakage due to depending on a too new MPFR version.
Comment 2 Janne Blomqvist 2019-11-20 20:01:56 UTC
Author: jb
Date: Wed Nov 20 20:01:25 2019
New Revision: 278523

URL: https://gcc.gnu.org/viewcvs?rev=278523&root=gcc&view=rev
Log:
PR 92463 MPFR modernization in GFortran

Now that we require a minimum of MPFR 3.1.0+ to build GCC, we can do
some modernization of the MPFR usage in the GFortran frontend.

This patch replaces

1) GMP_RND* with MPFR_RND*

2) mp_exp_t with mpfr_exp_t

3) mp_prec_t with mpfr_prec_t

4) mp_rnd_t with mpfr_rnd_t

gcc/fortran/ChangeLog:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/92463
	* arith.c (gfc_mpfr_to_mpz): Change mp_exp_t to mpfr_exp_t.
	(gfc_check_real_range): Likewise.
	* gfortran.h (GFC_RND_MODE): Change GMP_RNDN to MPFR_RNDN.
	* module.c (mio_gmp_real): Change mp_exp_t to mpfr_exp_t.
	* simplify.c (degrees_f): Change mp_rnd_t to mpfr_rnd_t.
	(radians_f): Likewise.
	(fullprec_erfc_scaled): Change mp_prec_t to mpfr_prec_t.
	(asympt_erfc_scaled): Likewise.
	(gfc_simplify_nearest): Change mp_exp_t to mpfr_exp_t, and
	GMP_RND* to MPFR_RND*.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/arith.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/simplify.c
Comment 3 Janne Blomqvist 2019-11-20 20:09:00 UTC
Author: jb
Date: Wed Nov 20 20:08:29 2019
New Revision: 278525

URL: https://gcc.gnu.org/viewcvs?rev=278525&root=gcc&view=rev
Log:
PR 92463 MPFR modernization: Revert r269139

Commit r269139 fixed an accidental dependency on MPFR 3.0. As we now
require at least MPFR 3.1.0+ we can revert it and instead use the
simpler MPFR 3.0+ code.

ChangeLog entry of the original commit was:

2019-02-23  David Malcolm  <dmalcolm@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>

        PR middle-end/88074
        * simplify.c (norm2_do_sqrt, gfc_simplify_norm2): Use
        mpfr_number_p && !mpfr_zero_p instead of mpfr_regular_p.
        (norm2_add_squared): Likewise.  Use mp_exp_t rather than mpfr_exp_t.

ChangeLog for this commit:

2019-11-20  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/92463
	Revert r269139
	* simplify.c (norm2_do_sqrt, gfc_simplify_norm2): Use
	mpfr_regular_p instead of mpfr_number_p && !mpfr_zero_p.
	(norm2_add_squared): Likewise.  Use mpfr_exp_t rather than
	mp_exp_t.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/simplify.c
Comment 4 Janne Blomqvist 2019-11-20 21:39:13 UTC
Fortran parts done, reassigning to middle-end as there are similar MPFR modernization opportunities there.
Comment 5 Tobias Burnus 2019-11-21 08:34:58 UTC
(In reply to Janne Blomqvist from comment #4)
> Fortran parts done, reassigning to middle-end as there are similar MPFR
> modernization opportunities there.

See also https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01969.html for grep for the files where the type changes should be applied.

Background: r278058 changed the minimal version from 2.4.0 to 3.1.0.
The main changes are listed at https://www.mpfr.org/mpfr-3.0.0/#changes
and https://www.mpfr.org/mpfr-3.1.0/#changes

At a glance, I did not see function-call changes but I did just a simple grep with glancing at the code. New but probably not needed is a function to set zero (with + or - sign) and rounding away from zero (see MPFR changes linked above).
Comment 6 Tobias Burnus 2019-11-27 09:16:56 UTC
Author: burnus
Date: Wed Nov 27 09:16:24 2019
New Revision: 278761

URL: https://gcc.gnu.org/viewcvs?rev=278761&root=gcc&view=rev
Log:
PR 92463 - Cleanups due to minimum MPFR version bump to 3.1.0

        PR middle-end/92463
        * configure.ac: Use MPFR_RNDN instead of GMP's MP_RNDN.
        * configure: Regenerate

        gcc/
        PR middle-end/92463
        * builtins.c (do_mpfr_ckconv, do_mpc_ckconv, do_mpfr_remquo,
        do_mpfr_lgamma_r, do_mpc_arg2): Use MPFR_RNDx instead of GMP_RNDx,
        mpfr_rnd_t instead of mp_rnd_t.
        * fold-const-call.c (do_mpfr_ckconv, do_mpfr_arg1, do_mpfr_sincos,
        do_mpfr_arg2, do_mpfr_arg3, do_mpc_arg1, do_mpc_arg2): Likewise.
        * gimple-ssa-sprintf.c (format_floating_max, format_floating):
        Use mpfr_exp_t instead of mp_exp_t.
        * real.c (real_from_string, dconst_e_ptr, dconst_sqrt2_ptr): Use
        MPFR_RNDx instead of GMP_RNDx.
        * realmpfr.c (real_from_mpfr, mpfr_from_real): Use mpfr_rnd_t and
        mpfr_exp_t instead mp_rnd_t and mp_exp_t, respectively.
        * realmpfr.h (real_from_mpfr, mpfr_from_real): Use mpfr_rnd_t instead
        of mp_rnd_t and remove MPFR_RNDx poisoning.
        * ubsan.c (ubsan_instrument_float_cast): MPFR_RNDx instead of GMP_RNDx.

        fortran/
        PR middle-end/92463
        * arith.c (gfc_check_real_range): Replace mp_exp_t by mpfr_exp_t.


Modified:
    trunk/ChangeLog
    trunk/configure
    trunk/configure.ac
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/fold-const-call.c
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/arith.c
    trunk/gcc/gimple-ssa-sprintf.c
    trunk/gcc/real.c
    trunk/gcc/realmpfr.c
    trunk/gcc/realmpfr.h
    trunk/gcc/ubsan.c
Comment 7 Tobias Burnus 2019-11-27 09:19:17 UTC
The middle end is fixed – The Go front end remains – but won't be tackled by me.
Re-assign to the 'Go' component.
Comment 8 CVS Commits 2020-01-27 20:30:27 UTC
The master branch has been updated by Ian Lance Taylor <ian@gcc.gnu.org>:

https://gcc.gnu.org/g:2f195832a12ff4fb54d723f32019d4175db1b5da

commit r10-6267-g2f195832a12ff4fb54d723f32019d4175db1b5da
Author: Ian Lance Taylor <iant@golang.org>
Date:   Fri Jan 24 12:39:23 2020 -0800

    compiler: cleanups permitted by GCC requirement of MPFR 3.1.0
    
    For MPFR functions, change from GMP_RND* to MPFR_RND*.
    Also change mp_exp_t to mpfr_expt_t.
    
    Fixes PR go/92463
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216417
Comment 9 Ian Lance Taylor 2020-01-27 20:32:43 UTC
Go frontend is fixed.