Re: Book on low level program optimization



Richard E Maine wrote:

No, statement functions are not necessarily inlined. That is not an inherent property of statement functions. The standard mentions nothing on the subject.

It happens that many implementations do inline statement functions, but that is not inherent in their definition. It is just that their definition means that they are inevitably simple enough to be good candidates for inlining. Therefore, they often are inlined, but not always.

There is a story I posted not so long ago about a benchmark program that was written almost entirely with statement functions. It turned out that one compiler not only inlined statement functions but did constant expression evaluation, and so did the whole benchmark at compile time.
It seems that this was surprising at the time, so either inlining statement functions or constant expression evaluation must not have been too common.


With the ever decreasing price for memory, I would be surprised if a modern compiler didn't inline them, but in any memory constrained system
I probably wouldn't do it.


Also, there are compilers with the option to optimize for time or memory usage. That might also affect statement function inlining.

-- glen

.



Relevant Pages