This is the mail archive of the gcc-patches@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]

[PATCH] New code size estimate


This is the same patch as
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01571.html
but with inlining limits 10% reduced to the respective 3.4 value.
This 10% reduction is a lower bound on the average shrinkage
of the code size estimation compared to 3.4 collected from
compiling GCC.

Bootstrapped and tested on x86_64-unknown-linux-gnu with no regressions.

Ok for mainline?

Richard.


2005-Feb-28  Richard Guenther  <rguenth@gcc.gnu.org>

	* tree-inline.c (estimate_num_insns_1): Ignore stores to decls with
	ignored flag set.
	* params.def: Lower inlining limits to 10% below the 3.4 value.
	* invoke.texi: Update inlining limits.

	* gcc.dg/winline-6.c (t): Adjust function body size for changed
	size estimate.


Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.170
diff -c -3 -p -r1.170 tree-inline.c
*** tree-inline.c	27 Jan 2005 14:36:17 -0000	1.170
--- tree-inline.c	28 Feb 2005 09:42:53 -0000
*************** estimate_num_insns_1 (tree *tp, int *wal
*** 1247,1255 ****
         big arrays.  */
      case INIT_EXPR:
      case MODIFY_EXPR:
        x = TREE_OPERAND (x, 0);
        /* FALLTHRU */
-     case TARGET_EXPR:
      case CONSTRUCTOR:
        {
  	HOST_WIDE_INT size;
--- 1247,1257 ----
         big arrays.  */
      case INIT_EXPR:
      case MODIFY_EXPR:
+     case TARGET_EXPR:
        x = TREE_OPERAND (x, 0);
+       if (DECL_P (x) && DECL_IGNORED_P (x))
+ 	break;
        /* FALLTHRU */
      case CONSTRUCTOR:
        {
  	HOST_WIDE_INT size;
Index: params.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/params.def,v
retrieving revision 1.54
diff -c -3 -p -r1.54 params.def
*** params.def	1 Feb 2005 10:03:08 -0000	1.54
--- params.def	28 Feb 2005 09:42:53 -0000
*************** DEFPARAM (PARAM_SRA_FIELD_STRUCTURE_RATI
*** 58,67 ****
     of a function counted in internal gcc instructions (not in
     real machine instructions) that is eligible for inlining
     by the tree inliner.
!    The default value is 500.
     Only functions marked inline (or methods defined in the class
!    definition for C++) are affected by this, unless you set the
!    -finline-functions (included in -O3) compiler option.
     There are more restrictions to inlining: If inlined functions
     call other functions, the already inlined instructions are
     counted and once the recursive inline limit (see
--- 58,66 ----
     of a function counted in internal gcc instructions (not in
     real machine instructions) that is eligible for inlining
     by the tree inliner.
!    The default value is 450.
     Only functions marked inline (or methods defined in the class
!    definition for C++) are affected by this.
     There are more restrictions to inlining: If inlined functions
     call other functions, the already inlined instructions are
     counted and once the recursive inline limit (see
*************** DEFPARAM (PARAM_SRA_FIELD_STRUCTURE_RATI
*** 70,76 ****
  DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
  	  "max-inline-insns-single",
  	  "The maximum number of instructions in a single function eligible for inlining",
! 	  500, 0, 0)

  /* The single function inlining limit for functions that are
     inlined by virtue of -finline-functions (-O3).
--- 69,75 ----
  DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
  	  "max-inline-insns-single",
  	  "The maximum number of instructions in a single function eligible for inlining",
! 	  450, 0, 0)

  /* The single function inlining limit for functions that are
     inlined by virtue of -finline-functions (-O3).
*************** DEFPARAM (PARAM_MAX_INLINE_INSNS_SINGLE,
*** 78,98 ****
     that is applied to functions marked inlined (or defined in the
     class declaration in C++) given by the "max-inline-insns-single"
     parameter.
!    The default value is 150.  */
  DEFPARAM (PARAM_MAX_INLINE_INSNS_AUTO,
  	  "max-inline-insns-auto",
  	  "The maximum number of instructions when automatically inlining",
! 	  120, 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",
! 	  500, 0, 0)

  DEFPARAM (PARAM_MAX_INLINE_INSNS_RECURSIVE_AUTO,
  	  "max-inline-insns-recursive-auto",
  	  "The maximum number of instructions non-inline function can grow to via recursive inlining",
! 	  500, 0, 0)

  DEFPARAM (PARAM_MAX_INLINE_RECURSIVE_DEPTH,
  	  "max-inline-recursive-depth",
--- 77,97 ----
     that is applied to functions marked inlined (or defined in the
     class declaration in C++) given by the "max-inline-insns-single"
     parameter.
!    The default value is 90.  */
  DEFPARAM (PARAM_MAX_INLINE_INSNS_AUTO,
  	  "max-inline-insns-auto",
  	  "The maximum number of instructions when automatically inlining",
! 	  90, 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",
! 	  450, 0, 0)

  DEFPARAM (PARAM_MAX_INLINE_INSNS_RECURSIVE_AUTO,
  	  "max-inline-insns-recursive-auto",
  	  "The maximum number of instructions non-inline function can grow to via recursive inlining",
! 	  450, 0, 0)

  DEFPARAM (PARAM_MAX_INLINE_RECURSIVE_DEPTH,
  	  "max-inline-recursive-depth",
*************** DEFPARAM(PARAM_MAX_PENDING_LIST_LENGTH,
*** 148,154 ****
  DEFPARAM(PARAM_LARGE_FUNCTION_INSNS,
  	 "large-function-insns",
  	 "The size of function body to be considered large",
! 	 3000, 0, 0)
  DEFPARAM(PARAM_LARGE_FUNCTION_GROWTH,
  	 "large-function-growth",
  	 "Maximal growth due to inlining of large function (in percent)",
--- 147,153 ----
  DEFPARAM(PARAM_LARGE_FUNCTION_INSNS,
  	 "large-function-insns",
  	 "The size of function body to be considered large",
! 	 2700, 0, 0)
  DEFPARAM(PARAM_LARGE_FUNCTION_GROWTH,
  	 "large-function-growth",
  	 "Maximal growth due to inlining of large function (in percent)",
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.583.2.1
diff -c -3 -p -r1.583.2.1 invoke.texi
*** doc/invoke.texi	26 Feb 2005 01:41:38 -0000	1.583.2.1
--- doc/invoke.texi	28 Feb 2005 09:42:54 -0000
*************** This number sets the maximum number of i
*** 5442,5448 ****
  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}),
--- 5442,5448 ----
  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 450.

  @item max-inline-insns-auto
  When you use @option{-finline-functions} (included in @option{-O3}),
*************** a lot of functions that would otherwise
*** 5450,5456 ****
  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 120.

  @item large-function-insns
  The limit specifying really large functions.  For functions larger than this
--- 5450,5456 ----
  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 90.

  @item large-function-insns
  The limit specifying really large functions.  For functions larger than this
*************** limit after inlining inlining is constra
*** 5459,5465 ****
  to avoid extreme compilation time caused by non-linear algorithms used by the
  backend.
  This parameter is ignored when @option{-funit-at-a-time} is not used.
! The default value is 3000.

  @item large-function-growth
  Specifies maximal growth of large function caused by inlining in percents.
--- 5459,5465 ----
  to avoid extreme compilation time caused by non-linear algorithms used by the
  backend.
  This parameter is ignored when @option{-funit-at-a-time} is not used.
! The default value is 2700.

  @item large-function-growth
  Specifies maximal growth of large function caused by inlining in percents.
*************** For functions declared inline @option{--
*** 5482,5488 ****
  taken into acount.  For function not declared inline, recursive inlining
  happens only when @option{-finline-functions} (included in @option{-O3}) is
  enabled and @option{--param max-inline-insns-recursive-auto} is used.  The
! default value is 500.

  @item max-inline-recursive-depth
  @itemx max-inline-recursive-depth-auto
--- 5482,5488 ----
  taken into acount.  For function not declared inline, recursive inlining
  happens only when @option{-finline-functions} (included in @option{-O3}) is
  enabled and @option{--param max-inline-insns-recursive-auto} is used.  The
! default value is 450.

  @item max-inline-recursive-depth
  @itemx max-inline-recursive-depth-auto
*************** For functions declared inline @option{--
*** 5492,5498 ****
  taken into acount.  For function not declared inline, recursive inlining
  happens only when @option{-finline-functions} (included in @option{-O3}) is
  enabled and @option{--param max-inline-recursive-depth-auto} is used.  The
! default value is 500.

  @item max-unrolled-insns
  The maximum number of instructions that a loop should have if that loop
--- 5492,5498 ----
  taken into acount.  For function not declared inline, recursive inlining
  happens only when @option{-finline-functions} (included in @option{-O3}) is
  enabled and @option{--param max-inline-recursive-depth-auto} is used.  The
! default value is 450.

  @item max-unrolled-insns
  The maximum number of instructions that a loop should have if that loop
Index: testsuite/gcc.dg/winline-6.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/winline-6.c,v
retrieving revision 1.1
diff -c -3 -p -r1.1 winline-6.c
*** testsuite/gcc.dg/winline-6.c	4 Jan 2004 14:39:13 -0000	1.1
--- testsuite/gcc.dg/winline-6.c	24 Feb 2005 22:36:08 -0000
*************** inline int q(void)
*** 17,21 ****
  }
  inline int t (void)
  {
! 	return q ();		 /* { dg-warning "called from here" } */
  }
--- 17,21 ----
  }
  inline int t (void)
  {
! 	return q () + 1;	 /* { dg-warning "called from here" } */
  }


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