From: Richard Sandiford <rdsandiford@googlemail.com>
To: Jeff Law <law@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH 0/5] Cache recog_op_alt by insn code, take 2
Date: Sat, 31 May 2014 09:02:00 -0000 [thread overview]
Message-ID: <87mwdyfhhg.fsf_-_@talisman.default> (raw)
In-Reply-To: <537B9911.7070604@redhat.com> (Jeff Law's message of "Tue, 20 May 2014 12:04:01 -0600")
Sorry Jeff, while working on the follow-on LRA patch I came across
a couple of problems, so I need another round on this.
First of all, I mentioned doing a follow-on patch to make LRA and
recog use the same cache for operand_alternatives. I hadn't realised
until I wrote that patch that there's a significant difference between
the LRA and recog_op_alt versions of the information: recog_op_alt
groups alternatives together by operand whereas LRA groups operands
together by alternative. So in the cached flat array, recog_op_alt
uses [op * n_alternatives + alt] whereas LRA uses [alt * n_operands + nop].
The two could only share a cache if they used the same order.
I think the LRA ordering makes more sense. Quite a few places are
only interested in alternative which_alternative, so grouping operands
together by alternative gives a natural subarray. And there are places
in IRA (which uses recog_op_alt rather than the LRA information) where
the "for each alternative" loop is the outer one.
A second difference was that preprocess_constraints skips disabled
alternatives while LRA's setup_operand_alternative doesn't; LRA just
checks for disabled alternatives when walking the array instead.
That should make no difference in practice, but since the LRA approach
would also make it easier to precompute the array at build time,
I thought it would be a better way to go. It also gives a cleaner
interface: we can have a preprocess_insn_constraints function that
takes a (define_insn-based) insn and returns the operand_alternative
information without any global state.
Also, it turns out that sel-sched.c, regcprop.c and regrename.c
modify the recog_op_alt structure as a convenient way of handling
matching constraints. That obviously isn't a good idea if we want
other passes to reuse the data later. I've fixed that and made the
types "const" so that new instances shouldn't creep in.
Also, I hadn't realised that a define_insn with no constraints
at all has 0 alternatives rather than 1. Some passes nevertheless
unconditionally access the recog_op_alt information for alternative
which_alternative.
I could have fixed that by making n_alternatives always be >= 1
in the static insn table. Several places do have fast paths for
n_alternatives == 0 though, so I thought it would be better to
handle the 0 alternative case in preprocess_constraints as well.
All it needs is a MIN (..., 1).
So the patch has now grown to 5 subpatches:
1. make recog_op_alt a flat array and order it in the same way as LRA
2. fix the places that modified recog_op_alt locally
3. don't handle the enabled attribute in preprocess_constraints and make
sure all consumers check for disabled alternatives explicitly
4. the updated version of the original patch
5. get LRA to use the new cache too (the original follow-on patch)
Jeff Law <law@redhat.com> writes:
> On 05/20/14 02:19, Richard Sandiford wrote:
>> Following on from (and depending on) the last patch, process_constraints
>> also shows up high in the profile. This patch caches the recog_op_alt
>> information by insn code too. It also shrinks the size of the structure
>> from 1 pointer + 5 ints to 1 pointer + 2 ints:
>>
>> - no target should have more than 65536 register classes :-)
> That could probably be much lower if we needed more bits for other things.
>
>> - "reject" is based on a cost of 600 for '!', so 16 bits should be plenty
> OK. Makes sense.
>
>
>> - "matched" and "matches" are operand numbers and so fit in 8 bits
> OK. This could also be smaller, don't we have an upper limit of 32 (or
> 30?) on the number of operands appearing in an insn. It'd be a way to
> get a few more bits if we need them someday.
Yeah, we could probably squeeze everything into a single int if we needed
to and if we were prepared to have non-byte-sized integer fields.
Going from 2 ints to 1 int wouldn't help LP64 hosts as things stand
though, since we have a pointer at the beginning of the struct.
Boostrapped & regression-tested on x86_64-linux-gnu. Also tested by
building gcc.dg, g++.dg and gcc.c-torture for one target per config/
directory and making sure that there were no asm differences.
Thanks,
Richard
next prev parent reply other threads:[~2014-05-31 9:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 8:19 RFA: cache recog_op_alt by insn code Richard Sandiford
2014-05-20 18:04 ` Jeff Law
2014-05-26 19:21 ` Require '%' to be at the beginning of a constraint string Richard Sandiford
2014-05-27 17:41 ` Jeff Law
2014-05-28 19:50 ` Richard Sandiford
2014-05-30 16:24 ` Jeff Law
2014-05-31 9:02 ` Richard Sandiford [this message]
2014-05-31 9:06 ` [PATCH 1/5] Flatten recog_op_alt and reorder entries Richard Sandiford
2014-06-03 21:50 ` Jeff Law
2014-05-31 9:09 ` [PATCH 2/5] Don't modify recog_op_alt after preprocess_constraints Richard Sandiford
2014-06-03 21:53 ` Jeff Law
2014-05-31 9:15 ` [PATCH 3/5] Make recog_op_alt consumers check the enabled attribute Richard Sandiford
2014-06-03 21:58 ` Jeff Law
2014-06-04 17:37 ` Richard Sandiford
2014-05-31 9:17 ` [PATCH 4/5] Cache recog_op_alt by insn code: main patch Richard Sandiford
2014-06-03 22:01 ` Jeff Law
2014-05-31 9:23 ` [PATCH 5/5] Reuse recog_op_alt cache in LRA Richard Sandiford
2014-06-03 22:02 ` Jeff Law
2014-06-03 21:38 ` [PATCH 0/5] Cache recog_op_alt by insn code, take 2 Jeff Law
2014-06-04 17:39 ` 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=87mwdyfhhg.fsf_-_@talisman.default \
--to=rdsandiford@googlemail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.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).