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]

Re: [RFA] Kill artificial inlining limit


Hi,

On Tue, 13 May 2003, Gerald Pfeifer wrote:

> > It would be better to adjust the inlining heuristic to inline your very
> > small constructors despite the limit.  Or I envision to let the maximum
> > size of inlinable functions depend on the remaining size up to a certain
> > limit (so that later only smaller functions are inlined).
>
> The true fix, IMNSHO, is to inline bottom-up, not top-down

Well, it's not that easy.  There are cases which bottom-up doesn't get
right, and there are ones where top-down breaks.  Normally you would
probably need two passes over the call-tree, one BU, on TD.  For instance:

void big_but_not_too_big (void) { ... }
void very_small (void) {
  if (very_seldom)
    big_but_not_too_big ();
  something_small();
}

Now suppose there are many calls to very_small().  Inlining bottom-up
would inline big_but_not_too_big() into very_small(), making that one too
big to be inlined into all callers, and because it's seldomly called
wouldn't even improve performance.

Inlining top-down does the right thing here (inline very_small into all
callers, because it's so small, but not inlining big_but_not_too_big()).

There are equivalent cases where top-down is clearly inferior to
bottom-up.  Going twice over the call tree could probably solve some of
the problems.

> But isn't tree-ssa going in that direction?

tree-ssa is only another IR.  I'm not sure they also change the inlining
algorithm.  In fact with the unit-at-a-time mode we already do have the
call tree, so could possibly already change the algorithm used.


Ciao,
Michael.


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