surprising optimization results

Paul Burchard burchard@pobox.com
Tue Aug 31 23:20:00 GMT 1999


Joe Buck wrote:
> Inline functions in gcc suffer because gcc makes a decision too early
> about what needs to go into memory.  In this case, I believe it is because
> the arguments have their addresses taken, they are forced to memory.
> After inlining, arguably there is no longer any object that has its
> address taken..  But often the generated code still has dead stores
> in it (structs or classes written to memory and never read back).

Thanks, it helps to know that this could be a general effect (and not
merely the usual confluence of myriad details affecting optimization). 
I'm a little surprised that call-by-reference is always interpreted as
call-by-pointer-value, but I guess you're saying that's a reasonable
implementation technique, as long as you have good dead-store analysis.

Const reference arguments, by the way, seem to be handled differently
(or at least the dead-store analysis has an easier time removing the
extra layer of indirection).  They are as efficient as by-value scalar
arguments in every test I've tried.

-- 
----------------------------------------------------------------------
Paul Burchard   <burchard@pobox.com>   http://www.pobox.com/~burchard/
----------------------------------------------------------------------




More information about the Gcc mailing list