public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matt <matt@use.net>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Maxim Kuvyrkov <maxim@codesourcery.com>,
	    GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Add capability to run several iterations of early optimizations
Date: Fri, 28 Oct 2011 22:30:00 -0000	[thread overview]
Message-ID: <Pine.NEB.4.64.1110281450220.15721@cesium.clock.org> (raw)
In-Reply-To: <CAFiYyc3VB+eM-G_rSDfgCou0BG7ir0gsGr5UjaAaBVXaXH7gmg@mail.gmail.com>

On Fri, 28 Oct 2011, Richard Guenther wrote:

> I discussed the idea of iterating early optimizations shortly with Honza.
> I was trying to step back a bit and look at what we try to do right now,
> which is, optimize functions in topological order (thus, try to make sure
> all callees are already early optimized when optimizing callers).  That
> of course is difficult when there are cycles in the cgraph (for which we
> basically start at a random place), especially when there would be
> may-edges (which we do not have) for indirect/virtual calls, as they
> basically make the whole cgraph cyclic.  So my idea was to make
> cycle processing more explicit in early optimizations, and, whenever
> we discover a new direct cgraph edge make sure we optimize the
> callee, and whenever we optimized a callee queue all callers for
> re-optimization.  You of course have to limit the number of times you
> want to process a function, otherwise for a cycle, you'd optimize
> indefinitely.  We already do the inlining itself repeatedly (via
> --param early-inliner-max-iterations), though that only iterates
> the inlining itself, allowing for "deep" inlining and some cases
> of inlining of indirect calls if the inliner substituted a function
> pointer parameter into a call of the inlined function.  Moving that
> iteration over to iterating over the optimizations could make sense.

Inverting the patch's current approach makes sense to me, and may be 
preferrable from a usability perspective. That is, since each iteration 
increases compile time the user is indirectly specifying how long they're 
willing to give the compiler to get the best code. That being said, I'd be 
curious what the "maximum" number of iterations would be on something like 
Firefox/WebKit when compiled with LTO. On the proprietary codebase we 
tested on, there were still things being discovered at 120+ iterations 
(~100KLOC, compiled with mega-compilation aka the poor-man's LTO).

This could actually speed things up quite a bit if it means that we would 
only re-run the early passes on the functions whose call-chain had some 
optimization applied. That is, that the parts of the code being 
re-analyzed/optimized would narrow with each iteration, potentially 
reducing the overhead of multiple passes in the first place.


> Thus, I'd really like to at least make iterating depend on some
> profitability analysis, even if it is only based on cgraph analysis
> such as 'we discovered a new direct edge'.

That makes sense to me, but then again I'm not implementing it ;) FWIW, I 
implemented a similar rule in a static analysis product I wrote a few 
years ago -- if no new information was discovered on a given bottom-up 
pass, move onto the next analysis.

Thanks again for taking the time to work through this!


--
tangled strands of DNA explain the way that I behave.
http://www.clock.org/~matt

  reply	other threads:[~2011-10-28 22:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 22:47 Matt
2011-10-28 10:01 ` Richard Guenther
2011-10-28 22:30   ` Matt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-10-12  8:14 Maxim Kuvyrkov
2011-10-12 12:15 ` Richard Guenther
2011-10-18  3:00   ` Maxim Kuvyrkov
2011-10-18  9:09     ` Richard Guenther
2011-10-27 23:29       ` Maxim Kuvyrkov
2011-10-28 11:12         ` Richard Guenther
2011-10-28 23:07           ` Maxim Kuvyrkov
2011-10-29  0:10             ` Matt
2011-11-01 20:48               ` Martin Jambor
2011-11-01 21:33               ` Richard Guenther
2011-11-08  7:23                 ` Maxim Kuvyrkov
2011-11-08 11:18                   ` Richard Guenther

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=Pine.NEB.4.64.1110281450220.15721@cesium.clock.org \
    --to=matt@use.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=maxim@codesourcery.com \
    --cc=richard.guenther@gmail.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).