aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-inline.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@gcc.gnu.org>2019-10-02 16:01:47 +0000
committerJan Hubicka <hubicka@gcc.gnu.org>2019-10-02 16:01:47 +0000
commit562d1e9556777988ae46c5d1357af2636bc272ea (patch)
treeb07b5dedff4846b2076284b72777f8790ef92e0a /gcc/ipa-inline.c
parent352d2690f1eb7268cc21de643759e2f666119e9f (diff)
downloadgcc-562d1e9556777988ae46c5d1357af2636bc272ea.zip
gcc-562d1e9556777988ae46c5d1357af2636bc272ea.tar.gz
gcc-562d1e9556777988ae46c5d1357af2636bc272ea.tar.bz2
cif-code.def (MAX_INLINE_INSNS_SINGLE_O2_LIMIT, [...]): New.
* cif-code.def (MAX_INLINE_INSNS_SINGLE_O2_LIMIT, MAX_INLINE_INSNS_AUTO_O2_LIMIT): New. * ipa-inline.c (inline_insns_single, inline_insns_auto): New functions. (can_inline_edge_by_limits_p): Use it. (big_speedup_p): Use PARAM_INLINE_MIN_SPEEDUP_O2. (want_inline_small_function_p): Use O2 bounds. (edge_badness): LIkewise. * opts.c (default_options): Add OPT_finline_functions. * params.def (PARAM_INLINE_MIN_SPEEDUP_O2, PARAM_MAX_INLINE_INSNS_SINGLE_O2, PARAM_MAX_INLINE_INSNS_AUTO_O2): New parameters. * g++.dg/tree-ssa/pr53844.C: Add -fno-inline-functions --param max-inline-insns-single-O2=200. * gcc.c-torture/execute/builtins/builtins.exp: Add -fno-inline-functions to additional_flags. * gcc.dg/ipa/inline-7.c: Add -fno-inline-functions. * gcc.dg/optimize-bswapsi-5.c: Add -fno-inline-functions. * gcc.dg/tree-ssa/ssa-thread-12.c: Add --param early-inlining-insns-O2=14 -fno-inline-functions; revert previous change. * gcc.dg/winline-3.c: Use --param max-inline-insns-single-O2=1 --param inline-min-speedup-O2=100 instead of --param max-inline-insns-single=1 --param inline-min-speedup=100 * invoke.texi (-finline-functions): Update documentation. (max-inline-insns-single-O2, max-inline-insns-auto-O2, inline-min-speedup-O2): Document. (early-inlining-insns-O2): Simplify docs. From-SVN: r276469
Diffstat (limited to 'gcc/ipa-inline.c')
-rw-r--r--gcc/ipa-inline.c95
1 files changed, 67 insertions, 28 deletions
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index c8689c7..98d7fd3 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -390,6 +390,28 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
return inlinable;
}
+/* Return inlining_insns_single limit for function N */
+
+static int
+inline_insns_single (cgraph_node *n)
+{
+ if (opt_for_fn (n->decl, optimize >= 3))
+ return PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SINGLE);
+ else
+ return PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SINGLE_O2);
+}
+
+/* Return inlining_insns_auto limit for function N */
+
+static int
+inline_insns_auto (cgraph_node *n)
+{
+ if (opt_for_fn (n->decl, optimize >= 3))
+ return PARAM_VALUE (PARAM_MAX_INLINE_INSNS_AUTO);
+ else
+ return PARAM_VALUE (PARAM_MAX_INLINE_INSNS_AUTO_O2);
+}
+
/* Decide if we can inline the edge and possibly update
inline_failed reason.
We check whether inlining is possible at all and whether
@@ -532,8 +554,8 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, bool report,
int growth = estimate_edge_growth (e);
if (growth > PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SIZE)
&& (!DECL_DECLARED_INLINE_P (callee->decl)
- && growth >= MAX (MAX_INLINE_INSNS_SINGLE,
- MAX_INLINE_INSNS_AUTO)))
+ && growth >= MAX (inline_insns_single (caller),
+ inline_insns_auto (caller))))
{
e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
inlinable = false;
@@ -745,9 +767,14 @@ big_speedup_p (struct cgraph_edge *e)
sreal spec_time = estimate_edge_time (e, &unspec_time);
sreal time = compute_uninlined_call_time (e, unspec_time);
sreal inlined_time = compute_inlined_call_time (e, spec_time);
+ cgraph_node *caller = e->caller->global.inlined_to
+ ? e->caller->global.inlined_to
+ : e->caller;
+ int limit = opt_for_fn (caller->decl, optimize) >= 3
+ ? PARAM_VALUE (PARAM_INLINE_MIN_SPEEDUP)
+ : PARAM_VALUE (PARAM_INLINE_MIN_SPEEDUP_O2);
- if ((time - inlined_time) * 100
- > (sreal) (time * PARAM_VALUE (PARAM_INLINE_MIN_SPEEDUP)))
+ if ((time - inlined_time) * 100 > time * limit)
return true;
return false;
}
@@ -781,20 +808,29 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
&& (!e->count.ipa ().initialized_p () || !e->maybe_hot_p ()))
&& ipa_fn_summaries->get (callee)->min_size
- ipa_call_summaries->get (e)->call_stmt_size
- > MAX (MAX_INLINE_INSNS_SINGLE, MAX_INLINE_INSNS_AUTO))
+ > MAX (inline_insns_single (e->caller),
+ inline_insns_auto (e->caller)))
{
- e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
+ if (opt_for_fn (e->caller->decl, optimize) >= 3)
+ e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
+ else
+ e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_O2_LIMIT;
want_inline = false;
}
else if ((DECL_DECLARED_INLINE_P (callee->decl)
|| e->count.ipa ().nonzero_p ())
&& ipa_fn_summaries->get (callee)->min_size
- ipa_call_summaries->get (e)->call_stmt_size
- > 16 * MAX_INLINE_INSNS_SINGLE)
+ > 16 * inline_insns_single (e->caller))
{
- e->inline_failed = (DECL_DECLARED_INLINE_P (callee->decl)
- ? CIF_MAX_INLINE_INSNS_SINGLE_LIMIT
- : CIF_MAX_INLINE_INSNS_AUTO_LIMIT);
+ if (opt_for_fn (e->caller->decl, optimize) >= 3)
+ e->inline_failed = (DECL_DECLARED_INLINE_P (callee->decl)
+ ? CIF_MAX_INLINE_INSNS_SINGLE_LIMIT
+ : CIF_MAX_INLINE_INSNS_AUTO_LIMIT);
+ else
+ e->inline_failed = (DECL_DECLARED_INLINE_P (callee->decl)
+ ? CIF_MAX_INLINE_INSNS_SINGLE_O2_LIMIT
+ : CIF_MAX_INLINE_INSNS_AUTO_O2_LIMIT);
want_inline = false;
}
else
@@ -808,15 +844,18 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
/* Apply MAX_INLINE_INSNS_SINGLE limit. Do not do so when
hints suggests that inlining given function is very profitable. */
else if (DECL_DECLARED_INLINE_P (callee->decl)
- && growth >= MAX_INLINE_INSNS_SINGLE
- && (growth >= MAX_INLINE_INSNS_SINGLE * 16
+ && growth >= inline_insns_single (e->caller)
+ && (growth >= inline_insns_single (e->caller) * 16
|| (!(hints & (INLINE_HINT_indirect_call
| INLINE_HINT_known_hot
| INLINE_HINT_loop_iterations
| INLINE_HINT_loop_stride))
&& !(big_speedup = big_speedup_p (e)))))
{
- e->inline_failed = CIF_MAX_INLINE_INSNS_SINGLE_LIMIT;
+ if (opt_for_fn (e->caller->decl, optimize) >= 3)
+ e->inline_failed = CIF_MAX_INLINE_INSNS_SINGLE_LIMIT;
+ else
+ e->inline_failed = CIF_MAX_INLINE_INSNS_SINGLE_O2_LIMIT;
want_inline = false;
}
else if (!DECL_DECLARED_INLINE_P (callee->decl)
@@ -824,12 +863,12 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
&& growth >= PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SMALL))
{
/* growth_likely_positive is expensive, always test it last. */
- if (growth >= MAX_INLINE_INSNS_SINGLE
+ if (growth >= inline_insns_single (e->caller)
|| growth_likely_positive (callee, growth))
{
- e->inline_failed = CIF_NOT_DECLARED_INLINED;
+ e->inline_failed = CIF_NOT_DECLARED_INLINED;
want_inline = false;
- }
+ }
}
/* Apply MAX_INLINE_INSNS_AUTO limit for functions not declared inline
Upgrade it to MAX_INLINE_INSNS_SINGLE when hints suggests that
@@ -839,28 +878,28 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
&& growth >= ((hints & (INLINE_HINT_indirect_call
| INLINE_HINT_loop_iterations
| INLINE_HINT_loop_stride))
- ? MAX (MAX_INLINE_INSNS_AUTO,
- MAX_INLINE_INSNS_SINGLE)
- : MAX_INLINE_INSNS_AUTO)
+ ? MAX (inline_insns_auto (e->caller),
+ inline_insns_single (e->caller))
+ : inline_insns_auto (e->caller))
&& !(big_speedup == -1 ? big_speedup_p (e) : big_speedup))
{
/* growth_likely_positive is expensive, always test it last. */
- if (growth >= MAX_INLINE_INSNS_SINGLE
+ if (growth >= inline_insns_single (e->caller)
|| growth_likely_positive (callee, growth))
{
- e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
+ if (opt_for_fn (e->caller->decl, optimize) >= 3)
+ e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
+ else
+ e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_O2_LIMIT;
want_inline = false;
- }
+ }
}
/* If call is cold, do not inline when function body would grow. */
else if (!e->maybe_hot_p ()
- && (growth >= MAX_INLINE_INSNS_SINGLE
+ && (growth >= inline_insns_single (e->caller)
|| growth_likely_positive (callee, growth)))
{
- if (e->count.ipa () == profile_count::zero ())
- e->inline_failed = CIF_NEVER_CALL;
- else
- e->inline_failed = CIF_UNLIKELY_CALL;
+ e->inline_failed = CIF_UNLIKELY_CALL;
want_inline = false;
}
}
@@ -1166,7 +1205,7 @@ edge_badness (struct cgraph_edge *edge, bool dump)
&& caller_info->inlinable
&& caller_info->size
< (DECL_DECLARED_INLINE_P (caller->decl)
- ? MAX_INLINE_INSNS_SINGLE : MAX_INLINE_INSNS_AUTO))
+ ? inline_insns_single (caller) : inline_insns_auto (caller)))
{
if (dump)
fprintf (dump_file,