]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/90090 (ICE in mark_reachable_handlers, at tree...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:36:49 +0000 (14:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:36:49 +0000 (14:36 +0200)
Backported from mainline
2019-04-16  Jakub Jelinek  <jakub@redhat.com>

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr90090.C [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index 64c0a8829947dc170b2476ac1bc06ba832470c25..9d599c7d4b9524c044d998034ab2d94487630786 100644 (file)
@@ -1,6 +1,12 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-04-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/90090
+       * tree-ssa-math-opts.c (is_division_by): Ignore divisions that can
+       throw internally.
+
        2019-04-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/89998
index 46097e5d5ab6127929ee298dd814f982bceeff95..c7808b867d7dd3859aaa60c26bf57cff3cf56902 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-04-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/90090
+       * g++.dg/opt/pr90090.C: New test.
+
        2019-04-12  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..f60a888
--- /dev/null
@@ -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 ();
+    }
+}
index 4ff66e4ebcda2b64100c6afaacc6d7cae183402b..433c406bce3a161f35f5b59d816ed77834258a65 100644 (file)
@@ -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