From: Hongtao Liu <crazylht@gmail.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: liuhongt <hongtao.liu@intel.com>,
gcc-patches@gcc.gnu.org, hjl.tools@gmail.com
Subject: Re: [PATCH] i386[stv]: Handle REG_EH_REGION note
Date: Fri, 15 Mar 2024 09:24:00 +0800 [thread overview]
Message-ID: <CAMZc-bxLGB90iC5LXrA8DP-fMk2Pt7+k_=rRJRCFHdkbfZ3L4A@mail.gmail.com> (raw)
In-Reply-To: <CAFULd4bXB82O3uazsZzgMwouLW3MJ05UB08f7=0H5DBN5N+y+A@mail.gmail.com>
On Thu, Mar 14, 2024 at 10:46 PM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> On Thu, Mar 14, 2024 at 8:42 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> >
> > On Thu, Mar 14, 2024 at 8:32 AM Hongtao Liu <crazylht@gmail.com> wrote:
> > >
> > > On Thu, Mar 14, 2024 at 3:22 PM Uros Bizjak <ubizjak@gmail.com> wrote:
> > > >
> > > > On Thu, Mar 14, 2024 at 2:33 AM liuhongt <hongtao.liu@intel.com> wrote:
> > > > >
> > > > > When we split
> > > > > (insn 37 36 38 10 (set (reg:DI 104 [ _18 ])
> > > > > (mem:DI (reg/f:SI 98 [ CallNative_nclosure.0_1 ]) [6 MEM[(struct SQRefCounted *)CallNative_nclosure.0_1]._uiRef+0 S8 A32])) "test.C":22:42 84 {*movdi_internal}
> > > > > (expr_list:REG_EH_REGION (const_int -11 [0xfffffffffffffff5])
> > > > >
> > > > > into
> > > > >
> > > > > (insn 104 36 37 10 (set (subreg:V2DI (reg:DI 124) 0)
> > > > > (vec_concat:V2DI (mem:DI (reg/f:SI 98 [ CallNative_nclosure.0_1 ]) [6 MEM[(struct SQRefCounted *)CallNative_nclosure.0_1]._uiRef+0 S8 A32])
> > > > > (const_int 0 [0]))) "test.C":22:42 -1
> > > > > (nil)))
> > > > > (insn 37 104 105 10 (set (subreg:V2DI (reg:DI 104 [ _18 ]) 0)
> > > > > (subreg:V2DI (reg:DI 124) 0)) "test.C":22:42 2024 {movv2di_internal}
> > > > > (expr_list:REG_EH_REGION (const_int -11 [0xfffffffffffffff5])
> > > > > (nil)))
> > > > >
> > > > > we must copy the REG_EH_REGION note to the first insn and split the block
> > > > > after the newly added insn. The REG_EH_REGION on the second insn will be
> > > > > removed later since it no longer traps.
> > > > >
> > > > > Currently we only handle memory_operand, are there any other insns
> > > > > need to be handled???
> > > >
> > > > I think memory access is the only thing that can trap.
> > > >
> > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,} for trunk and gcc-13/gcc-12 release branch.
> > > > > Ok for trunk and backport?
> > > > >
> > > > > gcc/ChangeLog:
> > > > >
> > > > > * config/i386/i386-features.cc
> > > > > (general_scalar_chain::convert_op): Handle REG_EH_REGION note.
> > > > > (convert_scalars_to_vector): Ditto.
> > > > > * config/i386/i386-features.h (class scalar_chain): New
> > > > > memeber control_flow_insns.
> > > > >
> > > > > gcc/testsuite/ChangeLog:
> > > > >
> > > > > * g++.target/i386/pr111822.C: New test.
> > > > > ---
> > > > > gcc/config/i386/i386-features.cc | 48 ++++++++++++++++++++++--
> > > > > gcc/config/i386/i386-features.h | 1 +
> > > > > gcc/testsuite/g++.target/i386/pr111822.C | 45 ++++++++++++++++++++++
> > > > > 3 files changed, 90 insertions(+), 4 deletions(-)
> > > > > create mode 100644 gcc/testsuite/g++.target/i386/pr111822.C
> > > > >
> > > > > diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
> > > > > index 1de2a07ed75..2ed27a9ebdd 100644
> > > > > --- a/gcc/config/i386/i386-features.cc
> > > > > +++ b/gcc/config/i386/i386-features.cc
> > > > > @@ -998,20 +998,36 @@ general_scalar_chain::convert_op (rtx *op, rtx_insn *insn)
> > > > > }
> > > > > else if (MEM_P (*op))
> > > > > {
> > > > > + rtx_insn* eh_insn, *movabs = NULL;
> > > > > rtx tmp = gen_reg_rtx (GET_MODE (*op));
> > > > >
> > > > > /* Handle movabs. */
> > > > > if (!memory_operand (*op, GET_MODE (*op)))
> > > > > {
> > > > > rtx tmp2 = gen_reg_rtx (GET_MODE (*op));
> > > > > + movabs = emit_insn_before (gen_rtx_SET (tmp2, *op), insn);
> > > > >
> > > > > - emit_insn_before (gen_rtx_SET (tmp2, *op), insn);
> > > > > *op = tmp2;
> > > > > }
> > > >
> > > > I may be missing something, but isn't the above a dead code? We have
> > > > if (MEM_p(*op)) and then if (!memory_operand (*op, ...)).
> > > It's PR91814 #c1, memory_operand will also check invalid memory addresses.
> >
> > Oh, it is even my comment ;)
> >
> > Perhaps the comment should be improved to something like:
> >
> > "Emit MOVABS to load from a 64-bit absolute address to a GPR."
> >
> > LGTM then.
>
> BTW: Do we need to also fix timode_scalar_chain::convert_op ? There we
> also preload operand, so a similar fix should be applied there.
Yes, I'll make another patch. Didn't realize there are 2 of them.
>
> Uros.
--
BR,
Hongtao
prev parent reply other threads:[~2024-03-15 1:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-14 1:33 liuhongt
2024-03-14 7:22 ` Uros Bizjak
2024-03-14 7:43 ` Hongtao Liu
2024-03-14 7:42 ` Uros Bizjak
2024-03-14 14:45 ` Uros Bizjak
2024-03-15 1:24 ` Hongtao Liu [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='CAMZc-bxLGB90iC5LXrA8DP-fMk2Pt7+k_=rRJRCFHdkbfZ3L4A@mail.gmail.com' \
--to=crazylht@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
--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).