Commit acb156cc by Janne Blomqvist

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.

From-SVN: r278525
parent c9d4cc5d
2019-11-20 Janne Blomqvist <jb@gcc.gnu.org> 2019-11-20 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/92463 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.
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. * arith.c (gfc_mpfr_to_mpz): Change mp_exp_t to mpfr_exp_t.
(gfc_check_real_range): Likewise. (gfc_check_real_range): Likewise.
* gfortran.h (GFC_RND_MODE): Change GMP_RNDN to MPFR_RNDN. * gfortran.h (GFC_RND_MODE): Change GMP_RNDN to MPFR_RNDN.
......
...@@ -6023,8 +6023,8 @@ norm2_add_squared (gfc_expr *result, gfc_expr *e) ...@@ -6023,8 +6023,8 @@ norm2_add_squared (gfc_expr *result, gfc_expr *e)
gfc_set_model_kind (result->ts.kind); gfc_set_model_kind (result->ts.kind);
int index = gfc_validate_kind (BT_REAL, result->ts.kind, false); int index = gfc_validate_kind (BT_REAL, result->ts.kind, false);
mp_exp_t exp; mpfr_exp_t exp;
if (mpfr_number_p (result->value.real) && !mpfr_zero_p (result->value.real)) if (mpfr_regular_p (result->value.real))
{ {
exp = mpfr_get_exp (result->value.real); exp = mpfr_get_exp (result->value.real);
/* If result is getting close to overflowing, scale down. */ /* If result is getting close to overflowing, scale down. */
...@@ -6038,7 +6038,7 @@ norm2_add_squared (gfc_expr *result, gfc_expr *e) ...@@ -6038,7 +6038,7 @@ norm2_add_squared (gfc_expr *result, gfc_expr *e)
} }
mpfr_init (tmp); mpfr_init (tmp);
if (mpfr_number_p (e->value.real) && !mpfr_zero_p (e->value.real)) if (mpfr_regular_p (e->value.real))
{ {
exp = mpfr_get_exp (e->value.real); exp = mpfr_get_exp (e->value.real);
/* If e**2 would overflow or close to overflowing, scale down. */ /* If e**2 would overflow or close to overflowing, scale down. */
...@@ -6079,9 +6079,7 @@ norm2_do_sqrt (gfc_expr *result, gfc_expr *e) ...@@ -6079,9 +6079,7 @@ norm2_do_sqrt (gfc_expr *result, gfc_expr *e)
if (result != e) if (result != e)
mpfr_set (result->value.real, e->value.real, GFC_RND_MODE); mpfr_set (result->value.real, e->value.real, GFC_RND_MODE);
mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE); mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE);
if (norm2_scale if (norm2_scale && mpfr_regular_p (result->value.real))
&& mpfr_number_p (result->value.real)
&& !mpfr_zero_p (result->value.real))
{ {
mpfr_t tmp; mpfr_t tmp;
mpfr_init (tmp); mpfr_init (tmp);
...@@ -6120,9 +6118,7 @@ gfc_simplify_norm2 (gfc_expr *e, gfc_expr *dim) ...@@ -6120,9 +6118,7 @@ gfc_simplify_norm2 (gfc_expr *e, gfc_expr *dim)
result = simplify_transformation_to_scalar (result, e, NULL, result = simplify_transformation_to_scalar (result, e, NULL,
norm2_add_squared); norm2_add_squared);
mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE); mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE);
if (norm2_scale if (norm2_scale && mpfr_regular_p (result->value.real))
&& mpfr_number_p (result->value.real)
&& !mpfr_zero_p (result->value.real))
{ {
mpfr_t tmp; mpfr_t tmp;
mpfr_init (tmp); mpfr_init (tmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment