From: YunQiang Su <syq@gcc.gnu.org>
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: Jeff Law <jeffreyalaw@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v3] EXPR: Emit an truncate if 31+ bits polluted for SImode
Date: Sun, 24 Dec 2023 17:15:26 +0800 [thread overview]
Message-ID: <CAKcpw6U0WEXwaZLp7v9aia+5zAW0=X899Rb4VoiESOkZzQSb7w@mail.gmail.com> (raw)
In-Reply-To: <000f01da3646$57092a40$051b7ec0$@nextmovesoftware.com>
Roger Sayle <roger@nextmovesoftware.com> 于2023年12月24日周日 16:51写道:
>
>
> > What's exceedingly weird is T_N_T_M_P (DImode, SImode) isn't actually a
> > truncation! The output precision is first, the input precision is second. The docs
> > explicitly state the output precision should be smaller than the input precision
> > (which makes sense for truncation).
> >
> > That's where I'd start with trying to untangle this mess.
>
> Thanks (both) for correcting my misunderstanding.
> At the very least might I suggest that we introduce a new
> TRULY_NOOP_EXTENSION_MODES_P target hook that MIPS
> can use for this purpose? It'd help reduce confusion, and keep
> the documentation/function naming correct.
>
Yes. It is good for me.
T_N_T_M_P is a really confusion naming.
> When Richard Sandiford "hookized" truly_noop_truncation in 2017
> https://gcc.gnu.org/legacy-ml/gcc-patches/2017-09/msg00836.html
> he mentions the inprec/outprec confusion [deciding not to add a
> gcc_assert outprec < inprec here, which might be a good idea].
>
> The next question is whether this is just
> TRULY_NOOP_SIGN_EXTENSION_MODES_P
> or whether there are any targets that usefully ensure some modes
> are zero-extended forms of others. TRULY_NOOP_ZERO_EXTENSION...
>
I guess ARM64 is the one TRULY_NOOP_ZERO_EXTENSION?
> My vote is that a DINS instruction that updates the most significant
> bit of an SImode value should then expand or define_insn_and_split
> with an explicit following sign-extension operation. To avoid this being
> eliminated by the RTL optimizers/combine the DINS should return a
> DImode result, with the following extension truncating it to canonical
Is it this one?
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626137.html
> SImode form. This preserves the required backend invariant (and
> doesn't require tweaking machine-independent code in combine).
> SImode DINS instructions that don't/can't affect the MSB, can be a
> single SImode instruction.
>
Yes. As most of MIPS microarchitecture, INS may have slight better
performance than DINS.
While, I am worrying that: will some body do something like
INS <SI_REG1>,<DI_REG2>,24,8
In this case, if <DI_REG2> is not sign-extended, the result will be
UNPREDICTABLE.
For this, now, I prefer to use DINS and append a SLL.
I tried to write a C code that can produce this case, but not yet
success.
> Cheers,
> Roger
> --
>
>
next prev parent reply other threads:[~2023-12-24 9:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-24 0:49 Roger Sayle
2023-12-24 5:38 ` Jeff Law
2023-12-24 8:51 ` Roger Sayle
2023-12-24 9:15 ` YunQiang Su [this message]
2023-12-24 9:28 ` Andrew Pinski
2023-12-24 12:24 ` Roger Sayle
2023-12-28 18:26 ` Jeff Law
2023-12-24 8:29 ` YunQiang Su
-- strict thread matches above, loose matches on Subject: below --
2023-12-23 8:58 YunQiang Su
2023-12-23 16:51 ` Jeff Law
2023-12-23 22:46 ` YunQiang Su
2023-12-24 5:27 ` Jeff Law
2023-12-24 8:11 ` YunQiang Su
2023-12-28 18:11 ` Jeff Law
2024-01-03 23:39 ` Richard Sandiford
2024-01-09 18:49 ` Jeff Law
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='CAKcpw6U0WEXwaZLp7v9aia+5zAW0=X899Rb4VoiESOkZzQSb7w@mail.gmail.com' \
--to=syq@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=roger@nextmovesoftware.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).