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]

Re: Patch to -Os


> The idea is that a function call is at least 1 instruction (call) plus 1.5
> instructions per argument (well, constants are one or two insns, simple
> variables are one or two insns..), so doing the inline with small functions
> might be even better than calling them, since the actual call needs more
> instructions (there _are_ such functions!)

jbuck@synopsys.com said:
> Yes, such functions are extremely common in C++ (e.g. a member
> function that just returns some field of a class).  Out-of-line calls
> will not save space.  It would make sense to always inline extremely
> small functions, for a suitable definition of small, even when
> optimizing for space.

I find that optimizing for speed and space are not necessarily exclusive.
I fight for every byte of space when writing embedded C++ code.

I think that the simple instruction count is not enough to express the
advantage of proper inlining. Often, code that is inlined can shrink more
then otherwise thanks to CSE, constant propagation, whatever, so that even
some functions longer then a function call reduce to smaller then a call
sequence. Indeed, sometimes it reduces to <0 size!

-- 
Steve Williams                "The woods are lovely, dark and deep.
steve@icarus.com              But I have promises to keep,
steve@picturel.com            and lines to code before I sleep,
http://www.picturel.com       And lines to code before I sleep."




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