This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: On inlining in C++
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Matthias Benkmann <matthias at winterdrache dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 5 Aug 2003 15:00:49 +0200 (CEST)
- Subject: Re: On inlining in C++
Matthias Benkmann wrote:
> One thing that is often overlooked is that most programs written today
> (for desktop platforms, not embedded systems!) do not need inlining
> optimization AT ALL. All of the programs I've written so far perform
> adequately regardless of whether I compile them with -Os, -O1, -O2 or -O3,
> -finline-functions, -whatever. The importance of optimization is vastly
> overrated. There are very few applications for which optimization makes a
> major difference (e.g. software MPEG-decoders). And these applications are
> usually carefully examined and maintained by capable people. These people
> should have a portable way of making their own inlining decisions. These
> are the people who complain if they can't do so. These are the people who
> complain if a new GCC version has a regression in the automatic inliner.
> These are the people GCC should be optimized for.
>
> The vast majority of developers won't notice the difference either way.
> But even they will be more happy if they look at the assembly of their
> compiled program and see that the compiler has inlined the functions they
> declared inline. It gives them the reassuring feeling that they are in
> charge.
The point is, all these "people will optimize" suggestions go against
portability to different compilers. Optimizing inlining in a portable
way ist just not possible - neither the C++ standard, nor compilers
practice of interpreting it helps you at this task.
So to say it in other words: The only way to get good performance with
regard to inlining out of "portable" C++ programs is to improve the
automatic inlining heuristics of the _compiler_. You just cannot apply the
same heuristics wrt placing the "inline" keyword for gcc on ia32 and f.i.
the C++ compiler on a Hitachi SR8000 pseudo-vector computer. This is
the world of HPC and not about micro-optimizing your mpeg player.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/