From: Jeff Law <law@redhat.com>
To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com
Subject: Re: RFC: Faster for_each_rtx-like iterators
Date: Fri, 09 May 2014 06:18:00 -0000 [thread overview]
Message-ID: <536C7345.4010106@redhat.com> (raw)
In-Reply-To: <87k39x48gu.fsf@talisman.default>
On 05/07/14 14:52, Richard Sandiford wrote:
> I noticed for_each_rtx showing up in profiles and thought I'd have a go
> at using worklist-based iterators instead. So far I have three:
>
> FOR_EACH_SUBRTX: iterates over const_rtx subrtxes of a const_rtx
> FOR_EACH_SUBRTX_VAR: iterates over rtx subrtxes of an rtx
> FOR_EACH_SUBRTX_PTR: iterates over subrtx pointers of an rtx *
>
> with FOR_EACH_SUBRTX_PTR being the direct for_each_rtx replacement.
Yea, for_each_rtx is a bit of a workhorse, so I'm not surprised it's
showing up on some profiles.
> I've locally replaced all for_each_rtx calls in the generic code with
> these iterators and they make things reproducably faster. The speed-up
> on full --enable-checking=release ./cc1 and ./cc1plus times is only about 1%,
> but maybe that's enough to justify the churn.
I'd consider that enough to justify the churn, especially if it's an
improvement we're seeing consistently rather than just something that's
helping pathological cases.
>
> Implementation-wise, the main observation is that most subrtxes are part
> of a single contiguous sequence of "e" fields. E.g. when compiling an
> oldish combine.ii on x86_64-linux-gnu with -O2, we iterate over the
> subrtxes of 7,636,542 rtxes. Of those:
Yea, makes sense. One could possibly carry this a step further and
realize that we could specialize the walkers. ie, rather than indexing
the rtx_code to get the rtx format, then iterate over that to find the
'e' fields, if we have an PLUS, then damn it, we ought to know how to
walk pretty directly.
>
> (A) 4,459,135 (58.4%) are leaf rtxes with no "e" or "E" fields,
> (B) 3,133,875 (41.0%) are rtxes with a single block of "e" fields and
> no "E" fields, and
> (C) 43,532 (00.6%) are more complicated.
>
> (A) is really a special case of (B) in which the block has zero length.
> Those are the only two cases that really need to be handled inline.
> The implementation does this by having a mapping from an rtx code to the
> bounds of its "e" sequence, in the form of a start index and count.
Right. So my thought above us just extending this a bit and realizing
that we don't need an index/count for most RTXs. That may (or may not)
be worth the extra pain. Your call whether or not to investigate that
further.
>
> Does this look like it's worth pursuing? If so, is it OK to start
> submitting now or should it wait until 4.9.1 is out? If it is OK,
> I plan to convert the ports too and get rid of for_each_rtx.
I think it's definitely worth pursuing. I suspect the release managers
would definitely want to wait for 4.9.1 :-)
jeff
next prev parent reply other threads:[~2014-05-09 6:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 20:52 Richard Sandiford
2014-05-07 21:31 ` Mike Stump
2014-05-08 1:20 ` Trevor Saunders
2014-05-08 6:25 ` Richard Sandiford
2014-05-08 6:30 ` Richard Sandiford
2014-05-08 11:20 ` Trevor Saunders
2014-05-09 6:18 ` Jeff Law [this message]
2014-05-09 10:41 ` Richard Biener
2014-05-17 7:34 ` Richard Sandiford
2014-05-19 18:19 ` Jeff Law
2014-05-19 18:46 ` Richard Sandiford
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=536C7345.4010106@redhat.com \
--to=law@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rdsandiford@googlemail.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).