This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make -Os inlining less magic
> How so? cgraph_default_inline_p only checks the callee, but for
> -Os we want the caller to not grow (or in case of inlining once called
> static functions grow over a certain limit). So, adjusting
> cgraph_check_inline_limits looks ok, just it doesn't seem (in its
> current
> form) applicable to the case of -Os and inlining static once called
> functions.
You are right, I tend to forget that the estimated growth now depends on
call site too. With -Os we want to:
1) inline functions called once as at -O3
2) inline small functions only when caller body decrease
3) disable recursive inlining as in general it just increase size
I am testing the attached patch, hope it is more or less right now.
In the followup I would like to make -O2 to:
1) inline functions called once as at -O3 now
2) inline small functions declared inline
3) inline small function when calleer body decrease
4) do recursive inlining only on functions declared inline (to be
consistent with current behaviour)
Hope that the attached patch gets right the first part of plan ;)
I am testing it now and will commit it tomorrow if there are no
complains (or counterexamples ;)
Honza
2007-05-01 Richard Guenther <rguenther@suse.de>
Jan Hubicka <jh@suse.cz>
* opts.c (decode_options): Do not fiddle with inlining
parameters in case of optimizing for size.
* ipa-inline.c (cgraph_decide_recursive_inlining): When optimizing
for size do nothing.
(cgraph_decide_inlining_of_small_function): When optimizing for
size never inline functions increasing caller size.
(cgraph_early_inlining): Inline for size when optimizing for size.
Index: ipa-inline.c
===================================================================
*** ipa-inline.c (revision 124378)
--- ipa-inline.c (working copy)
*************** cgraph_decide_recursive_inlining (struct
*** 668,673 ****
--- 668,676 ----
int depth = 0;
int n = 0;
+ if (optimize_size)
+ return false;
+
if (DECL_DECLARED_INLINE_P (node->decl))
{
limit = PARAM_VALUE (PARAM_MAX_INLINE_INSNS_RECURSIVE);
*************** cgraph_decide_inlining_of_small_function
*** 913,919 ****
}
}
! if (!cgraph_maybe_hot_edge_p (edge) && growth > 0)
{
if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
&edge->inline_failed))
--- 916,922 ----
}
}
! if ((!cgraph_maybe_hot_edge_p (edge) || optimize_size) && growth > 0)
{
if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
&edge->inline_failed))
*************** cgraph_early_inlining (void)
*** 1444,1450 ****
if (sorrycount || errorcount)
return 0;
if (cgraph_decide_inlining_incrementally (node,
! flag_unit_at_a_time
? INLINE_SIZE : INLINE_SPEED, 0))
{
timevar_push (TV_INTEGRATION);
--- 1447,1453 ----
if (sorrycount || errorcount)
return 0;
if (cgraph_decide_inlining_incrementally (node,
! flag_unit_at_a_time || optimize_size
? INLINE_SIZE : INLINE_SPEED, 0))
{
timevar_push (TV_INTEGRATION);
Index: opts.c
===================================================================
*** opts.c (revision 124378)
--- opts.c (working copy)
*************** decode_options (unsigned int argc, const
*** 796,804 ****
if (optimize_size)
{
! /* Inlining of very small functions usually reduces total size. */
! set_param_value ("max-inline-insns-single", 5);
! set_param_value ("max-inline-insns-auto", 5);
flag_inline_functions = 1;
/* We want to crossjump as much as possible. */
--- 796,803 ----
if (optimize_size)
{
! /* Inlining of functions reducing size is a good idea regardless
! of them being declared inline. */
flag_inline_functions = 1;
/* We want to crossjump as much as possible. */