On inlining in C++
Richard Guenther
rguenth@tat.physik.uni-tuebingen.de
Tue Aug 5 13:29:00 GMT 2003
On 5 Aug 2003, Gabriel Dos Reis wrote:
> Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
>
> | The point is, all these "people will optimize" suggestions go against
> | portability to different compilers.
>
> It is going to be non portable only if compiler back ends decide they
> know better and don't trust the programmer preference. Inline in C++
> precisely to cut down the non-portability. Inline in C++ does not
> mean "hey back-end, optimize this as you want".
The standard doesnt say something explicit about this. And current
practice of most compilers I know is to either ignore "inline" or give it
a boost in any heuristics they use. Most of them are weak in inlining
decisions (or fail to honour "inline"), so they fall on their face trying
to vectorize expression template code and drop from GFLOPS to MFLOPS
performance...
But at least most of them have constructs like #pragma inline or
#pragma inline complete to give control about inlining per call.
They also are a lot better with their decisions given profiling data.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
More information about the Gcc
mailing list