2002-10-23 Kurt Garloff * params.def: Introduce parameter max-inline-insns-rtl for a separate limit for the RTL inliner. * params.h: Likewise. * integrate.c (function_cannot_inline_p): Use it. * toplev.c (decode_f_option): Set multiple parameters controlling inlining with -finline-limit. * params.def: Fix orthographic and typographic errors. * doc/invoke.texi: Document parameters controlling inlining and the way -finline-limit sets multiple of them. diff -uNr gcc.vanilla/gcc/doc/invoke.texi gcc.p1.docu/gcc/doc/invoke.texi --- gcc.vanilla/gcc/doc/invoke.texi Sat Oct 12 18:19:12 2002 +++ gcc.p1.docu/gcc/doc/invoke.texi Wed Oct 23 03:09:13 2002 @@ -3483,6 +3483,26 @@ means slower programs). This option is particularly useful for programs that use inlining heavily such as those based on recursive templates with C++. +Inlining is actually controlled by a number of parameters, which may be +specified individually by using @option{--param @var{name}=@var{value}}. +The @option{-finline-limit=@var{n}} option sets some of these parameters +as follows: + +@table @gcctabopt + @item max-inline-insns + is set to @var{n}. + @item max-inline-insns-single + is set to @var{n}/2. + @item min-inline-insns + is set to 130 or @var{n}/4, whichever is smaller. + @item max-inline-insns-rtl + is set to @var{n}. +@end table + +Using @option{-finline-limit=600} thus results in the default settings +for these parameters. See below for a documentation of the individual +parameters controlling inlining. + @emph{Note:} pseudo instruction represents, in this particular context, an abstract measurement of function's size. In no way, it represents a count of assembly instructions and as such its exact meaning might change from one @@ -4109,10 +4129,45 @@ with few branches or calls can create excessively large lists which needlessly consume memory and resources. +@item max-inline-insns-single +Several parameters control the tree inliner used in gcc. +This number sets the maximum number of instructions (counted in gcc's +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 300. + @item max-inline-insns -If an function contains more than this many instructions, it -will not be inlined. This option is precisely equivalent to -@option{-finline-limit}. +The tree inliner does decrease the allowable size for single functions +to be inlined after we already inlined the number of instructions +given here by repeated inlining. This number should be a factor of +two or more larger than the single function limit. +Higher numbers result in better runtime performance, but incur higher +compile-time resource (CPU time, memory) requirements and result in +larger binaries. Very high values are not advisable, as too large +binaries may adversely affect runtime performance. +The default value is 600. + +@item max-inline-slope +After exceeding the maximum number of inlined instructions by repeated +inlining, a linear function is used to decrease the allowable size +for single functions. The slope of that function is the negative +reciprocal of the number specified here. +The default value is 32. + +@item min-inline-insns +The repeated inlining is throttled more and more by the linear function +after exceeding the limit. To avoid too much throttling, a minimum for +this function is specified here to allow repeated inlining for very small +functions even when a lot of repeated inlining already has been done. +The default value is 130. + +@item max-inline-insns-rtl +For languages that use the RTL inliner (this happens at a later stage +than tree inlining), you can set the maximum allowable size (counted +in RTL instructions) for the RTL inliner with this parameter. +The default value is 600. + @item max-unrolled-insns The maximum number of instructions that a loop should have if that loop diff -uNr gcc.vanilla/gcc/integrate.c gcc.p1.docu/gcc/integrate.c --- gcc.vanilla/gcc/integrate.c Sat Oct 12 18:19:01 2002 +++ gcc.p1.docu/gcc/integrate.c Wed Oct 23 02:46:50 2002 @@ -157,11 +157,13 @@ tree last = tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))); /* For functions marked as inline increase the maximum size to - MAX_INLINE_INSNS (-finline-limit-). For regular functions - use the limit given by INTEGRATE_THRESHOLD. */ + MAX_INLINE_INSNS_RTL (--param max-inline-insn-rtl=). For + regular functions use the limit given by INTEGRATE_THRESHOLD. + Note that the RTL inliner is not used by the languages that use + the tree inliner (C, C++). */ int max_insns = (DECL_INLINE (fndecl)) - ? (MAX_INLINE_INSNS + ? (MAX_INLINE_INSNS_RTL + 8 * list_length (DECL_ARGUMENTS (fndecl))) : INTEGRATE_THRESHOLD (fndecl); diff -uNr gcc.vanilla/gcc/params.def gcc.p1.docu/gcc/params.def --- gcc.vanilla/gcc/params.def Sat Oct 12 18:19:01 2002 +++ gcc.p1.docu/gcc/params.def Wed Oct 23 03:11:11 2002 @@ -50,10 +50,10 @@ gets decreased. */ DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE, "max-inline-insns-single", - "The maximum number of instructions in a single function eliglible for inlining", + "The maximum number of instructions in a single function eligible for inlining", 300) - -/* The repeated inlining limit. After this number of instructions + +/* The repeated inlining limit. After this number of instructions (in the internal gcc representation, not real machine instructions) got inlined by repeated inlining, gcc starts to decrease the maximum number of inlinable instructions in the tree inliner. @@ -62,16 +62,14 @@ could otherwise become very high. It is recommended to set this value to twice the value of the single function limit (set by the "max-inline-insns-single" parameter) or - higher. The default value is 600. + higher. The default value is 600. Higher values mean that more inlining is done, resulting in better performance of the code, at the expense of higher compile-time resource (time, memory) requirements and larger - binaries. - This parameters also controls the maximum size of functions considered - for inlining in the RTL inliner. */ + binaries. */ DEFPARAM (PARAM_MAX_INLINE_INSNS, "max-inline-insns", - "The maximuem number of instructions by repeated inlining before gcc starts to throttle inlining", + "The maximum number of instructions by repeated inlining before gcc starts to throttle inlining", 600) /* After the repeated inline limit has been exceeded (see @@ -79,7 +77,7 @@ decrease the size of single functions eligible for inlining. The slope of this linear function is given the negative reciprocal value (-1/x) of this parameter. - The default vlue is 32. + The default value is 32. This linear function is used until it falls below a minimum value specified by the "min-inline-insns" parameter. */ DEFPARAM (PARAM_MAX_INLINE_SLOPE, @@ -90,9 +88,9 @@ /* When gcc has inlined so many instructions (by repeated inlining) that the throttling limits the inlining very much, inlining for very small functions is still desirable to - achieve good runtime performance. The size of single functions + achieve good runtime performance. The size of single functions (measured in gcc instructions) which will still be eligible for - inlining then is given by this parameter. It defaults to 130. + inlining then is given by this parameter. It defaults to 130. Only much later (after exceeding 128 times the recursive limit) inlining is cut down completely. */ DEFPARAM (PARAM_MIN_INLINE_INSNS, @@ -100,6 +98,16 @@ "The number of instructions in a single functions still eligible to inlining after a lot recursive inlining", 130) +/* For languages that (still) use the RTL inliner, we can specify + limits for the RTL inliner separately. + The parameter here defines the maximum number of RTL instructions + a function may have to be eligible for inlining in the RTL inliner. + The default value is 600. */ +DEFPARAM (PARAM_MAX_INLINE_INSNS_RTL, + "max-inline-insns-rtl", + "The maximum number of instructions for the RTL inliner", + 600) + /* The maximum number of instructions to consider when looking for an instruction to fill a delay slot. If more than this arbitrary number of instructions is searched, the time savings from filling diff -uNr gcc.vanilla/gcc/params.h gcc.p1.docu/gcc/params.h --- gcc.vanilla/gcc/params.h Wed Sep 4 08:51:10 2002 +++ gcc.p1.docu/gcc/params.h Tue Oct 22 15:42:44 2002 @@ -92,6 +92,8 @@ PARAM_VALUE (PARAM_MAX_INLINE_SLOPE) #define MIN_INLINE_INSNS \ PARAM_VALUE (PARAM_MIN_INLINE_INSNS) +#define MAX_INLINE_INSNS_RTL \ + PARAM_VALUE (PARAM_MAX_INLINE_INSNS_RTL) #define MAX_DELAY_SLOT_INSN_SEARCH \ PARAM_VALUE (PARAM_MAX_DELAY_SLOT_INSN_SEARCH) #define MAX_DELAY_SLOT_LIVE_SEARCH \ diff -uNr gcc.vanilla/gcc/toplev.c gcc.p1.docu/gcc/toplev.c --- gcc.vanilla/gcc/toplev.c Sat Oct 12 18:19:03 2002 +++ gcc.p1.docu/gcc/toplev.c Wed Oct 23 02:35:00 2002 @@ -3951,6 +3951,15 @@ read_integral_parameter (option_value, arg - 2, MAX_INLINE_INSNS); set_param_value ("max-inline-insns", val); + set_param_value ("max-inline-insns-single", val/2); + set_param_value ("max-inline-insns-rtl", val); + if (val/4 < MIN_INLINE_INSNS) + { + if (val/4 > 10) + set_param_value ("min-inline-insns", val/4); + else + set_param_value ("min-inline-insns", 10); + } } else if ((option_value = skip_leading_substring (arg, "tls-model="))) {