From: Jakub Jelinek Date: Fri, 30 Aug 2019 12:36:49 +0000 (+0200) Subject: backport: re PR tree-optimization/90090 (ICE in mark_reachable_handlers, at tree... X-Git-Tag: releases/gcc-7.5.0~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cffcee79a1ef5e16597eb156e41eabdff3770975;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/90090 (ICE in mark_reachable_handlers, at tree-eh.c:3938 since r219202) Backported from mainline 2019-04-16 Jakub Jelinek PR tree-optimization/90090 * tree-ssa-math-opts.c (is_division_by): Ignore divisions that can throw internally. * g++.dg/opt/pr90090.C: New test. From-SVN: r275148 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 64c0a8829947..9d599c7d4b95 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,12 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-04-16 Jakub Jelinek + + PR tree-optimization/90090 + * tree-ssa-math-opts.c (is_division_by): Ignore divisions that can + throw internally. + 2019-04-09 Jakub Jelinek PR tree-optimization/89998 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 46097e5d5ab6..c7808b867d7d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2019-08-30 Jakub Jelinek Backported from mainline + 2019-04-16 Jakub Jelinek + + PR tree-optimization/90090 + * g++.dg/opt/pr90090.C: New test. + 2019-04-12 Jakub Jelinek PR c/89933 diff --git a/gcc/testsuite/g++.dg/opt/pr90090.C b/gcc/testsuite/g++.dg/opt/pr90090.C new file mode 100644 index 000000000000..f60a888733f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr90090.C @@ -0,0 +1,19 @@ +// PR tree-optimization/90090 +// { dg-do compile } +// { dg-options "-Ofast -fno-associative-math -fsignaling-nans -fno-tree-dce -fnon-call-exceptions" } + +double bar (double, double, double, double, double); +double baz (); + +double +foo (double a) +{ + try + { + return bar (1.0/a, 2.0/a, 4.0/a, 8.0/a, 16.0/a); + } + catch (...) + { + return baz (); + } +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 4ff66e4ebcda..433c406bce3a 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -337,7 +337,8 @@ is_division_by (gimple *use_stmt, tree def) /* Do not recognize x / x as valid division, as we are getting confused later by replacing all immediate uses x in such a stmt. */ - && gimple_assign_rhs1 (use_stmt) != def; + && gimple_assign_rhs1 (use_stmt) != def + && !stmt_can_throw_internal (use_stmt); } /* Walk the subset of the dominator tree rooted at OCC, setting the