public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Stephen Williams <steve@icarus.icarus.com>
To: Joe Buck <jbuck@synopsys.com>
Cc: egcs@cygnus.com
Subject: Re: Patch to -Os
Date: Sat, 31 Jan 1998 22:46:00 -0000	[thread overview]
Message-ID: <199802010646.WAA09109@icarus.icarus.com> (raw)
In-Reply-To: <199802010203.SAA02484@atrus.synopsys.com>

> 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."



  reply	other threads:[~1998-01-31 22:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-31 12:09 Marc Lehmann
1998-01-31 18:04 ` Joe Buck
1998-01-31 22:46   ` Stephen Williams [this message]
1998-02-01  0:37     ` Jeffrey A Law
1998-02-01  1:05 ` Jeffrey A Law
1998-02-02 17:14 Mike Stump

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199802010646.WAA09109@icarus.icarus.com \
    --to=steve@icarus.icarus.com \
    --cc=egcs@cygnus.com \
    --cc=jbuck@synopsys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).