diff options
author | Richard Biener <rguenther@suse.de> | 2019-02-19 12:46:48 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-02-19 12:46:48 +0000 |
commit | 83fce9004a100215ac1b5e1ea5e1084bd2667c66 (patch) | |
tree | f5ead5aa182afa6e2f6c8cbf55dc320c9ff25d6d | |
parent | be200c5c41cd17948aca4932fe96aeae268c99fc (diff) | |
download | gcc-83fce9004a100215ac1b5e1ea5e1084bd2667c66.zip gcc-83fce9004a100215ac1b5e1ea5e1084bd2667c66.tar.gz gcc-83fce9004a100215ac1b5e1ea5e1084bd2667c66.tar.bz2 |
re PR tree-optimization/88074 (g++ hangs on math expression)
2019-02-19 Richard Biener <rguenther@suse.de>
PR middle-end/88074
* toplev.c (do_compile): Initialize mpfr's exponent range
based on available float modes.
* gcc.dg/pr88074.c: New testcase.
From-SVN: r269015
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr88074.c | 14 | ||||
-rw-r--r-- | gcc/toplev.c | 24 |
4 files changed, 49 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c4dbd2..3c9e17a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-02-19 Richard Biener <rguenther@suse.de> + + PR middle-end/88074 + * toplev.c (do_compile): Initialize mpfr's exponent range + based on available float modes. + 2019-02-19 Eric Botcazou <ebotcazou@adacore.com> * rtlanal.c (get_initial_register_offset): Fall back to the estimate diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab23500..9e34716 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-19 Richard Biener <rguenther@suse.de> + + PR middle-end/88074 + * gcc.dg/pr88074.c: New testcase. + 2019-02-19 Jakub Jelinek <jakub@redhat.com> PR middle-end/89303 diff --git a/gcc/testsuite/gcc.dg/pr88074.c b/gcc/testsuite/gcc.dg/pr88074.c new file mode 100644 index 0000000..9f64cc1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr88074.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +#include <complex.h> + +int main() +{ + _Complex double x; + __real x = 3.091e+8; + __imag x = -4.045e+8; + /* This used to spend huge amounts of compile-time inside mpc. */ + volatile _Complex double y = ctan (x); + return 0; +} diff --git a/gcc/toplev.c b/gcc/toplev.c index 0acfaae..d8096ce 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2153,6 +2153,30 @@ do_compile () else int_n_enabled_p[i] = false; + /* Initialize mpfrs exponent range. This is important to get + underflow/overflow in a reasonable timeframe. */ + machine_mode mode; + int min_exp = -1; + int max_exp = 1; + FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) + if (SCALAR_FLOAT_MODE_P (mode)) + { + const real_format *fmt = REAL_MODE_FORMAT (mode); + if (fmt) + { + /* fmt->emin - fmt->p + 1 should be enough but the + back-and-forth dance in real_to_decimal_for_mode we + do for checking fails due to rounding effects then. */ + if ((fmt->emin - fmt->p) < min_exp) + min_exp = fmt->emin - fmt->p; + if (fmt->emax > max_exp) + max_exp = fmt->emax; + } + } + if (mpfr_set_emin (min_exp) + || mpfr_set_emax (max_exp)) + sorry ("mpfr not configured to handle all float modes"); + /* Set up the back-end if requested. */ if (!no_backend) backend_init (); |