From: Robert Suchanek <robert.sucha...@imgtec.com> --param early-inlining-insns-cold=NUMBER --param max-inline-insns-small-and-cold=NUMBER
Analysis shows that the main difference between -O2 and -Os goes down to inlining of cold or unlikely functions. The new parameters (defaulted to 0) mean to disable these limitations with -Os. NUMBER could be set to something like 4-32 to see the impact. The main reason that smaller functions are treated as cold or unlikely is the function cgraph_maybe_hot_edge_p () always returning FALSE for -Os. gcc/ * ipa-inline.cc (want_early_inline_function_p): Check if the growth is greater than param_early_inlining_insns_cold. (want_inline_small_function_p): Check if the growth is greater than param_max_inline_insns_small_and_cold. * params.opt (early-inlining-insns-cold): New option. (max-inline-insns-small-and-cold): Likewise. Cherry-picked c38d7e548cbb3defb141efb528cb356333e8eb7a from https://github.com/MIPS/gcc Signed-off-by: Robert Suchanek <robert.sucha...@imgtec.com> Signed-off-by: Faraz Shahbazker <fshahbaz...@wavecomp.com> Signed-off-by: Aleksandar Rakic <aleksandar.ra...@htecgroup.com> --- gcc/ipa-inline.cc | 4 +++- gcc/params.opt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc index fe8efa9a157..4d3d0fbc0c3 100644 --- a/gcc/ipa-inline.cc +++ b/gcc/ipa-inline.cc @@ -820,7 +820,8 @@ want_early_inline_function_p (struct cgraph_edge *e) if (!want_inline || growth <= param_max_inline_insns_size) ; - else if (!e->maybe_hot_p ()) + else if (!e->maybe_hot_p () + && growth > param_early_inlining_insns_cold) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt, @@ -1060,6 +1061,7 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report) } /* If call is cold, do not inline when function body would grow. */ else if (!e->maybe_hot_p () + && growth > param_max_inline_insns_small_and_cold && (growth >= inline_insns_single (e->caller, false, false) || growth_positive_p (callee, e, growth))) { diff --git a/gcc/params.opt b/gcc/params.opt index 7c572774df2..edb62a221fb 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -130,6 +130,10 @@ Maximum size (in bytes) of objects tracked bytewise by dead store elimination. Common Joined UInteger Var(param_early_inlining_insns) Init(6) Optimization Param Maximal estimated growth of function body caused by early inlining of single call. +-param=early-inlining-insns-cold= +Common Joined UInteger Var(param_early_inlining_insns_cold) Init(0) Optimization Param +Maximal estimated growth of function body caused by early inlining of cold call. + -param=fsm-scale-path-stmts= Common Joined UInteger Var(param_fsm_scale_path_stmts) Init(2) IntegerRange(1, 10) Param Optimization Scale factor to apply to the number of statements in a threading path crossing a loop backedge when comparing to max-jump-thread-duplication-stmts. @@ -573,6 +577,10 @@ The maximum number of instructions when inlining for size. Common Joined UInteger Var(param_max_inline_insns_small) Optimization Param The maximum number of instructions when automatically inlining small functions. +-param=max-inline-insns-small-and-cold= +Common Joined UInteger Var(param_max_inline_insns_small_and_cold) Optimization Init(0) Param +The maximum number of instructions in a small and cold function eligible for inlining. + -param=max-inline-recursive-depth= Common Joined UInteger Var(param_max_inline_recursive_depth) Optimization Init(8) Param The maximum depth of recursive inlining for inline functions. -- 2.34.1