From: Segher Boessenkool <segher@kernel.crashing.org>
To: Peter Bergner <bergner@linux.ibm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: rs6000: Generate an lxvp instead of two adjacent lxv instructions
Date: Fri, 9 Jul 2021 10:33:26 -0500 [thread overview]
Message-ID: <20210709153326.GV1583@gate.crashing.org> (raw)
In-Reply-To: <680c1d6a-0662-f609-f0b5-2547011ea4b6@linux.ibm.com>
On Thu, Jul 08, 2021 at 08:26:45PM -0500, Peter Bergner wrote:
> On 7/8/21 6:28 PM, Segher Boessenkool wrote:
> >> int index = WORDS_BIG_ENDIAN ? i : nvecs - 1 - i;
> >> - rtx dst_i = gen_rtx_REG (reg_mode, reg + index);
> >> - emit_insn (gen_rtx_SET (dst_i, XVECEXP (src, 0, i)));
> >> + int index_next = WORDS_BIG_ENDIAN ? index + 1 : index - 1;
> >
> > What does index_next mean? The machine instructions do the same thing
> > in any endianness.
>
> Yeah, I'm bad at coming up with names! :-) So "index" is the index
> into XVECEXP (src, 0, ...) which is the operand that is to be assigned
> to regno. "index_next" is the index into XVECEXP (src, 0, ...) which is
> the operand to be assigned to regno + 1 (ie, the next register of the
> even/odd register pair). Whether the "next index" is index+1 or index-1
> is dependent on LE versus BE.
I would just call it "index1", or even "j" and "k" instead of "index"
and "index_next" :-) "next" can put people on the wrong track (it did
me :-) )
> >> + /* If we are loading an even VSX register and our memory location
> >> + is adjacent to the next register's memory location (if any),
> >> + then we can load them both with one LXVP instruction. */
> >> + if ((regno & 1) == 0
> >> + && VSX_REGNO_P (regno)
> >> + && MEM_P (XVECEXP (src, 0, index))
> >> + && MEM_P (XVECEXP (src, 0, index_next)))
> >> + {
> >> + rtx base = WORDS_BIG_ENDIAN ? XVECEXP (src, 0, index)
> >> + : XVECEXP (src, 0, index_next);
> >> + rtx next = WORDS_BIG_ENDIAN ? XVECEXP (src, 0, index_next)
> >> + : XVECEXP (src, 0, index);
> >
> > Please get rid of index_next, if you still have to do different code for
> > LE here -- it doesn't make the code any clearer (in fact I cannot follow
> > it at all anymore :-( )
>
> We do need different code for LE versus BE. So you want something like
>
> if (WORDS_BIG_ENDIAN) {...} else {...}
>
> ...instead? I can try that to see if the code is easier to read.
Yes exactly. It will more directly say what it does, and there is no
"index_next" abstraction the reader has to absorb first.
> > So this converts pairs of lxv to an lxvp in only a very limited case,
> > right? Can we instead do it more generically? And what about stxvp?
>
> Doing it more generically is my next TODO and that will cover both
> lxvp and stxvp.
Ah cool :-)
> My thought was to write a simple pass run at about
> the same time as our swap optimization pass to look for adjacent
> lxv's and stxv's and convert them into lxvp and stxvp.
So, very early, as soon as DF is set up. Makes sense.
> However, that
> won't catch the above case, since the assemble/build pattern is not
> split until very late, so we still want the above change.
You probably should also have a peephole (whether you do it like here or
not :-) )
> Also, given the new pass will be more complicated than the above code,
> it will be a GCC 12 only change.
/nod
> Let me make the changes you want and I'll repost with what I come up with.
Thanks! And thanks for the explanation.
Segher
next prev parent reply other threads:[~2021-07-09 15:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 22:01 Peter Bergner
2021-07-08 23:28 ` Segher Boessenkool
2021-07-09 1:26 ` Peter Bergner
2021-07-09 15:33 ` Segher Boessenkool [this message]
2021-07-09 23:14 ` Peter Bergner
2021-07-10 2:51 ` Peter Bergner
2021-07-11 0:39 ` segher
2021-07-13 17:09 ` Peter Bergner
2021-07-13 22:42 ` Segher Boessenkool
2021-07-13 17:14 ` Peter Bergner
2021-07-13 18:52 ` Peter Bergner
2021-07-13 22:59 ` Segher Boessenkool
2021-07-14 21:12 ` Peter Bergner
2021-07-15 14:15 ` Peter Bergner
2021-07-15 15:56 ` Segher Boessenkool
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=20210709153326.GV1583@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=bergner@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
/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).