Re: [Patch] PR 92463 - Cleanups due to minimum MPFR version bump to 3.1.0

2019-11-27 Thread Richard Biener
On Tue, Nov 26, 2019 at 10:43 PM Tobias Burnus  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
>


Re: [Patch] PR 92463 - Cleanups due to minimum MPFR version bump to 3.1.0

2019-11-27 Thread Janne Blomqvist
On Tue, Nov 26, 2019 at 11:42 PM Tobias Burnus  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.

-- 
Janne Blomqvist


[Patch] PR 92463 - Cleanups due to minimum MPFR version bump to 3.1.0

2019-11-26 Thread Tobias Burnus
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

	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_cl