diff mbox series

PR 92463 - Cleanups due to minimum MPFR version bump to 3.1.0

Message ID 2a338982-99cb-cc33-ab2b-f11a095296d1@codesourcery.com
State New
Headers show
Series PR 92463 - Cleanups due to minimum MPFR version bump to 3.1.0 | expand

Commit Message

Tobias Burnus Nov. 26, 2019, 9:42 p.m. UTC
Recently, Janne bumped the minimal MPFR version from 2.4 to 3.1. As a 
follow-up cleanup, the mp_ data types can now be changed to mpfr_ and 
GMP_RNDx rounding to MPFR_RNDx (with an additional MPFR_RNDA).

This patch changes the types in the middle end and a left over from 
previous patch round in Fortran. However, I have not touched the MPFR 
users in GO.

See https://www.mpfr.org/mpfr-3.0.0/#changes for the 2.4 to 3.0 changes. 
("mp_rnd_t may be removed in the future").

Bootstrapped and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

Comments

Janne Blomqvist Nov. 27, 2019, 8:08 a.m. UTC | #1
On Tue, Nov 26, 2019 at 11:42 PM Tobias Burnus <tobias@codesourcery.com> wrote:
>
> Recently, Janne bumped the minimal MPFR version from 2.4 to 3.1. As a
> follow-up cleanup, the mp_ data types can now be changed to mpfr_ and
> GMP_RNDx rounding to MPFR_RNDx (with an additional MPFR_RNDA).
>
> This patch changes the types in the middle end and a left over from
> previous patch round in Fortran. However, I have not touched the MPFR
> users in GO.
>
> See https://www.mpfr.org/mpfr-3.0.0/#changes for the 2.4 to 3.0 changes.
> ("mp_rnd_t may be removed in the future").
>
> Bootstrapped and regtested on x86-64-gnu-linux.
> OK for the trunk?

Fortran part is obviously Ok (sorry I missed that one in my previous patch).

For realmpfr.h, should we additionally poison GMP_RNDx to make sure we
don't accidentally add back uses of it?

Rest of the patch looks Ok, though not being a global reviewer I can't
approve it.
Richard Biener Nov. 27, 2019, 8:44 a.m. UTC | #2
On Tue, Nov 26, 2019 at 10:43 PM Tobias Burnus <tobias@codesourcery.com> wrote:
>
> Recently, Janne bumped the minimal MPFR version from 2.4 to 3.1. As a
> follow-up cleanup, the mp_ data types can now be changed to mpfr_ and
> GMP_RNDx rounding to MPFR_RNDx (with an additional MPFR_RNDA).
>
> This patch changes the types in the middle end and a left over from
> previous patch round in Fortran. However, I have not touched the MPFR
> users in GO.
>
> See https://www.mpfr.org/mpfr-3.0.0/#changes for the 2.4 to 3.0 changes.
> ("mp_rnd_t may be removed in the future").
>
> Bootstrapped and regtested on x86-64-gnu-linux.
> OK for the trunk?

OK.

Thanks,
Richard.

>
> Tobias
>
diff mbox series

Patch

	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.

diff --git a/configure b/configure
index 00f7487e2e9..f6027397ced 100755
--- a/configure
+++ b/configure
@@ -5865,9 +5865,9 @@  main ()
     int t;
     mpfr_init (n);
     mpfr_init (x);
-    mpfr_atan2 (n, n, x, GMP_RNDN);
-    mpfr_erfc (n, x, GMP_RNDN);
-    mpfr_subnormalize (x, t, GMP_RNDN);
+    mpfr_atan2 (n, n, x, MPFR_RNDN);
+    mpfr_erfc (n, x, MPFR_RNDN);
+    mpfr_subnormalize (x, t, MPFR_RNDN);
     mpfr_clear(n);
     mpfr_clear(x);
     mpc_init2 (c, 53);
diff --git a/configure.ac b/configure.ac
index 29e25f13278..50e2fa135b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1641,9 +1641,9 @@  if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
     int t;
     mpfr_init (n);
     mpfr_init (x);
