public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] regcprop: Determine subreg offset depending on endianness [PR101260]
Date: Fri,  8 Oct 2021 13:29:05 +0200	[thread overview]
Message-ID: <20211008112904.3459907-1-stefansf@linux.ibm.com> (raw)

gcc/ChangeLog:

	* regcprop.c (maybe_mode_change): Determine offset relative to
	high or low part depending on endianness.

Bootstrapped and regtested on IBM Z. Ok for mainline and gcc-{11,10,9}?

---
 gcc/regcprop.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/regcprop.c b/gcc/regcprop.c
index d2a01130fe1..0e1ac12458a 100644
--- a/gcc/regcprop.c
+++ b/gcc/regcprop.c
@@ -414,9 +414,14 @@ maybe_mode_change (machine_mode orig_mode, machine_mode copy_mode,
 			    copy_nregs, &bytes_per_reg))
 	return NULL_RTX;
       poly_uint64 copy_offset = bytes_per_reg * (copy_nregs - use_nregs);
-      poly_uint64 offset
-	= subreg_size_lowpart_offset (GET_MODE_SIZE (new_mode) + copy_offset,
-				      GET_MODE_SIZE (orig_mode));
+      poly_uint64 offset =
+#if WORDS_BIG_ENDIAN
+	subreg_size_highpart_offset
+#else
+	subreg_size_lowpart_offset
+#endif
+				    (GET_MODE_SIZE (new_mode) + copy_offset,
+				     GET_MODE_SIZE (orig_mode));
       regno += subreg_regno_offset (regno, orig_mode, offset, new_mode);
       if (targetm.hard_regno_mode_ok (regno, new_mode))
 	return gen_raw_REG (new_mode, regno);
-- 
2.31.1


             reply	other threads:[~2021-10-08 11:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 11:29 Stefan Schulze Frielinghaus [this message]
2021-10-11  7:38 ` Richard Biener
2021-10-11 12:14   ` Stefan Schulze Frielinghaus
2021-10-29  8:11     ` Stefan Schulze Frielinghaus

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=20211008112904.3459907-1-stefansf@linux.ibm.com \
    --to=stefansf@linux.ibm.com \
    --cc=gcc-patches@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).