public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Geoff Keating <geoffk@geoffk.org>
To: Joe Buck <jbuck@synopsys.com>
Cc: gdr@integrable-solutions.net, gcc@gcc.gnu.org
Subject: Re: On inlining in C++
Date: Mon, 04 Aug 2003 19:01:00 -0000	[thread overview]
Message-ID: <jm65ldxnvz.fsf@desire.geoffk.org> (raw)
In-Reply-To: <20030804103355.A25321@synopsys.com>

Joe Buck <jbuck@synopsys.com> writes:

> On Mon, Aug 04, 2003 at 12:35:48PM -0400, Robert Dewar wrote:
> > > Excellent article.  I think that anyone who wishes to oppose the argument
> > > should be asked to demonstrate that we can get better quality of results
> > > by deviating from the simple approach Gaby describes; philosophical
> > > arguments should not suffice.
> > 
> > Well there is a burden of demonstration on both sides I would say, in terms
> > of showing behavior on actual code.
> 
> Don't forget that the biggest complaint we have about GCC is how slow the
> compiler is.  Ignoring or partially ignoring "inline", and doing analysis
> instead, costs time.
> 
> I suggest resolving this argument by doing an experiment.
> 
> Option 1: a version of GNU C++ that
> 
> * honors the "inline" keyword in all situations where the compiler is
>   capable of inlining the call
> * does the same for functions defined in the class body
> * when -Winline is given, issues a warning and explanation about why
>   a call is not inlined
> * avoids computing any metrics related to inlining decisions (unless -O3)
> 
> Option 2: a version of GNU C++ that uses the smartest heuristics that the
> "ignore inline" advocates can come up with.

I completely agree.

However, I claim that option (2) will always win or tie.  Why?
Because you can always use heuristics that are "inline exactly when
option (1) would have inlined".

In fact, I will go further, and claim that option (2) will win.
Saying that option (2) will tie is equivalent to saying that every
case of inlining triggered by option (1) is neutral or good for
performance, and I know that this is not true.  You can start by
rejecting cases that cannot possibly be good for performance.

> Now, build a lot of C++ code with -O2 for both options.  Measure compiler
> speed as well as speed and space of the final code.  If option 2 is
> consistently better, I surrender.  If option 2 is better only for one or
> two programs, and it turns out that these programs use "inline" in
> inappropriate ways, then the programs should be fixed.

Don't forget to test on multiple targets!

