On inlining in C++
Joe Buck
jbuck@synopsys.com
Wed Aug 6 02:02:00 GMT 2003
On Tue, Aug 05, 2003 at 02:41:26PM -0700, Mike Stump wrote:
> On Tuesday, August 5, 2003, at 12:29 PM, Gabriel Dos Reis wrote:
> > | > It it a matter of bumping numbers.
> > |
> > | Ok, submit numbers for a testcase, before the change, a suggested
> >
> > sorry, I see I incorrect typed the message: I meant
> >
> > It is not a matter of bumping numbers.
>
> Ah, but I include algorithmic changes in the set of allowable changes
> as well, surely, that is sufficient. If not, please provide a testcase
> that cannot be solved this way, and the proof that it cannot be solved.
> :-)
OK, here's the algorithm: for -O2 and below, attempt to inline a C++
function if and only if it is either declared inline, or is defined in
a class body. I say "attempt" to excuse the places where we can't inline
because of recursion, excessive lookahead (call comes before the
definition), or some other reason that prevents inlining. Issue a
-Winline warning when inlining fails.
This might harm some users who don't use a coherent process to decide
what gets inlined. Fine. They will learn.
For -O3, try what you want, and maybe I could recommend its use someday,
but not for 3.2 or 3.3 and C++. For evidence why, I suggest looking at a
recent speed comparison between Gentoo and Debian versions of a number of
apps: why did Gentoo come out slower despite its custom optimizations? My
theory: -O3.
See
http://articles.linmagau.org/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=227
More information about the Gcc
mailing list