From: "H.J. Lu" <hjl.tools@gmail.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: Hongtao Liu <crazylht@gmail.com>,
liuhongt <hongtao.liu@intel.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] x86: Use XMM31 for scratch SSE register
Date: Tue, 3 Aug 2021 06:13:15 -0700 [thread overview]
Message-ID: <CAMe9rOrmo6pOkG_aUrbz6oA8k-nC1A+rS9gFsD3if3YNxowXiA@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOoUKLNhHTCjO+yK=JPubw++E6EDSCZn8=sKzYXn5opp1w@mail.gmail.com>
On Tue, Aug 3, 2021 at 5:10 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Aug 3, 2021 at 1:43 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > On Tue, Aug 3, 2021 at 10:15 AM Hongtao Liu <crazylht@gmail.com> wrote:
> > >
> > > On Tue, Aug 3, 2021 at 4:03 PM Uros Bizjak via Gcc-patches
> > > <gcc-patches@gcc.gnu.org> wrote:
> > > >
> > > > On Mon, Aug 2, 2021 at 7:47 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > > >
> > > > > In 64-bit mode, use XMM31 for scratch SSE register to avoid vzeroupper
> > > > > if possible.
> > > > >
> > > > > gcc/
> > > > >
> > > > > * config/i386/i386.c (ix86_gen_scratch_sse_rtx): In 64-bit mode,
> > > > > try XMM31 to avoid vzeroupper.
> > > > >
> > > > > gcc/testsuite/
> > > > >
> > > > > * gcc.target/i386/avx-vzeroupper-14.c: Pass -mno-avx512f to
> > > > > disable XMM31.
> > > > > * gcc.target/i386/avx-vzeroupper-15.c: Likewise.
> > > > > * gcc.target/i386/pr82941-1.c: Updated. Check for vzeroupper.
> > > > > * gcc.target/i386/pr82942-1.c: Likewise.
> > > > > * gcc.target/i386/pr82990-1.c: Likewise.
> > > > > * gcc.target/i386/pr82990-3.c: Likewise.
> > > > > * gcc.target/i386/pr82990-5.c: Likewise.
> > > > > * gcc.target/i386/pr100865-4b.c: Likewise.
> > > > > * gcc.target/i386/pr100865-6b.c: Likewise.
> > > > > * gcc.target/i386/pr100865-7b.c: Likewise.
> > > > > * gcc.target/i386/pr100865-10b.c: Likewise.
> > > > > * gcc.target/i386/pr100865-8b.c: Updated.
> > > > > * gcc.target/i386/pr100865-9b.c: Likewise.
> > > > > * gcc.target/i386/pr100865-11b.c: Likewise.
> > > > > * gcc.target/i386/pr100865-12b.c: Likewise.
> > > > > ---
> > > > > gcc/config/i386/i386.c | 18 +++++++++++++++---
> > > > > .../gcc.target/i386/avx-vzeroupper-14.c | 2 +-
> > > > > .../gcc.target/i386/avx-vzeroupper-15.c | 2 +-
> > > > > gcc/testsuite/gcc.target/i386/pr100865-10b.c | 1 +
> > > > > gcc/testsuite/gcc.target/i386/pr100865-11b.c | 2 +-
> > > > > gcc/testsuite/gcc.target/i386/pr100865-12b.c | 2 +-
> > > > > gcc/testsuite/gcc.target/i386/pr100865-4b.c | 2 ++
> > > > > gcc/testsuite/gcc.target/i386/pr100865-6b.c | 5 ++++-
> > > > > gcc/testsuite/gcc.target/i386/pr100865-7b.c | 5 ++++-
> > > > > gcc/testsuite/gcc.target/i386/pr100865-8b.c | 2 +-
> > > > > gcc/testsuite/gcc.target/i386/pr100865-9b.c | 2 +-
> > > > > gcc/testsuite/gcc.target/i386/pr82941-1.c | 3 ++-
> > > > > gcc/testsuite/gcc.target/i386/pr82942-1.c | 3 ++-
> > > > > gcc/testsuite/gcc.target/i386/pr82990-1.c | 3 ++-
> > > > > gcc/testsuite/gcc.target/i386/pr82990-3.c | 3 ++-
> > > > > gcc/testsuite/gcc.target/i386/pr82990-5.c | 3 ++-
> > > > > 16 files changed, 42 insertions(+), 16 deletions(-)
> > > > >
> > > > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > > > > index 842eb0e6786..ec0690876b7 100644
> > > > > --- a/gcc/config/i386/i386.c
> > > > > +++ b/gcc/config/i386/i386.c
> > > > > @@ -23335,9 +23335,21 @@ rtx
> > > > > ix86_gen_scratch_sse_rtx (machine_mode mode)
> > > > > {
> > > > > if (TARGET_SSE && !lra_in_progress)
> > > > > - return gen_rtx_REG (mode, (TARGET_64BIT
> > > > > - ? LAST_REX_SSE_REG
> > > > > - : LAST_SSE_REG));
> > > > > + {
> > > > > + unsigned int regno;
> > > > > + if (TARGET_64BIT)
> > > > > + {
> > > > > + /* In 64-bit mode, use XMM31 to avoid vzeroupper and always
> > > > > + use XMM31 for CSE. */
> > > > > + if (ix86_hard_regno_mode_ok (LAST_EXT_REX_SSE_REG, mode))
> > > > > + regno = LAST_EXT_REX_SSE_REG;
> > > > > + else
> > > > > + regno = LAST_REX_SSE_REG;
> > > > > + }
> > > > > + else
> > > > > + regno = LAST_SSE_REG;
> > > >
> > > > Assuming that ix86_hard_regno_mode_ok always returns false for XMM31
> > > > in 64bit mode, we can do:
> > > >
> > > > /* Use XMM31 if available to avoid vzeroupper. */
> > > > if (ix86_hard_regno_mode_ok (LAST_EXT_REX_SSE_REG, mode))
>
> It doesn't work for -m32 since ix86_hard_regno_mode_ok doesn't check
> for TARGET_64BIT. LAST_EXST_REX_SSE_REG is used for -m32:
I will check in my original patch as is.
Thanks.
> $ /export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/xgcc
> -B/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/
> /export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.target/i386/pr82941-1.c
> -m32 -fdiagnostics-plain-output -O2 -march=skylake-avx512
> -ffat-lto-objects -fno-ident -S -o pr82941-1.s
> xgcc: internal compiler error: Segmentation fault signal terminated program cc1
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <https://gcc.gnu.org/bugs/> for instructions.
> $
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000001201c64 in general_operand (
> op=<error reading variable: Cannot access memory at address
> 0x7ffffbffeff8>, mode=<error reading variable: Cannot access memory at
> address 0x7ffffbffeff4>)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.c:1412
> 1412 {
> (gdb) bt
> #0 0x0000000001201c64 in general_operand (
> op=<error reading variable: Cannot access memory at address
> 0x7ffffbffeff8>, mode=<error reading variable: Cannot access memory at
> address 0x7ffffbffeff4>)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.c:1412
> #1 0x000000000120221e in register_operand (op=0x7ffff5c10510, mode=E_V8DFmode)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.c:1559
> #2 0x00000000018fcfdb in ix86_expand_vector_move (mode=E_V8DFmode,
> operands=0x7ffffbfff190)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/config/i386/i386-expand.c:625
> #3 0x0000000001ef9bc2 in gen_movv8df (operand0=0x7ffff5c10510,
> operand1=0x7ffff6351d98)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/config/i386/sse.md:1051
> #4 0x0000000000de6cfb in insn_gen_fn::operator()<rtx_def*, rtx_def*> (
> this=0x2d88908 <insn_data+278376>)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/recog.h:407
> #5 0x0000000000dbe4ec in emit_move_insn_1 (x=0x7ffff5c10510, y=0x7ffff6351d98)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/expr.c:3930
> #6 0x0000000000dbefde in emit_move_insn (x=0x7ffff5c10510, y=0x7ffff6351d98)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/expr.c:4100
> #7 0x00000000018fd036 in ix86_expand_vector_move (mode=E_V8DFmode,
> operands=0x7ffffbfff420)
> at /export/gnu/import/git/gitlab/x86-gcc/gcc/config/i386/i386-expand.c:629
> #8 0x0000000001ef9bc2 in gen_movv8df (operand0=0x7ffff5c104e0,
>
> > > > regno = LAST_EXST_REX_SSE_REG;
> > > > else if (TARGET_64BIT)
> > > > regno = LAST_EXT_REX_SSE_REG;
> >
> > > why? w/o avx512 xmm31 is not available.
> >
> > Oh, a typo, this should read LAST_REX_SSE_REG.
> >
> > Uros.
>
>
>
> --
> H.J.
--
H.J.
prev parent reply other threads:[~2021-08-03 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-02 17:47 H.J. Lu
2021-08-03 1:38 ` Hongtao Liu
2021-08-03 8:02 ` Uros Bizjak
2021-08-03 8:15 ` Hongtao Liu
2021-08-03 8:43 ` Uros Bizjak
2021-08-03 12:10 ` H.J. Lu
2021-08-03 13:13 ` H.J. Lu [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=CAMe9rOrmo6pOkG_aUrbz6oA8k-nC1A+rS9gFsD3if3YNxowXiA@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=crazylht@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hongtao.liu@intel.com \
--cc=ubizjak@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).