[PATCH] Minimum version of mpfr? (was Re: [PATCH] Fix up norm2 simplification (PR middle-end/88074)), take 2
David Malcolm
dmalcolm@redhat.com
Sat Feb 23 00:33:00 GMT 2019
On Fri, 2019-02-22 at 14:19 +0100, Jakub Jelinek wrote:
> On Thu, Feb 21, 2019 at 04:50:27PM -0500, David Malcolm wrote:
> > gcc/fortran/ChangeLog:
> > PR middle-end/88074
> > * simplify.c (norm2_add_squared): Use mp_exp_t rather than
> > mpfr_exp_t.
>
> I have discussed this with Richard on IRC earlier today, there is
> another
> issue that mpfr_regular_p is only 3.0 and later. And he prefers that
> mp_exp_t over say
> #if MPFR_VERSION < MPFR_VERSION_NUM(3,0,0)
> typedef mp_exp_t mpfr_exp_t;
> #endif
>
> So, here is the full patch I'll bootstrap/regtest soon:
FWIW, your patch fixed the bootstrap for me (and the regression tests
look sane:
gfortran.sum : total: 49370 PASS: 49164 XFAIL: 126 UNSUPPORTED: 80
though sadly I've blown away my known-good baseline for comparison)
Dave
> 2019-02-22 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.
>
> --- gcc/fortran/simplify.c.jj 2019-02-21 22:20:07.272388243
> +0100
> +++ gcc/fortran/simplify.c 2019-02-22 11:07:36.093374586 +0100
> @@ -6061,8 +6061,8 @@ norm2_add_squared (gfc_expr *result, gfc
>
> gfc_set_model_kind (result->ts.kind);
> int index = gfc_validate_kind (BT_REAL, result->ts.kind, false);
> - mpfr_exp_t exp;
> - if (mpfr_regular_p (result->value.real))
> + mp_exp_t exp;
> + if (mpfr_number_p (result->value.real) && !mpfr_zero_p (result-
> >value.real))
> {
> exp = mpfr_get_exp (result->value.real);
> /* If result is getting close to overflowing, scale down. */
> @@ -6076,7 +6076,7 @@ norm2_add_squared (gfc_expr *result, gfc
> }
>
> mpfr_init (tmp);
> - if (mpfr_regular_p (e->value.real))
> + if (mpfr_number_p (e->value.real) && !mpfr_zero_p (e->value.real))
> {
> exp = mpfr_get_exp (e->value.real);
> /* If e**2 would overflow or close to overflowing, scale
> down. */
> @@ -6117,7 +6117,9 @@ norm2_do_sqrt (gfc_expr *result, gfc_exp
> if (result != e)
> mpfr_set (result->value.real, e->value.real, GFC_RND_MODE);
> mpfr_sqrt (result->value.real, result->value.real, GFC_RND_MODE);
> - if (norm2_scale && mpfr_regular_p (result->value.real))
> + if (norm2_scale
> + && mpfr_number_p (result->value.real)
> + && !mpfr_zero_p (result->value.real))
> {
> mpfr_t tmp;
> mpfr_init (tmp);
> @@ -6156,7 +6158,9 @@ gfc_simplify_norm2 (gfc_expr *e, gfc_exp
> result = simplify_transformation_to_scalar (result, e, NULL,
> norm2_add_squared)
> ;
> mpfr_sqrt (result->value.real, result->value.real,
> GFC_RND_MODE);
> - if (norm2_scale && mpfr_regular_p (result->value.real))
> + if (norm2_scale
> + && mpfr_number_p (result->value.real)
> + && !mpfr_zero_p (result->value.real))
> {
> mpfr_t tmp;
> mpfr_init (tmp);
>
> Jakub
More information about the Fortran
mailing list