From: Richard Sandiford <richard.sandiford@arm.com>
To: YunQiang Su <syq@gcc.gnu.org>
Cc: gcc-patches@gcc.gnu.org, pinskia@gmail.com,
jeffreyalaw@gmail.com, rguenther@suse.de
Subject: Re: [PATCH v3] EXPR: Emit an truncate if 31+ bits polluted for SImode
Date: Wed, 03 Jan 2024 23:39:37 +0000 [thread overview]
Message-ID: <mpt7ckq7zra.fsf@arm.com> (raw)
In-Reply-To: <20231223085858.4136369-1-syq@gcc.gnu.org> (YunQiang Su's message of "Sat, 23 Dec 2023 16:58:58 +0800")
YunQiang Su <syq@gcc.gnu.org> writes:
> On TRULY_NOOP_TRUNCATION_MODES_P (DImode, SImode)) == true platforms,
> if 31 or above bits is polluted by an bitops, we will need an
> truncate. Let's emit one, and mark let's use the same hardreg
> as in and out, the RTL may like:
>
> (insn 21 20 24 2 (set (subreg/s/u:SI (reg/v:DI 200 [ val ]) 0)
> (truncate:SI (reg/v:DI 200 [ val ]))) "../xx.c":7:29 -1
> (nil))
>
> We use /s/u flags to mark it as really needed, as in
> combine_simplify_rtx, this insn may be considered as truncated,
> so let's skip this combination.
>
> gcc/ChangeLog:
> PR: 104914.
> * combine.cc (try_combine): Skip combine with truncate if
> dest is subreg and has /u/s flags on platforms
> TRULY_NOOP_TRUNCATION_MODES_P (DImode, SImode)) == true.
> * expr.cc (expand_assignment): Emit a truncate insn, if
> 31+ bits is polluted for SImode.
>
> gcc/testsuite/ChangeLog:
> PR: 104914.
> * gcc.target/mips/pr104914.c: New testcase.
Sorry for not looking at this earlier. I've got a bit lost in the
various threads, so apologies if this has been discussed already
but I think the fix is:
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 4f42c0ff487..9847eba19fe 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -6275,9 +6275,8 @@ expand_assignment (tree to, tree from, bool nontemporal)
else
{
rtx to_rtx1
- = lowpart_subreg (subreg_unpromoted_mode (to_rtx),
- SUBREG_REG (to_rtx),
- subreg_promoted_mode (to_rtx));
+ = convert_to_mode (subreg_unpromoted_mode (to_rtx),
+ SUBREG_REG (to_rtx), false);
result = store_field (to_rtx1, bitsize, bitpos,
bitregion_start, bitregion_end,
mode1, from, get_alias_set (to),
(completely untested apart from the test case). That should still
produce a subreg on most targets, but generates the required trunc
on MIPS.
Thanks,
Richard
next prev parent reply other threads:[~2024-01-03 23:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-01-09 18:49 ` Jeff Law
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
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
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=mpt7ckq7zra.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=pinskia@gmail.com \
--cc=rguenther@suse.de \
--cc=syq@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).