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]

Re: issues with inlining


On Thu, Jan 09, 2003 at 01:50:02PM -0800, Michel LESPINASSE wrote:
> > According to the docs
> > 
> >      `-O3' turns on all optimizations specified by `-O2' and also
> >      turns on the `inline-functions' option.

But that says nothing about priority regulation.

> > so why are you using -O3 if you want to control inlining by means of
> > the "inline" kwyword?

To let the compiler decide is MORE can be inlined than what I already
marked as must-be-inlined (although it doesn't do that :/).

> >>> 4) The instruction limit that can be set with -finline-limit
> >>>    seems to count instructions before optimization...
> >
> > True -- the inliner works at the source level before optimization is
> > performed.  This is the best way to do it.

Of course it is best to FIRST inline and THEN optimize - but, the set
instruction limit should be on the optimized result, not on on the
number of instructions before optimization.

> You're most probably right on average. But you sometimes see code that
> use compile-time constants for specialization, i.e. one big inline
> routine that evaluates to something small based on the value of some
> constant parameters. In this case, the fact the inliner only sees the
> huge initial routine instead of the smaller one after specialization,
> combined with the fact the programmer can not use the inline keyword
> to force inlining, is an issue.

Exactly my point.  I use HUGE template functions that go like:

  if (constant == 1)
  {
    ...
  }
  else if (constant == 2)
  {
    ...
  }
  
  etc etc.  We talk about a reduction of 100 in size ONLY because
  of if (CONSTANT) { } constructs.  The -finline-limit is really 
  un usable when it doesn't ignore the instructions in those
  blocks that will not be used.  Note that even with -O0 these
  blocks are removed... so why the need to count those instruction
  when deciding whether or not to inline the function?!

-- 
Carlo Wood <carlo@alinoe.com>


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