From: David Malcolm Date: Sat, 23 Feb 2019 00:14:52 +0000 (+0000) Subject: re PR tree-optimization/88074 (g++ hangs on math expression) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0d527f0d31acd5f41ec6dc01ac4b8b5ab432b8ed;p=gcc.git re PR tree-optimization/88074 (g++ hangs on math expression) 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. Co-Authored-By: Jakub Jelinek From-SVN: r269139 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4de649e2550..054936b6886 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2019-02-23 David Malcolm + Jakub Jelinek + + 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. + 2019-02-22 Harald Anlauf PR fortran/83057 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index fa6396bee69..942f2eea3fc 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -6061,8 +6061,8 @@ norm2_add_squared (gfc_expr *result, gfc_expr *e) 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_expr *e) } 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_expr *e) 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_expr *dim) 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);