This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/RFA?] Enabling unit-at-a-time for -O2 and increasing inline limits


Hi,
I would like to suggest enabling unit-at-a-time at -O2 by default and
increasing the inline limits.  At SuSE we did quite extensive testing of
unit-at-a-time mode and I were able to build big C++ packages using it (like
KDE) with a code size decrease on the whole thing even with inlining
limits set up.

We also did SPEC benchmarking with possitive overall effect and found
the limit of 150 to be about the best code size/performance ratio
(behind that value the speedups seems to be relatively low given the
runtime costs).

The bootstrap times appears to be almost unchanged - insn-recog compiles
longer causing raw compiler to bootstrap slower and libstdc++ compiles
faster compensating the delay.

As discussed earlier on the lists, I also increased the inline limits for
inline functions to 500.  This should help people complaining that their inline
functions are not inlined.
I also tested Gerald's testcase to verify that increasing inline limits does
not hurt compile time perfomrance much.  It is about 20 seconds out of 4 minute
-O2 compilation, still faster than with -fno-unit-at-a-time and the current
settings.

For POOMA testcase I get increase from 1m49s to 2m1s compile time increase
with unit-at-a-time.  Without unit-at-a-time I stopped it after 15 minutes.

We still do have limits on overall compilation unit growh and large functions
to trottle down the expenses that appears to work better.  In my simple test
there is no single file in GCC distribution hitting these limits, but when i do
intermodule, I hit them as there are very many inline candidates, so in the
longer term I expect these two parameters to be more important than the
function body sizes.  (for your amusement, the most expensive function GCC
inlined is end_sequence :)

There are possible problems:
 - some programs are using top level asm statements and needs to be fixed
   SuSE will hopefully take care of most of these packages
 - increased memory requirements of unit-at-a-time
   As posted previously for moderately sized units, like combine.c is we get
   memory savings because of not sharing frontend and backend data together
   and releasing some of frontend data early, tought it is easy to make large
   unit constructed out of small uninlinable functions to see problem.
   With --enable-intermodule I need about 700MB to parse GCC and I hope to
   improve this a bit.
 - There has been number of problems in C++ frontend and still probably some
   will be found so it is not completely smooth transition.

OK for mainline?

Thu Sep  4 10:47:52 CEST 2003  Jan Hubicka  <jh@suse.cz>
	* opts.c (decode_options): Enable unit-at-a-time at -O2.
	* params.def (max-inline-insns-single): Set to 500
	(max-inline-insns-auto): Set to 150
	* invoke.texi (max-inline-insns-single, max-inline-insns-auto): Update.
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.37
diff -c -3 -p -r1.37 opts.c
*** opts.c	3 Sep 2003 20:57:31 -0000	1.37
--- opts.c	4 Sep 2003 08:47:23 -0000
*************** decode_options (unsigned int argc, const
*** 556,561 ****
--- 556,562 ----
        flag_delete_null_pointer_checks = 1;
        flag_reorder_blocks = 1;
        flag_reorder_functions = 1;
+       flag_unit_at_a_time = 1;
      }
  
    if (optimize >= 3)
*************** decode_options (unsigned int argc, const
*** 563,569 ****
        flag_inline_functions = 1;
        flag_rename_registers = 1;
        flag_unswitch_loops = 1;
-       flag_unit_at_a_time = 1;
      }
  
    if (optimize < 2 || optimize_size)
--- 564,569 ----
Index: params.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.def,v
retrieving revision 1.28
diff -c -3 -p -r1.28 params.def
*** params.def	19 Jul 2003 08:13:56 -0000	1.28
--- params.def	4 Sep 2003 08:47:23 -0000
*************** Software Foundation, 59 Temple Place - S
*** 51,57 ****
  DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
  	  "max-inline-insns-single",
  	  "The maximum number of instructions in a single function eligible for inlining",
! 	  100)
  
  /* The single function inlining limit for functions that are
     inlined by virtue of -finline-functions (-O3).
--- 51,57 ----
  DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
  	  "max-inline-insns-single",
  	  "The maximum number of instructions in a single function eligible for inlining",
! 	  500)
  
  /* The single function inlining limit for functions that are
     inlined by virtue of -finline-functions (-O3).
*************** DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
*** 63,69 ****
  DEFPARAM (PARAM_MAX_INLINE_INSNS_AUTO,
  	  "max-inline-insns-auto",
  	  "The maximum number of instructions when automatically inlining",
! 	  100)
  
  /* The repeated inlining limit.  After this number of instructions 
     (in the internal gcc representation, not real machine instructions)
--- 63,69 ----
  DEFPARAM (PARAM_MAX_INLINE_INSNS_AUTO,
  	  "max-inline-insns-auto",
  	  "The maximum number of instructions when automatically inlining",
! 	  150)
  
  /* The repeated inlining limit.  After this number of instructions 
     (in the internal gcc representation, not real machine instructions)
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.332
diff -c -3 -p -r1.332 invoke.texi
*** doc/invoke.texi	3 Sep 2003 20:57:31 -0000	1.332
--- doc/invoke.texi	4 Sep 2003 08:47:24 -0000
*************** This number sets the maximum number of i
*** 4590,4596 ****
  internal representation) in a single function that the tree inliner 
  will consider for inlining.  This only affects functions declared
  inline and methods implemented in a class declaration (C++).
! The default value is 100.
  
  @item max-inline-insns-auto
  When you use @option{-finline-functions} (included in @option{-O3}),
--- 4590,4596 ----
  internal representation) in a single function that the tree inliner 
  will consider for inlining.  This only affects functions declared
  inline and methods implemented in a class declaration (C++).
! The default value is 500.
  
  @item max-inline-insns-auto
  When you use @option{-finline-functions} (included in @option{-O3}),
*************** a lot of functions that would otherwise 
*** 4598,4604 ****
  by the compiler will be investigated.  To those functions, a different
  (more restrictive) limit compared to functions declared inline can
  be applied.
! The default value is 100.
  
  @item max-inline-insns
  The tree inliner does decrease the allowable size for single functions 
--- 4598,4604 ----
  by the compiler will be investigated.  To those functions, a different
  (more restrictive) limit compared to functions declared inline can
  be applied.
! The default value is 150.
  
  @item max-inline-insns
  The tree inliner does decrease the allowable size for single functions 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]