public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] middle-end/95171 - inlining of trapping compare into non-call EH fn
@ 2020-08-22 21:20 Giuliano Belinassi
0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:804937f5b730ee7c1ec5e32fbfad1f07840076cc
commit 804937f5b730ee7c1ec5e32fbfad1f07840076cc
Author: Richard Biener <rguenther@suse.de>
Date: Mon May 18 08:51:23 2020 +0200
middle-end/95171 - inlining of trapping compare into non-call EH fn
This fixes always-inlining across -fnon-call-exception boundaries
for conditions which we do not allow to throw.
2020-05-18 Richard Biener <rguenther@suse.de>
PR middle-end/95171
* tree-inline.c (remap_gimple_stmt): Split out trapping compares
when inlining into a non-call EH function.
* gcc.dg/pr95171.c: New testcase.
Diff:
---
gcc/ChangeLog | 6 ++++++
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gcc.dg/pr95171.c | 18 ++++++++++++++++++
gcc/tree-inline.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 60 insertions(+)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 491293d77df..98c035a5356 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-18 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/95171
+ * tree-inline.c (remap_gimple_stmt): Split out trapping compares
+ when inlining into a non-call EH function.
+
2020-05-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/95172
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1123599b9a7..33425f259b4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-18 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/95171
+ * gcc.dg/pr95171.c: New testcase.
+
2020-05-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/95172
diff --git a/gcc/testsuite/gcc.dg/pr95171.c b/gcc/testsuite/gcc.dg/pr95171.c
new file mode 100644
index 00000000000..af9bde7bc6a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr95171.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-fexceptions -ffinite-math-only -fnon-call-exceptions" } */
+
+inline double __attribute__ ((always_inline))
+w9 (int q2)
+{
+ return __builtin_fabs (__builtin_nan ("")) > 0.0 ? 1.0 : q2 / 1.0;
+}
+
+double __attribute__ ((optimize ("-fipa-cp")))
+o7 (int iz)
+{
+ int rj[1];
+
+ (void) rj;
+
+ return w9 (iz);
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index ee96c9cfff0..943f3f9407b 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1956,6 +1956,37 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
gimple_set_vuse (copy, NULL_TREE);
}
+ if (cfun->can_throw_non_call_exceptions)
+ {
+ /* When inlining a function which does not have non-call exceptions
+ enabled into a function that has (which only happens with
+ always-inline) we have to fixup stmts that cannot throw. */
+ if (gcond *cond = dyn_cast <gcond *> (copy))
+ if (gimple_could_trap_p (cond))
+ {
+ gassign *cmp
+ = gimple_build_assign (make_ssa_name (boolean_type_node),
+ gimple_cond_code (cond),
+ gimple_cond_lhs (cond),
+ gimple_cond_rhs (cond));
+ gimple_seq_add_stmt (&stmts, cmp);
+ gimple_cond_set_code (cond, NE_EXPR);
+ gimple_cond_set_lhs (cond, gimple_assign_lhs (cmp));
+ gimple_cond_set_rhs (cond, boolean_false_node);
+ }
+ if (gassign *ass = dyn_cast <gassign *> (copy))
+ if ((gimple_assign_rhs_code (ass) == COND_EXPR
+ || gimple_assign_rhs_code (ass) == VEC_COND_EXPR)
+ && gimple_could_trap_p (ass))
+ {
+ gassign *cmp
+ = gimple_build_assign (make_ssa_name (boolean_type_node),
+ gimple_assign_rhs1 (ass));
+ gimple_seq_add_stmt (&stmts, cmp);
+ gimple_assign_set_rhs1 (ass, gimple_assign_lhs (cmp));
+ }
+ }
+
gimple_seq_add_stmt (&stmts, copy);
return stmts;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-22 21:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:20 [gcc/devel/autopar_devel] middle-end/95171 - inlining of trapping compare into non-call EH fn Giuliano Belinassi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).