-    mpfr_atan2 (n, n, x, GMP_RNDN);
-    mpfr_erfc (n, x, GMP_RNDN);
-    mpfr_subnormalize (x, t, GMP_RNDN);
+    mpfr_atan2 (n, n, x, MPFR_RNDN);
+    mpfr_erfc (n, x, MPFR_RNDN);
+    mpfr_subnormalize (x, t, MPFR_RNDN);
     mpfr_clear(n);
     mpfr_clear(x);
     mpc_init2 (c, 53);
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 8296d846171..36319a97b52 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -11045,7 +11045,7 @@  do_mpfr_ckconv (mpfr_srcptr m, tree type, int inexact)
     {
       REAL_VALUE_TYPE rr;
 
-      real_from_mpfr (&rr, m, type, GMP_RNDN);
+      real_from_mpfr (&rr, m, type, MPFR_RNDN);
       /* Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR value,
 	 check for overflow/underflow.  If the REAL_VALUE_TYPE is zero
 	 but the mpft_t is not, then we underflowed in the
@@ -11085,8 +11085,8 @@  do_mpc_ckconv (mpc_srcptr m, tree type, int inexact, int force_convert)
     {
       REAL_VALUE_TYPE re, im;
 
-      real_from_mpfr (&re, mpc_realref (m), TREE_TYPE (type), GMP_RNDN);
-      real_from_mpfr (&im, mpc_imagref (m), TREE_TYPE (type), GMP_RNDN);
+      real_from_mpfr (&re, mpc_realref (m), TREE_TYPE (type), MPFR_RNDN);
+      real_from_mpfr (&im, mpc_imagref (m), TREE_TYPE (type), MPFR_RNDN);
       /* Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR values,
 	 check for overflow/underflow.  If the REAL_VALUE_TYPE is zero
 	 but the mpft_t is not, then we underflowed in the
@@ -11138,14 +11138,14 @@  do_mpfr_remquo (tree arg0, tree arg1, tree arg_quo)
         {
 	  const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type));
 	  const int prec = fmt->p;
-	  const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN;
+	  const mpfr_rnd_t rnd = fmt->round_towards_zero? MPFR_RNDZ : MPFR_RNDN;
 	  tree result_rem;
 	  long integer_quo;
 	  mpfr_t m0, m1;
 
 	  mpfr_inits2 (prec, m0, m1, NULL);
-	  mpfr_from_real (m0, ra0, GMP_RNDN);
-	  mpfr_from_real (m1, ra1, GMP_RNDN);
+	  mpfr_from_real (m0, ra0, MPFR_RNDN);
+	  mpfr_from_real (m1, ra1, MPFR_RNDN);
 	  mpfr_clear_flags ();
 	  mpfr_remquo (m0, &integer_quo, m0, m1, rnd);
 	  /* Remquo is independent of the rounding mode, so pass
@@ -11218,13 +11218,13 @@  do_mpfr_lgamma_r (tree arg, tree arg_sg, tree type)
         {
 	  const struct real_format *fmt = REAL_MODE_FORMAT (TYPE_MODE (type));
 	  const int prec = fmt->p;
-	  const mp_rnd_t rnd = fmt->round_towards_zero? GMP_RNDZ : GMP_RNDN;
+	  const mpfr_rnd_t rnd = fmt->round_towards_zero? MPFR_RNDZ : MPFR_RNDN;
 	  int inexact, sg;
 	  mpfr_t m;
 	  tree result_lg;
 
 	  mpfr_init2 (m, prec);
-	  mpfr_from_real (m, ra, GMP_RNDN);
+	  mpfr_from_real (m, ra, MPFR_RNDN);
 	  mpfr_clear_flags ();
 	  inexact = mpfr_lgamma (m, &sg, m, rnd);
 	  result_lg = do_mpfr_ckconv (m, type, inexact);
@@ -11287,7 +11287,8 @@  do_mpc_arg2 (tree arg0, tree arg1, tree type, int do_nonfinite,
 	  const struct real_format *const fmt =
 	    REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (type)));
 	  const int prec = fmt->p;
-	  const mp_rnd_t rnd = fmt->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+	  const mpfr_rnd_t rnd = fmt->round_towards_zero
+				 ? MPFR_RNDZ : MPFR_RNDN;
 	  const mpc_rnd_t crnd = fmt->round_towards_zero ? MPC_RNDZZ : MPC_RNDNN;
 	  int inexact;
 	  mpc_t m0, m1;
diff --git a/gcc/fold-const-call.c b/gcc/fold-const-call.c
index 3a14d2a41c1..c4f52fb3c15 100644
--- a/gcc/fold-const-call.c
+++ b/gcc/fold-const-call.c
@@ -99,7 +99,7 @@  do_mpfr_ckconv (real_value *result, mpfr_srcptr m, bool inexact,
     return false;
 
   REAL_VALUE_TYPE tmp;
-  real_from_mpfr (&tmp, m, format, GMP_RNDN);
+  real_from_mpfr (&tmp, m, format, MPFR_RNDN);
 
   /* Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR values.
      If the REAL_VALUE_TYPE is zero but the mpft_t is not, then we
@@ -130,11 +130,11 @@  do_mpfr_arg1 (real_value *result,
     return false;
 
   int prec = format->p;
-  mp_rnd_t rnd = format->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+  mpfr_rnd_t rnd = format->round_towards_zero ? MPFR_RNDZ : MPFR_RNDN;
   mpfr_t m;
 
   mpfr_init2 (m, prec);
-  mpfr_from_real (m, arg, GMP_RNDN);
+  mpfr_from_real (m, arg, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = func (m, m, rnd);
   bool ok = do_mpfr_ckconv (result, m, inexact, format);
@@ -160,11 +160,11 @@  do_mpfr_sincos (real_value *result_sin, real_value *result_cos,
     return false;
 
   int prec = format->p;
-  mp_rnd_t rnd = format->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+  mpfr_rnd_t rnd = format->round_towards_zero ? MPFR_RNDZ : MPFR_RNDN;
   mpfr_t m, ms, mc;
 
   mpfr_inits2 (prec, m, ms, mc, NULL);
-  mpfr_from_real (m, arg, GMP_RNDN);
+  mpfr_from_real (m, arg, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = mpfr_sin_cos (ms, mc, m, rnd);
   bool ok = (do_mpfr_ckconv (result_sin, ms, inexact, format)
@@ -193,12 +193,12 @@  do_mpfr_arg2 (real_value *result,
     return false;
 
   int prec = format->p;
-  mp_rnd_t rnd = format->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+  mpfr_rnd_t rnd = format->round_towards_zero ? MPFR_RNDZ : MPFR_RNDN;
   mpfr_t m0, m1;
 
   mpfr_inits2 (prec, m0, m1, NULL);
-  mpfr_from_real (m0, arg0, GMP_RNDN);
-  mpfr_from_real (m1, arg1, GMP_RNDN);
+  mpfr_from_real (m0, arg0, MPFR_RNDN);
+  mpfr_from_real (m1, arg1, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = func (m0, m0, m1, rnd);
   bool ok = do_mpfr_ckconv (result, m0, inexact, format);
@@ -216,7 +216,7 @@  do_mpfr_arg2 (real_value *result,
 
 static bool
 do_mpfr_arg2 (real_value *result,
-	      int (*func) (mpfr_ptr, long, mpfr_srcptr, mp_rnd_t),
+	      int (*func) (mpfr_ptr, long, mpfr_srcptr, mpfr_rnd_t),
 	      const wide_int_ref &arg0, const real_value *arg1,
 	      const real_format *format)
 {
@@ -224,11 +224,11 @@  do_mpfr_arg2 (real_value *result,
     return false;
 
   int prec = format->p;
-  mp_rnd_t rnd = format->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+  mpfr_rnd_t rnd = format->round_towards_zero ? MPFR_RNDZ : MPFR_RNDN;
   mpfr_t m;
 
   mpfr_init2 (m, prec);
-  mpfr_from_real (m, arg1, GMP_RNDN);
+  mpfr_from_real (m, arg1, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = func (m, arg0.to_shwi (), m, rnd);
   bool ok = do_mpfr_ckconv (result, m, inexact, format);
@@ -260,13 +260,13 @@  do_mpfr_arg3 (real_value *result,
     return false;
 
   int prec = format->p;
-  mp_rnd_t rnd = format->round_towards_zero ? GMP_RNDZ : GMP_RNDN;
+  mpfr_rnd_t rnd = format->round_towards_zero ? MPFR_RNDZ : MPFR_RNDN;
   mpfr_t m0, m1, m2;
 
   mpfr_inits2 (prec, m0, m1, m2, NULL);
-  mpfr_from_real (m0, arg0, GMP_RNDN);
-  mpfr_from_real (m1, arg1, GMP_RNDN);
-  mpfr_from_real (m2, arg2, GMP_RNDN);
+  mpfr_from_real (m0, arg0, MPFR_RNDN);
+  mpfr_from_real (m1, arg1, MPFR_RNDN);
+  mpfr_from_real (m2, arg2, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = func (m0, m0, m1, m2, rnd);
   bool ok = do_mpfr_ckconv (result, m0, inexact, format);
@@ -296,8 +296,8 @@  do_mpc_ckconv (real_value *result_real, real_value *result_imag,
     return false;
 
   REAL_VALUE_TYPE tmp_real, tmp_imag;
-  real_from_mpfr (&tmp_real, mpc_realref (m), format, GMP_RNDN);
-  real_from_mpfr (&tmp_imag, mpc_imagref (m), format, GMP_RNDN);
+  real_from_mpfr (&tmp_real, mpc_realref (m), format, MPFR_RNDN);
+  real_from_mpfr (&tmp_imag, mpc_imagref (m), format, MPFR_RNDN);
 
   /* Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR values.
      If the REAL_VALUE_TYPE is zero but the mpft_t is not, then we
@@ -341,8 +341,8 @@  do_mpc_arg1 (real_value *result_real, real_value *result_imag,
   mpc_t m;
 
   mpc_init2 (m, prec);
-  mpfr_from_real (mpc_realref (m), arg_real, GMP_RNDN);
-  mpfr_from_real (mpc_imagref (m), arg_imag, GMP_RNDN);
+  mpfr_from_real (mpc_realref (m), arg_real, MPFR_RNDN);
+  mpfr_from_real (mpc_imagref (m), arg_imag, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = func (m, m, crnd);
   bool ok = do_mpc_ckconv (result_real, result_imag, m, inexact, format);
@@ -378,10 +378,10 @@  do_mpc_arg2 (real_value *result_real, real_value *result_imag,
 
   mpc_init2 (m0, prec);
   mpc_init2 (m1, prec);
-  mpfr_from_real (mpc_realref (m0), arg0_real, GMP_RNDN);
-  mpfr_from_real (mpc_imagref (m0), arg0_imag, GMP_RNDN);
-  mpfr_from_real (mpc_realref (m1), arg1_real, GMP_RNDN);
-  mpfr_from_real (mpc_imagref (m1), arg1_imag, GMP_RNDN);
+  mpfr_from_real (mpc_realref (m0), arg0_real, MPFR_RNDN);
+  mpfr_from_real (mpc_imagref (m0), arg0_imag, MPFR_RNDN);
+  mpfr_from_real (mpc_realref (m1), arg1_real, MPFR_RNDN);
+  mpfr_from_real (mpc_imagref (m1), arg1_imag, MPFR_RNDN);
   mpfr_clear_flags ();
   bool inexact = func (m0, m0, m1, crnd);
   bool ok = do_mpc_ckconv (result_real, result_imag, m0, inexact, format);
diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c
index cf480779709..7f048da9583 100644
--- a/gcc/fortran/arith.c
+++ b/gcc/fortran/arith.c
@@ -385,8 +385,8 @@  gfc_check_real_range (mpfr_t p, int kind)
 
       /* Set emin and emax for the current model number.  */
       en = gfc_real_kinds[i].min_exponent - gfc_real_kinds[i].digits + 1;
-      mpfr_set_emin ((mp_exp_t) en);
-      mpfr_set_emax ((mp_exp_t) gfc_real_kinds[i].max_exponent);
+      mpfr_set_emin ((mpfr_exp_t) en);
+      mpfr_set_emax ((mpfr_exp_t) gfc_real_kinds[i].max_exponent);
       mpfr_check_range (q, 0, GFC_RND_MODE);
       mpfr_subnormalize (q, 0, GFC_RND_MODE);
 
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 804a0867587..2bbb2b37ac3 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -1606,7 +1606,7 @@  format_floating_max (tree type, char spec, HOST_WIDE_INT prec)
      round-to-nearest mode.  */
   mpfr_t x;
   mpfr_init2 (x, rfmt->p);
-  mpfr_from_real (x, &rv, GMP_RNDN);
+  mpfr_from_real (x, &rv, MPFR_RNDN);
 
   /* Return a value one greater to account for the leading minus sign.  */
   unsigned HOST_WIDE_INT r
@@ -1953,7 +1953,7 @@  format_floating (const directive &dir, tree arg, const vr_values *)
 	   rounding in either direction can result in longer output.  */
 	mpfr_t mpfrval;
 	mpfr_init2 (mpfrval, rfmt->p);
-	mpfr_from_real (mpfrval, rvp, i ? GMP_RNDU : GMP_RNDD);
+	mpfr_from_real (mpfrval, rvp, i ? MPFR_RNDU : MPFR_RNDD);
 
 	/* Use the MPFR rounding specifier to round down in the first
 	   iteration and then up.  In most but not all cases this will
diff --git a/gcc/real.c b/gcc/real.c
index 90067f0087b..134240a6be9 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -2104,7 +2104,7 @@  real_from_string (REAL_VALUE_TYPE *r, const char *str)
 
       /* Nonzero value, possibly overflowing or underflowing.  */
       mpfr_init2 (m, SIGNIFICAND_BITS);
-      inexact = mpfr_strtofr (m, str, NULL, 10, GMP_RNDZ);
+      inexact = mpfr_strtofr (m, str, NULL, 10, MPFR_RNDZ);
       /* The result should never be a NaN, and because the rounding is
 	 toward zero should never be an infinity.  */
       gcc_assert (!mpfr_nan_p (m) && !mpfr_inf_p (m));
@@ -2120,7 +2120,7 @@  real_from_string (REAL_VALUE_TYPE *r, const char *str)
 	}
       else
 	{
-	  real_from_mpfr (r, m, NULL_TREE, GMP_RNDZ);
+	  real_from_mpfr (r, m, NULL_TREE, MPFR_RNDZ);
 	  /* 1 to 3 bits may have been shifted off (with a sticky bit)
 	     because the hex digits used in real_from_mpfr did not
 	     start with a digit 8 to f, but the exponent bounds above
@@ -2431,9 +2431,9 @@  dconst_e_ptr (void)
     {
       mpfr_t m;
       mpfr_init2 (m, SIGNIFICAND_BITS);
-      mpfr_set_ui (m, 1, GMP_RNDN);
-      mpfr_exp (m, m, GMP_RNDN);
-      real_from_mpfr (&value, m, NULL_TREE, GMP_RNDN);
+      mpfr_set_ui (m, 1, MPFR_RNDN);
+      mpfr_exp (m, m, MPFR_RNDN);
+      real_from_mpfr (&value, m, NULL_TREE, MPFR_RNDN);
       mpfr_clear (m);
 
     }
@@ -2474,8 +2474,8 @@  dconst_sqrt2_ptr (void)
     {
       mpfr_t m;
       mpfr_init2 (m, SIGNIFICAND_BITS);
-      mpfr_sqrt_ui (m, 2, GMP_RNDN);
-      real_from_mpfr (&value, m, NULL_TREE, GMP_RNDN);
+      mpfr_sqrt_ui (m, 2, MPFR_RNDN);
+      real_from_mpfr (&value, m, NULL_TREE, MPFR_RNDN);
       mpfr_clear (m);
     }
   return &value;
@@ -5410,13 +5410,13 @@  build_sinatan_real (REAL_VALUE_TYPE * r, tree type)
 
   mpfr_inits (mpfr_const1, mpfr_c, mpfr_maxval, NULL);
 
-  mpfr_from_real (mpfr_const1, &dconst1, GMP_RNDN);
-  mpfr_from_real (mpfr_maxval, &maxval,  GMP_RNDN);
+  mpfr_from_real (mpfr_const1, &dconst1, MPFR_RNDN);
+  mpfr_from_real (mpfr_maxval, &maxval,  MPFR_RNDN);
 
-  mpfr_sub (mpfr_c, mpfr_maxval, mpfr_const1, GMP_RNDN);
-  mpfr_sqrt (mpfr_c, mpfr_c, GMP_RNDZ);
+  mpfr_sub (mpfr_c, mpfr_maxval, mpfr_const1, MPFR_RNDN);
+  mpfr_sqrt (mpfr_c, mpfr_c, MPFR_RNDZ);
 
-  real_from_mpfr (r, mpfr_c, fmt, GMP_RNDZ);
+  real_from_mpfr (r, mpfr_c, fmt, MPFR_RNDZ);
   
   mpfr_clears (mpfr_const1, mpfr_c, mpfr_maxval, NULL);
 }
diff --git a/gcc/realmpfr.c b/gcc/realmpfr.c
index 39f9fa1333b..a760ae124c3 100644
--- a/gcc/realmpfr.c
+++ b/gcc/realmpfr.c
@@ -28,7 +28,7 @@ 
    for initializing and clearing the MPFR parameter.  */
 
 void
-mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mp_rnd_t rndmode)
+mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mpfr_rnd_t rndmode)
 {
   /* We use a string as an intermediate type.  */
   char buf[128];
@@ -59,11 +59,11 @@  mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mp_rnd_t rndmode)
 
 void
 real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, const real_format *format,
