From b2d6c9e88c22c18b1109bb39f265f64fffdbb901 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 20 Feb 2019 23:41:26 +0100 Subject: [PATCH] re PR tree-optimization/88074 (g++ hangs on math expression) PR middle-end/88074 PR middle-end/89415 * toplev.c (do_compile): Double the emin/emax exponents to workaround buggy mpc_norm. * gcc.dg/pr88074-2.c: New test. From-SVN: r269055 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/pr88074-2.c | 17 +++++++++++++++++ gcc/toplev.c | 8 ++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr88074-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f164119..1babbc7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-02-20 Jakub Jelinek + + PR middle-end/88074 + PR middle-end/89415 + * toplev.c (do_compile): Double the emin/emax exponents to workaround + buggy mpc_norm. + 2019-02-20 Uroš Bizjak PR target/89397 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6be764f..b5e800c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2019-02-20 Jakub Jelinek + PR middle-end/88074 + PR middle-end/89415 + * gcc.dg/pr88074-2.c: New test. + PR c++/89336 * g++.dg/cpp1y/constexpr-89336-3.C: New test. diff --git a/gcc/testsuite/gcc.dg/pr88074-2.c b/gcc/testsuite/gcc.dg/pr88074-2.c new file mode 100644 index 0000000..a93c19d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr88074-2.c @@ -0,0 +1,17 @@ +/* PR middle-end/88074 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-add-options float128 } */ +/* { dg-require-effective-target float128 } */ +/* { dg-final { scan-tree-dump-not "link_error " "optimized" } } */ + +extern void link_error (void); +int +main () +{ + if (((__FLT128_MAX__ * 0.5 + __FLT128_MAX__ * 0.5i) + / (__FLT128_MAX__ * 0.25 + __FLT128_MAX__ * 0.25i)) + != (_Complex _Float128) 2) + link_error (); + return 0; +} diff --git a/gcc/toplev.c b/gcc/toplev.c index d8096ce..d3719ff 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2173,8 +2173,12 @@ do_compile () max_exp = fmt->emax; } } - if (mpfr_set_emin (min_exp) - || mpfr_set_emax (max_exp)) + /* E.g. mpc_norm assumes it can square a number without bothering with + with range scaling, so until that is fixed, double the minimum + and maximum exponents, plus add some buffer for arithmetics + on the squared numbers. */ + if (mpfr_set_emin (2 * (min_exp - 1)) + || mpfr_set_emax (2 * (max_exp + 1))) sorry ("mpfr not configured to handle all float modes"); /* Set up the back-end if requested. */ -- 2.7.4