std::pow implementation
Bernd Schmidt
bernds@redhat.com
Mon Aug 4 19:00:00 GMT 2003
On Mon, 4 Aug 2003, Richard Earnshaw wrote:
> The issue here isn't what to do with really tiny functions, or even what
> to to with really enormous ones: it's entirely to do with the boundary
> between the two -- how does the compiler decide that it has crossed from
> one to the other? A smart compiler can work that out based on its
> knowledge of the machine. A dumb one can't. Do we want gcc to be smart
> or dumb?
It's not about we want. Wishful thinking doesn't help. It's about two
facts:
a) gcc is currently dumb
b) the inline keyword has only one reasonable meaning, regardless of
whether the compiler is smart or dumb.
To repeat the argument:
If we have a dumb compiler, the choices it makes are effectively random.
The programmer can get a big improvement by using inline carefully, iff
the compiler honours it. If it makes another random choice, the keyword
is effectively useless.
If we have a smart compiler, we can rely on it making good choices in
almost every case. We don't generally need to use inline, but there may
be cases where a human could demonstrate that it can improve code, iff
the compiler honours it.
The only imaginable alternative, for a really smart compiler, is to treat
the inline keyword as having no meaning at all, like register. So far, no
one has demonstrated the existence of a sufficiently smart algorithm.
Bernd
More information about the Gcc
mailing list