On Fri, 22 Feb 2019, 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:

OK if it passes.

Apart from autotesters where some of ours run very old outdated systems...
for SLES 12 which I think is the oldest relevant distro I'd like to
see newer GCCs to work on we have mpfr 3.1.2 and gmp 5.1.3 just in
case we might finally consider bumping the minimum required versions
at some point.  Though I didn't yet see any technical reason to do so,
we have more "issues" supporting old host GCC versions (SLE12 uses
GCC 4.8 so that would be a considerable bump already).

Richard.

> 2019-02-22  David Malcolm  <dmalc...@redhat.com>
>           Jakub Jelinek  <ja...@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
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 
21284 (AG Nuernberg)

Reply via email to