aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-05-18 08:51:23 +0200
committerRichard Biener <rguenther@suse.de>2020-05-18 12:27:53 +0200
commitfe168751c5c1c517c7c89c9a1e4e561d66b24663 (patch)
tree14205bc73e57021f4079ec12868dd2362fa44e13
parent52a0f83980082c9995f2d8ec9b88548520fb8a5f (diff)
downloadgcc-fe168751c5c1c517c7c89c9a1e4e561d66b24663.zip
gcc-fe168751c5c1c517c7c89c9a1e4e561d66b24663.tar.gz
gcc-fe168751c5c1c517c7c89c9a1e4e561d66b24663.tar.bz2
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.
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr95171.c18
-rw-r--r--gcc/tree-inline.c31
4 files changed, 60 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 491293d..98c035a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
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
* tree-ssa-loop-im.c (execute_sm): Get flag whether we
eventually need the conditional processing.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1123599..33425f2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
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
* gcc.dg/torture/pr95172.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/pr95171.c b/gcc/testsuite/gcc.dg/pr95171.c
new file mode 100644
index 0000000..af9bde7
--- /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 ee96c9c..943f3f9 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;
}