This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Sigh. Inlining heuristics.
- To: Alexandre Oliva <aoliva at redhat dot com>
- Subject: Re: Sigh. Inlining heuristics.
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Tue, 10 Jul 2001 19:57:03 -0700 (PDT)
- cc: <dewar at gnat dot com>, <mark at codesourcery dot com>, <dan at cgsoftware dot com>, <gcc at gcc dot gnu dot org>
On 10 Jul 2001, Alexandre Oliva wrote:
>
> We already do. My proposal is only for the default value. And it's
> hard to tell whether it's really going to give worse performance.
> There's a cache hit, indeed, if you inline the same large function
> into multiple other functions, but if you call it only once, and you
> get it inlined, you'd be saving the function-call overhead without any
> cache hit
Nope.
The way gcc currently generates code, you'll often get _worse_ code from
inlining, because it often adds register pressure when gcc decides to keep
stuff live for long stretches. Very noticeable on x86 with the few
registers - you can get into stack slot reload hell, causing much worse
code generation than if you didn't inline.
So when you inline, you quite often
- make code bigger
- make code _slower_ than if you just had a "call"
- make the compile slower
Ie you have _no_ gains anywhere.
So you really shouldn't inline too aggressively. (The new register-
allocator branch may fix most of the code generation issue. At least I
_hope_ it will fix the register allocation issues gcc has some day).
Linus