-		mp_rnd_t rndmode)
+		mpfr_rnd_t rndmode)
 {
   /* We use a string as an intermediate type.  */
   char buf[128], *rstr;
-  mp_exp_t exp;
+  mpfr_exp_t exp;
 
   /* Take care of Infinity and NaN.  */
   if (mpfr_inf_p (m))
@@ -105,7 +105,8 @@  real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, const real_format *format,
    mode RNDMODE.  TYPE is only relevant if M is a NaN.  */
 
 void
-real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, tree type, mp_rnd_t rndmode)
+real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, tree type,
+		mpfr_rnd_t rndmode)
 {
   real_from_mpfr (r, m, type ? REAL_MODE_FORMAT (TYPE_MODE (type)) : NULL,
 		  rndmode);
diff --git a/gcc/realmpfr.h b/gcc/realmpfr.h
index bfea86d2bd9..ebb44fd859d 100644
--- a/gcc/realmpfr.h
+++ b/gcc/realmpfr.h
@@ -27,15 +27,9 @@ 
 /* Convert between MPFR and REAL_VALUE_TYPE.  The caller is
    responsible for initializing and clearing the MPFR parameter.  */
 
-extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr, tree, mp_rnd_t);
+extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr, tree, mpfr_rnd_t);
 extern void real_from_mpfr (REAL_VALUE_TYPE *, mpfr_srcptr,
-			    const real_format *, mp_rnd_t);
-extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mp_rnd_t);
-
-#if (GCC_VERSION >= 3000)
-  /* For compatibility with mpfr 2.4 and earlier, we want to only use
-     GMP_RND*.  */
-  #pragma GCC poison MPFR_RNDN MPFR_RNDZ MPFR_RNDU MPFR_RNDD
-#endif
+			    const real_format *, mpfr_rnd_t);
+extern void mpfr_from_real (mpfr_ptr, const REAL_VALUE_TYPE *, mpfr_rnd_t);
 
 #endif /* ! GCC_REALGMP_H */
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index d2696302bd0..f12674b5649 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1860,7 +1860,7 @@  ubsan_instrument_float_cast (location_t loc, tree type, tree expr)
 	 representable decimal number greater or equal than
 	 1 << (prec - !uns_p).  */
       mpfr_init2 (m, prec + 2);
-      mpfr_set_ui_2exp (m, 1, prec - !uns_p, GMP_RNDN);
+      mpfr_set_ui_2exp (m, 1, prec - !uns_p, MPFR_RNDN);
       mpfr_snprintf (buf, sizeof buf, "%.*RUe", p - 1, m);
       decimal_real_from_string (&maxval, buf);
       max = build_real (expr_type, maxval);
@@ -1873,8 +1873,8 @@  ubsan_instrument_float_cast (location_t loc, tree type, tree expr)
 	  /* Use mpfr_snprintf rounding to compute the largest
 	     representable decimal number less or equal than
 	     (-1 << (prec - 1)) - 1.  */
-	  mpfr_set_si_2exp (m, -1, prec - 1, GMP_RNDN);
-	  mpfr_sub_ui (m, m, 1, GMP_RNDN);
+	  mpfr_set_si_2exp (m, -1, prec - 1, MPFR_RNDN);
+	  mpfr_sub_ui (m, m, 1, MPFR_RNDN);
 	  mpfr_snprintf (buf, sizeof buf, "%.*RDe", p - 1, m);
 	  decimal_real_from_string (&minval, buf);
 	  min = build_real (expr_type, minval);