[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: KNF and the C preprocessor
On Mon, Dec 10, 2012 at 02:28:28PM -0600, David Young wrote:
> On Mon, Dec 10, 2012 at 07:37:14PM +0000, David Laight wrote:
> > a) #define macros tend to get optimised better.
> Better even than an __attribute__((always_inline)) function?
I'd like to submit that neither are a good thing, because human
beings are demonstrably quite bad at deciding when things should
be inlined, particularly in terms of the cache effects of excessive
Unless your compiler's truly awesome at global optimization (most of
which we turn off even in our compilers that can use it) it's not going
to manage to CSE away any uses of a macro. That's bad, because we have
a lot of macros that really are bad for performance when their code is
inserted inline all over the place (the old MALLOC() may have been among
worst). It's got the same (no) change with an always_inline function,
but it can do a little better with a function that's just declared static
inline, or the always_inline attribute wouldn't exist.
One reason why macros should die is that in the process, inappropriate
and harmful excessive inlining of code that would perform better if
it were called as subroutines would die.
Main Index |
Thread Index |