This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: std::pow implementation
On Jul 30, 2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> Alexandre Oliva <aoliva@redhat.com> writes:
> | On Jul 29, 2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
> |
> | > The point you seem to be missing is that whether a function is inlined
> | > depends on the context of use -- not just on its intrinsinc complexity.
> | > That is what is absurd. Not the mere statement of that fact.
> |
> | The context of use can make a *lot* of difference on whether it's
> | worth to inline a function or not.
> But, why don't you trust the programmer? Why do you insist that you
> know better than the programmer?
Because (1) inline is implicit in C++, (2) inline's fate is probably
no different from that of `register', and (3) what's profitable to
inline on one architecture may not be on another, making inline's use
highly non-portable should the compiler blindly trust it.
> | Consider a very complex function
> | that takes a boolean argument, used to enable or disable most of the
> | complexity in the function. If the caller passes a false boolean
> | argument, the function would simplify to pretty much nothing.
> This is not a convincing example.
You may want to try this argument line with the customer that
approached us with this very request :-)
> | Therefore claiming that the context of use shouldn't play any role in
> | deciding whether a function should be inlined is absurd.
> No, what is absurb is the imaginary scenario you describ above.
It's not imaginary. It comes up in real life very often. Not
necessarily with boolean arguments, but integer constants known at
compile time are often passed to functions, and this enables
significant simplifications. I'm not making this up. This is a
feature that would be very nice to have, but we don't have mechanisms
to do anything like `try inlining, see whether it enables significant
simplification and, if not, outline it.'
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer