This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std::pow implementation


On Jul 30, 2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:

> If you give inline its original meaning, you won't run into the risk
> of the situation you're describing.

Which meaning are you talking about?  The meaning assigned to inline
in C++98 or in C99?  They have very different meanings, besides the
issue on whether inline affects the linkage of a function in C.

> | They are not designed to tune inlining, they're designed to impose
> | requirements on the compiler's behavior.  If they're abused for other
> | purposes, there's unfortunately nothing we can do about it other than
> | try to educate people about their intended uses.

> Why do you think "inline" is different?

Because at least in C99, inline is defined as a hint to make the
function call be fast, not as a requirement that inline substitution
be made.  Quoting the ISO C99 standard:

  [...] Making a function an inline function suggests that calls to the
  function be as fast as possible.  The extent to which such
  suggestions are effective is implementation-defined.  [6.7.4]/#5

If performing ``inline substitution'', that is one of the *example*
mechanisms mentioned in a footnote that explains what `as fast as
possible' is, doesn't make it faster than an out-of-line call, the
inline suggestion should be taken as a directive to keep it
out-of-line.

In order for a compiler to strictly follow the standard requirement
about inlining, it should be able to tell whether inline substitution
will actually speed things up.  Solving this problem can be
particularly tricky if the choice depends on arguments whose values
are not known at compile time.

-- 
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]