Re: Inlining can be _very_bad...

From: Benjamin LaHaise
Date: Wed Mar 28 2007 - 21:30:38 EST


On Thu, Mar 29, 2007 at 01:18:38AM +0200, J.A. Magallón wrote:
> It looks like is updating the stack on each iteration...This is -march=opteron
> code, the -march=pentium4 is similar. Same behaviour with gcc3 and gcc4.
>
> tst.c and Makefile attached.
>
> Nice, isn't it ? Please, probe where is my fault...

Yes, gcc sucks in its handling of large return values, news at 11. I have
several outstanding bugs on cases where gcc could keep things in registers
but doesn't.

That said, it tends to do much better on plain integer code, as that is
what it gets tuned for. Do NOT propagate the blanket myth that inlining is
a bad thing. It is very useful for small functions where the overhead
associated with call/ret sequences and register clobbers overshadows the
work being done. The call/ret updates alone can make a big difference when
there are lots of other (more useful) memory transactions to complete. Take
a look at things like the notifier hooks for an example of something that
does far too little work per function call and should really be inlined.

-ben
--
"Time is of no importance, Mr. President, only life is important."
Don't Email: <zyntrop@xxxxxxxxx>.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/