* Add new --param knobs for inliner
@ 2019-01-05 17:58 Jan Hubicka
2019-01-07 14:05 ` Ulrich Weigand
2019-01-07 17:46 ` Pat Haugen
0 siblings, 2 replies; 5+ messages in thread
From: Jan Hubicka @ 2019-01-05 17:58 UTC (permalink / raw)
To: gcc-patches, uweigand, dje.gcc
Hi,
this patch adds new parameters to ipa-inline. max-inline-insns-size is
useful to increase inlining limits for programs with large abstraction
penalty.
uinlined-* should be useful for architecutures with greater function
call overhead than modern x86 chips (which is good portion of them,
especially s390 as I learnt on Cauldron). It would be nice to benchmark
effect of those and tune default in config/* files. I think this is a
reasonable way to deal with architecutral differences without making
inliner hard to tune in long term.
Bootstrapped/regtested x86_64-linux, plan to commit it soon.
Honza
* doc/invoke.texi: Document max-inline-insns-size,
uninlined-function-insns, uninlined-function-time,
uninlined-thunk-insns and uninlined-thunk-time.
* params.def: Add max-inline-insns-size,
uninlined-function-insns, uninlined-function-time,
uninlined-thunk-insns and uninlined-thunk-time.
* ipa-fnsummary.c (compute_fn_summary, analyze_function_body): Use
new parameters.
* ipa-inline.c (can_inline_edge_by_limits_p,
want_inline_small_function_p): Use new parameters.
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi (revision 267585)
+++ doc/invoke.texi (working copy)
@@ -11007,6 +11007,23 @@ by the compiler are investigated. To th
(more restrictive) limit compared to functions declared inline can
be applied.
+@item max-inline-insns-size
+This is bound applied to calls which are optimized for size. Small growth
+may be desirable to anticipate optimization oppurtunities exposed by inlining.
+
+@item uninlined-function-insns
+Number of instructions accounted by inliner for function overhead such as
+function prologue and epilogue.
+
+@item uninlined-function-time
+Extra time accounted by inliner for function overhead such as time needed to
+execute function prologue and epilogue
+
+@item uninlined-thunk-insns
+@item uninlined-thunk-time
+Same as @option{--param uninlined-function-insns} and
+@option{--param uninlined-function-time} but applied to function thunks
+
@item inline-min-speedup
When estimated performance improvement of caller + callee runtime exceeds this
threshold (in percent), the function can be inlined regardless of the limit on
Index: ipa-fnsummary.c
===================================================================
--- ipa-fnsummary.c (revision 267600)
+++ ipa-fnsummary.c (working copy)
@@ -2034,7 +2081,10 @@ analyze_function_body (struct cgraph_nod
info->account_size_time (0, 0, bb_predicate, bb_predicate);
bb_predicate = predicate::not_inlined ();
- info->account_size_time (2 * ipa_fn_summary::size_scale, 0, bb_predicate,
+ info->account_size_time (PARAM_VALUE (PARAM_UNINLINED_FUNCTION_INSNS)
+ * ipa_fn_summary::size_scale,
+ PARAM_VALUE (PARAM_UNINLINED_FUNCTION_TIME),
+ bb_predicate,
bb_predicate);
if (fbi.info)
@@ -2418,7 +2468,11 @@ compute_fn_summary (struct cgraph_node *
node->local.can_change_signature = false;
es->call_stmt_size = eni_size_weights.call_cost;
es->call_stmt_time = eni_time_weights.call_cost;
- info->account_size_time (ipa_fn_summary::size_scale * 2, 2, t, t);
+ info->account_size_time (ipa_fn_summary::size_scale
+ * PARAM_VALUE
+ (PARAM_UNINLINED_FUNCTION_THUNK_INSNS),
+ PARAM_VALUE
+ (PARAM_UNINLINED_FUNCTION_THUNK_TIME), t, t);
t = predicate::not_inlined ();
info->account_size_time (2 * ipa_fn_summary::size_scale, 0, t, t);
ipa_update_overall_fn_summary (node);
Index: ipa-inline.c
===================================================================
--- ipa-inline.c (revision 267585)
+++ ipa-inline.c (working copy)
@@ -523,7 +523,7 @@ can_inline_edge_by_limits_p (struct cgra
> opt_for_fn (caller->decl, optimize_size))
{
int growth = estimate_edge_growth (e);
- if (growth > 0
+ 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)))
@@ -635,7 +635,7 @@ want_early_inline_function_p (struct cgr
int growth = estimate_edge_growth (e);
int n;
- if (growth <= 0)
+ if (growth <= PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SIZE))
;
else if (!e->maybe_hot_p ()
&& growth > 0)
@@ -791,7 +791,7 @@ want_inline_small_function_p (struct cgr
ipa_hints hints = estimate_edge_hints (e);
int big_speedup = -1; /* compute this lazily */
- if (growth <= 0)
+ if (growth <= PARAM_VALUE (PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SIZE)))
;
/* Apply MAX_INLINE_INSNS_SINGLE limit. Do not do so when
hints suggests that inlining given function is very profitable. */
Index: params.def
===================================================================
--- params.def (revision 267585)
+++ params.def (working copy)
@@ -83,6 +83,33 @@ DEFPARAM (PARAM_MAX_INLINE_INSNS_AUTO,
"The maximum number of instructions when automatically inlining.",
30, 0, 0)
+DEFPARAM (PARAM_MAX_INLINE_INSNS_SIZE,
+ "max-inline-insns-size",
+ "The maximum number of instructions when inlining for size.",
+ 0, 0, 0)
+
+DEFPARAM (PARAM_UNINLINED_FUNCTION_INSNS,
+ "uninlined-function-insns",
+ "Instruction accounted for function prologue, epilogue and other"
+ " overhead.",
+ 2, 0, 0)
+
+DEFPARAM (PARAM_UNINLINED_FUNCTION_TIME,
+ "uninlined-function-time",
+ "Time accounted for function prologue, epilogue and other"
+ " overhead.",
+ 0, 0, 0)
+
+DEFPARAM (PARAM_UNINLINED_FUNCTION_THUNK_INSNS,
+ "uninlined-thunk-insns",
+ "Instruction accounted for function thunk overhead.",
+ 2, 0, 0)
+
+DEFPARAM (PARAM_UNINLINED_FUNCTION_THUNK_TIME,
+ "uninlined-thunk-time",
+ "Time accounted for function thunk overhead.",
+ 2, 0, 0)
+
DEFPARAM (PARAM_MAX_INLINE_INSNS_RECURSIVE,
"max-inline-insns-recursive",
"The maximum number of instructions inline function can grow to via recursive inlining.",
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Add new --param knobs for inliner
2019-01-05 17:58 Add new --param knobs for inliner Jan Hubicka
@ 2019-01-07 14:05 ` Ulrich Weigand
2019-01-07 15:01 ` Jan Hubicka
2019-01-07 17:46 ` Pat Haugen
1 sibling, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2019-01-07 14:05 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches, dje.gcc
Jan Hubicka wrote:
> uinlined-* should be useful for architecutures with greater function
> call overhead than modern x86 chips (which is good portion of them,
> especially s390 as I learnt on Cauldron). It would be nice to benchmark
> effect of those and tune default in config/* files. I think this is a
> reasonable way to deal with architecutral differences without making
> inliner hard to tune in long term.
Thanks for the heads-up! This looks interesting, we'll have a look.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU/Linux compilers and toolchain
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Add new --param knobs for inliner
2019-01-07 14:05 ` Ulrich Weigand
@ 2019-01-07 15:01 ` Jan Hubicka
0 siblings, 0 replies; 5+ messages in thread
From: Jan Hubicka @ 2019-01-07 15:01 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gcc-patches, dje.gcc
> Jan Hubicka wrote:
>
> > uinlined-* should be useful for architecutures with greater function
> > call overhead than modern x86 chips (which is good portion of them,
> > especially s390 as I learnt on Cauldron). It would be nice to benchmark
> > effect of those and tune default in config/* files. I think this is a
> > reasonable way to deal with architecutral differences without making
> > inliner hard to tune in long term.
>
> Thanks for the heads-up! This looks interesting, we'll have a look.
It may (and likely will) still be necessary to also increase
max-inline-insns-auto and perhaps -single but I think it is good to get
model realistic first. It will make inliner to prioritize better and
consider more inline candidates as important via the big speedup metric.
Honza
>
> Bye,
> Ulrich
>
> --
> Dr. Ulrich Weigand
> GNU/Linux compilers and toolchain
> Ulrich.Weigand@de.ibm.com
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Add new --param knobs for inliner
2019-01-05 17:58 Add new --param knobs for inliner Jan Hubicka
2019-01-07 14:05 ` Ulrich Weigand
@ 2019-01-07 17:46 ` Pat Haugen
2019-01-07 20:03 ` Jan Hubicka
1 sibling, 1 reply; 5+ messages in thread
From: Pat Haugen @ 2019-01-07 17:46 UTC (permalink / raw)
To: Jan Hubicka, gcc-patches, uweigand, dje.gcc
On 1/5/19 11:58 AM, Jan Hubicka wrote:
> @@ -791,7 +791,7 @@ want_inline_small_function_p (struct cgr
> ipa_hints hints = estimate_edge_hints (e);
> int big_speedup = -1; /* compute this lazily */
>
> - if (growth <= 0)
> + if (growth <= PARAM_VALUE (PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SIZE)))
Extra PARAM_VALUE here.
-Pat
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Add new --param knobs for inliner
2019-01-07 17:46 ` Pat Haugen
@ 2019-01-07 20:03 ` Jan Hubicka
0 siblings, 0 replies; 5+ messages in thread
From: Jan Hubicka @ 2019-01-07 20:03 UTC (permalink / raw)
To: Pat Haugen; +Cc: gcc-patches, uweigand, dje.gcc
> On 1/5/19 11:58 AM, Jan Hubicka wrote:
> > @@ -791,7 +791,7 @@ want_inline_small_function_p (struct cgr
> > ipa_hints hints = estimate_edge_hints (e);
> > int big_speedup = -1; /* compute this lazily */
> >
> > - if (growth <= 0)
> > + if (growth <= PARAM_VALUE (PARAM_VALUE (PARAM_MAX_INLINE_INSNS_SIZE)))
>
> Extra PARAM_VALUE here.
This was fixed by the followup commit. Indeed a stupid bug.
Honza
>
> -Pat
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-07 20:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-05 17:58 Add new --param knobs for inliner Jan Hubicka
2019-01-07 14:05 ` Ulrich Weigand
2019-01-07 15:01 ` Jan Hubicka
2019-01-07 17:46 ` Pat Haugen
2019-01-07 20:03 ` Jan Hubicka
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).