From: Michael Meissner <meissner@linux.ibm.com>
To: "Kewen.Lin" <linkw@linux.ibm.com>
Cc: Michael Meissner <meissner@linux.ibm.com>,
gcc-patches@gcc.gnu.org,
Segher Boessenkool <segher@kernel.crashing.org>,
David Edelsohn <dje.gcc@gmail.com>,
Peter Bergner <bergner@linux.ibm.com>,
Will Schmidt <will_schmidt@vnet.ibm.com>
Subject: Re: [PATCH] PR target/105325, Make load/cmp fusion know about prefixed loads
Date: Fri, 24 Mar 2023 19:09:17 -0400 [thread overview]
Message-ID: <ZB4tnUiT0po9x1mS@toto.the-meissners.org> (raw)
In-Reply-To: <f641dfc7-46a7-b323-5b82-fb18f05af8a8@linux.ibm.com>
On Thu, Mar 23, 2023 at 04:10:22PM +0800, Kewen.Lin wrote:
> Hi Mike,
>
> Thanks for fixing this, some minor comments are inlined below.
>
> on 2023/3/22 07:53, Michael Meissner wrote:
> > The issue with the bug is the power10 load GPR + cmpi -1/0/1 fusion
> > optimization generates illegal assembler code.
> >
> > Ultimately the code was dying because the fusion load + compare -1/0/1 patterns
> > did not handle the possibility that the load might be prefixed.
> >
> > The main cause is the constraints for the individual loads in the fusion did not
> > match the machine. In particular, LWA is a ds format instruction when it is
> > unprefixed. The code did not also set the prefixed attribute correctly.
> >
> > This patch rewrites the genfusion.pl script so that it will have more accurate
> > constraints for the LWA and LD instructions (which are DS instructions). The
> > updated genfusion.pl was then run to update fusion.md. Finally, the code for
> > the "prefixed" attribute is modified so that it considers load + compare
> > immediate patterns to be like the normal load insns in checking whether
> > operand[1] is a prefixed instruction.
> >
> > I have tested this patch on a little endian power10 system, on a little endian
> > power9 system, and a big endian power8 system (both -m32 and -m64 tested on
> > BE). There were no regressions, can I check this into the trunk?
> >
> > The same patch applies to the gcc-12 and gcc-11 branches. Can I check this
> > patch into those branches also after a burn-in period?
> >
> > 2023-03-21 Michael Meissner <meissner@linux.ibm.com>
> > Aaron Sawdey <acsawdey@linux.ibm.com>
> >
> > gcc/
> >
> > PR target/105325
> > * gcc/config/rs6000/genfusion.pl (gen_ld_cmpi_p10): Improve generation
> > of the ld and lwa instructions which use the DS encoding instead of D.
> > Use the YZ constraint for these loads. Handle prefixed loads better.
> > Set the sign_extend attribute as appropriate.
> > * gcc/config/rs6000/fusion.md: Regenerate.
> > * gcc/config/rs6000/rs6000.md (prefixed attribute): Add fused_load_cmpi
> > instructions to the list of instructions that might have a prefixed load
> > instruction.
> >
> > gcc/testsuite/
> >
> > PR target/105325
> > * g++.target/powerpc/pr105325.C: New test.
> > * gcc.target/powerpc/fusion-p10-ldcmpi.c: Adjust insn counts.
> > ---
> > gcc/config/rs6000/genfusion.pl | 26 ++++++++++++++++---
> > gcc/config/rs6000/fusion.md | 17 +++++++-----
> > gcc/config/rs6000/rs6000.md | 2 +-
> > gcc/testsuite/g++.target/powerpc/pr105325.C | 24 +++++++++++++++++
> > .../gcc.target/powerpc/fusion-p10-ldcmpi.c | 4 +--
> > 5 files changed, 59 insertions(+), 14 deletions(-)
> > create mode 100644 gcc/testsuite/g++.target/powerpc/pr105325.C
> >
> > diff --git a/gcc/config/rs6000/genfusion.pl b/gcc/config/rs6000/genfusion.pl
> > index e4db352e0ce..4f367cadc52 100755
> > --- a/gcc/config/rs6000/genfusion.pl
> > +++ b/gcc/config/rs6000/genfusion.pl
> > @@ -56,7 +56,7 @@ sub mode_to_ldst_char
> > sub gen_ld_cmpi_p10
> > {
> > my ($lmode, $ldst, $clobbermode, $result, $cmpl, $echr, $constpred,
> > - $mempred, $ccmode, $np, $extend, $resultmode);
> > + $mempred, $ccmode, $np, $extend, $resultmode, $constraint);
> > LMODE: foreach $lmode ('DI','SI','HI','QI') {
> > $ldst = mode_to_ldst_char($lmode);
> > $clobbermode = $lmode;
> > @@ -71,21 +71,34 @@ sub gen_ld_cmpi_p10
> > CCMODE: foreach $ccmode ('CC','CCUNS') {
> > $np = "NON_PREFIXED_D";
> > $mempred = "non_update_memory_operand";
> > + $constraint = "m";
>
> The three assignments on $np $mempred $constraint can be moved
> to place (a) (see below) and add one explicit assignment for
> $constraint at place (b), since for the condition ccmode eq 'CC',
> HI/SI/DI have their own settings (btw QI is skipped), these
> assignments for default value can be moved to else arm (for CCUNS).
...
> we have broken it into two different arms for SI and DI, this
> comment can be removed?
...
>
> ... and this comment.
>
I have fixed these issues and reposted the patch as:
| Date: Fri, 24 Mar 2023 19:06:35 -0400
| From: Michael Meissner <meissner@linux.ibm.com>
| Subject: [PATCH, V2] PR target/105325, Make load/cmp fusion know about prefixed load
| Message-ID: <ZB4s+1RqBNR49tj/@toto.the-meissners.org>
--
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meissner@linux.ibm.com
prev parent reply other threads:[~2023-03-24 23:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 23:53 Michael Meissner
2023-03-23 8:10 ` Kewen.Lin
2023-03-24 23:09 ` Michael Meissner [this message]
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=ZB4tnUiT0po9x1mS@toto.the-meissners.org \
--to=meissner@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=will_schmidt@vnet.ibm.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).