On 4/25/07, Joerg Wunsch <[EMAIL PROTECTED]> wrote:
As Ian Lance Taylor wrote:

> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31528

> The relevant code is in opts.c:

>   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;

> Inlining has changed considerably since then, and it is possible
> that these parameter values are no longer appropriate.  The reports
> at the time indicate space savings.

Thanks for telling me where to look for it, Ian!  It's really
appreciated.

I made a first attempt on lowering max-inline-insns-auto from 5 to 3.
I did some initial testing (using the C program and shell script in
the attachment), on a recent GCC tree built for both, the AVR target
as well as my host's native i386 target.  This appears to be at a
break-even to me:

I'd rather remove this "hack" and use the inliners code size estimator, like
that patch from early 2005 (attached)...

Richard.

2005-03-02  Richard Guenther  <[EMAIL PROTECTED]>

       * opts.c (decode_options): Do not fiddle with inlining
       parameters in case of optimizing for size.
       * cgraphunit.c (cgraph_check_inline_limits): If optimizing
       for size make sure we do not grow the unit-size by inlining.
       (cgraph_decide_recursive_inlining): Likewise.
2005-03-02  Richard Guenther  <[EMAIL PROTECTED]>

	* opts.c (decode_options): Do not fiddle with inlining
	parameters in case of optimizing for size.
	* cgraphunit.c (cgraph_check_inline_limits): If optimizing
	for size make sure we do not grow the unit-size by inlining.
	(cgraph_decide_recursive_inlining): Likewise.

Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.94
diff -c -3 -p -r1.94 opts.c
*** opts.c	24 Feb 2005 09:24:13 -0000	1.94
--- opts.c	2 Mar 2005 13:10:58 -0000
*************** decode_options (unsigned int argc, const
*** 572,580 ****
  
    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.  */
--- 572,579 ----
  
    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.  */
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.93.2.1
diff -c -3 -p -r1.93.2.1 cgraphunit.c
*** cgraphunit.c	2 Mar 2005 10:10:30 -0000	1.93.2.1
--- cgraphunit.c	2 Mar 2005 13:10:58 -0000
*************** cgraph_check_inline_limits (struct cgrap
*** 1184,1189 ****
--- 1189,1201 ----
    limit += limit * PARAM_VALUE (PARAM_LARGE_FUNCTION_GROWTH) / 100;
  
    newsize = cgraph_estimate_size_after_inlining (times, to, what);
+   if (optimize_size
+       && newsize > to->global.insns)
+     {
+       if (reason)
+ 	*reason = N_("optimizing for size");
+       return false;
+     }
    if (newsize > PARAM_VALUE (PARAM_LARGE_FUNCTION_INSNS)
        && newsize > limit)
      {
*************** cgraph_decide_recursive_inlining (struct
*** 1279,1284 ****
--- 1291,1297 ----
    struct cgraph_node *master_clone;
    int depth = 0;
    int n = 0;
+   int newsize;
  
    if (DECL_DECLARED_INLINE_P (node->decl))
      {
*************** cgraph_decide_recursive_inlining (struct
*** 1287,1294 ****
      }
  
    /* Make sure that function is small enough to be considered for inlining.  */
!   if (!max_depth
!       || cgraph_estimate_size_after_inlining (1, node, node)  >= limit)
      return;
    lookup_recursive_calls (node, node, &first_call, &last_call);
    if (!first_call)
--- 1300,1309 ----
      }
  
    /* Make sure that function is small enough to be considered for inlining.  */
!   newsize = cgraph_estimate_size_after_inlining (1, node, node);
!   if (! max_depth
!       || newsize  >= limit
!       || (optimize_size && newsize > node->global.insns))
      return;
    lookup_recursive_calls (node, node, &first_call, &last_call);
    if (!first_call)

Reply via email to