From: Richard Earnshaw <rearnsha@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: Richard Earnshaw <rearnsha@arm.com>, richard.guenther@gmail.com
Subject: [PATCH v2 1/3] rtl: properly handle subreg (mem) in gen_highpart [PR102125]
Date: Thu, 9 Sep 2021 12:09:21 +0100 [thread overview]
Message-ID: <20210909110923.3171630-2-rearnsha@arm.com> (raw)
In-Reply-To: <20210909110923.3171630-1-rearnsha@arm.com>
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
gen_lowpart_general handles forming a SUBREG of a MEM by using
adjust_address to rework and validate a new version of the MEM.
However, gen_highpart does not attempt this and simply returns (SUBREG
(MEM)) if the change is not 'obviously' safe. Improve on that by
using a similar approach so that gen_lowpart and gen_highpart are
mostly symmetrical in this regard.
gcc/ChangeLog:
PR target/102125
* emit-rtl.c (gen_highpart): If simplify_gen_subreg returns
SUBREG (MEM) for a MEM, use adjust_address to produce a new
MEM.
---
gcc/emit-rtl.c | 8 ++++++++
1 file changed, 8 insertions(+)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: v2-0001-rtl-properly-handle-subreg-mem-in-gen_highpart-PR.patch --]
[-- Type: text/x-patch; name="v2-0001-rtl-properly-handle-subreg-mem-in-gen_highpart-PR.patch", Size: 599 bytes --]
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 77ea8948ee8..bacf6fffa22 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1597,6 +1597,14 @@ gen_highpart (machine_mode mode, rtx x)
result = validize_mem (result);
gcc_assert (result);
}
+ /* It may also just put a SUBREG wrapper around a MEM for the same
+ reason. */
+ else if (GET_CODE (result) == SUBREG && MEM_P (SUBREG_REG (result))
+ && MEM_P (x))
+ {
+ poly_int64 offset = subreg_highpart_offset (mode, GET_MODE (x));
+ result = adjust_address (x, mode, offset);
+ }
return result;
}
next prev parent reply other threads:[~2021-09-09 11:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 11:09 [PATCH v2 0/3] lower more cases of memcpy [PR102125] Richard Earnshaw
2021-09-09 11:09 ` Richard Earnshaw [this message]
2021-09-09 12:23 ` [PATCH v2 1/3] rtl: properly handle subreg (mem) in gen_highpart [PR102125] Richard Biener
2021-09-09 14:39 ` Richard Earnshaw
2021-09-09 11:09 ` [PATCH v2 2/3] arm: expand handling of movmisalign for DImode [PR102125] Richard Earnshaw
2021-09-09 11:09 ` [PATCH v2 3/3] gimple: allow more folding of memcpy [PR102125] Richard Earnshaw
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=20210909110923.3171630-2-rearnsha@arm.com \
--to=rearnsha@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@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).