-- 
- Geoffrey Keating <geoffk@geoffk.org>

  parent reply	other threads:[~2003-08-04 18:45 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-04 16:38 Robert Dewar
2003-08-04 16:46 ` Andrew Haley
2003-08-04 17:35 ` Joe Buck
2003-08-04 17:54   ` Daniel Berlin
2003-08-04 19:01   ` Geoff Keating [this message]
2003-08-04 19:22     ` Joe Buck
2003-08-05  8:26 ` Richard Sandiford
2003-08-05  9:24   ` Steven Bosscher
2003-08-05 12:23   ` Matthias Benkmann
  -- strict thread matches above, loose matches on Subject: below --
2003-08-06 21:37 Robert Dewar
2003-08-06 22:14 ` Joe Buck
2003-08-06  4:31 Robert Dewar
2003-08-06  5:13 ` Andreas Jaeger
2003-08-06  9:07 ` Steven Bosscher
2003-08-06 16:51 ` Joe Buck
2003-08-05 18:13 Robert Dewar
2003-08-05 18:17 ` Gabriel Dos Reis
2003-08-05 19:11   ` Geoff Keating
2003-08-06  2:15     ` Joe Buck
2003-08-06  2:31       ` Andrew Pinski
2003-08-06  2:47         ` Joe Buck
2003-12-15 18:49       ` Diego Novillo
2003-08-06 10:10     ` Richard Earnshaw
2003-08-06 11:51       ` Gabriel Dos Reis
2003-08-06 11:51         ` Richard Earnshaw
2003-08-06 18:06           ` Joe Buck
2003-08-05 17:28 Robert Dewar
2003-08-05 17:49 ` Gabriel Dos Reis
2003-08-05 17:06 Robert Dewar
2003-08-05 17:26 ` Gabriel Dos Reis
2003-08-05 17:57 ` Scott Robert Ladd
2003-08-06 19:49   ` Alexandre Oliva
2003-08-05 16:23 Robert Dewar
2003-08-05 16:22 Robert Dewar
2003-08-05 16:15 Robert Dewar
2003-08-05 13:22 Richard Guenther
2003-08-05 13:25 ` Gabriel Dos Reis
2003-08-05 13:29   ` Richard Guenther
2003-08-05 13:39     ` Gabriel Dos Reis
2003-08-05 14:49       ` Richard Guenther
2003-08-05 14:51         ` Gabriel Dos Reis
2003-08-05 18:39 ` Matthias Benkmann
2003-08-05 19:42   ` Steven Bosscher
2003-08-05 19:53     ` Gabriel Dos Reis
2003-08-06  2:19   ` Joe Buck
2003-08-05  8:55 Richard Guenther
2003-08-05  9:36 ` Thomas Kunert
2003-08-05  9:57   ` Richard Guenther
2003-08-05 10:06     ` Gabriel Dos Reis
2003-08-05 11:45       ` Richard Guenther
2003-08-04 17:50 Robert Dewar
2003-08-04 17:52 ` Gabriel Dos Reis
2003-08-04 17:41 Robert Dewar
2003-08-04 17:40 Robert Dewar
2003-08-04 17:52 ` Gabriel Dos Reis
2003-08-04 17:59   ` Daniel Jacobowitz
2003-08-04 18:09     ` Gabriel Dos Reis
2003-08-08 21:21 ` Marc Espie
2003-08-08 23:12   ` Kevin Atkinson
2003-08-04 17:39 Robert Dewar
2003-08-04 17:51 ` Gabriel Dos Reis
2003-08-04 17:35 Robert Dewar
2003-08-04 17:44 ` Gabriel Dos Reis
2003-08-05 16:58 ` Scott Robert Ladd
2003-08-04 17:33 Robert Dewar
2003-08-04 17:34 ` Gabriel Dos Reis
2003-08-04 17:15 Robert Dewar
2003-08-04 17:26 ` Andrew Haley
2003-08-04 17:28 ` Gabriel Dos Reis
2003-08-04 17:11 Robert Dewar
2003-08-04 17:22 ` Gabriel Dos Reis
2003-08-04 16:50 Robert Dewar
2003-08-04 17:02 ` Joe Buck
2003-08-04 17:05 ` Andrew Haley
2003-08-04 18:30 ` Bernd Schmidt
2003-08-26 15:11 ` Nick Ing-Simmons
2003-08-04 13:51 Gabriel Dos Reis
2003-08-04 16:36 ` Joe Buck
2003-08-05  7:37   ` Mike Stump
2003-08-05  7:44     ` Thomas Kunert
2003-08-05  8:55     ` Gabriel Dos Reis
2003-08-05 19:33       ` Mike Stump
2003-08-05 19:46         ` Gabriel Dos Reis
2003-08-06  0:57           ` Mike Stump
2003-08-06  2:02             ` Joe Buck
2003-08-06  2:20               ` Scott Robert Ladd
2003-08-05 21:12         ` Gabriel Dos Reis
2003-08-05 21:12         ` Scott Robert Ladd
2003-08-06  2:00     ` Joe Buck
2003-08-06  9:30       ` Gerald Pfeifer
2003-08-06 13:57         ` Gabriel Dos Reis
2003-08-05 19:10 ` Matthias Benkmann

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=jm65ldxnvz.fsf@desire.geoffk.org \
    --to=geoffk@geoffk.org \
    --cc=gcc@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    --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).