From: Richard Sandiford <richard.sandiford@linaro.org>
To: gcc-patches@gcc.gnu.org
Subject: Fix LRA subreg calculation for big-endian targets
Date: Fri, 26 Jan 2018 13:34:00 -0000 [thread overview]
Message-ID: <87inbopx9c.fsf@linaro.org> (raw)
LRA was using a subreg offset of 0 whenever constraints matched
two operands with different modes. That leads to an invalid offset
(and ICE) on big-endian targets if one of the modes is narrower
than a word. E.g. if a (reg:SI X) is matched to a (reg:QI Y),
the big-endian subreg should be (subreg:QI (reg:SI X) 3) rather
than (subreg:QI (reg:SI X) 0).
But this raises the issue of what the behaviour should be when the
matched operands occupy different numbers of registers. Should the
register numbers match, or should the locations of the lsbs match?
Although the documentation isn't clear, reload went for the second
interpretation (which seems the most natural to me):
/* On a REG_WORDS_BIG_ENDIAN machine, point to the last register of a
multiple hard register group of scalar integer registers, so that
for example (reg:DI 0) and (reg:SI 1) will be considered the same
register. */
So I think this means that we can/must use the lowpart offset
unconditionally, rather than trying to separate out the multi-register
case. This also matches the LRA handling of constant integers, which
already uses lowpart subregs.
The patch fixes gcc.target/aarch64/sve/extract_[34].c for aarch64_be.
Tested on aarch64_be-none-elf, aarch64-linux-gnu and x86_64-linux-gnu.
OK to install?
2018-01-26 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* lra-constraints.c (match_reload): Use subreg_lowpart_offset
rather than 0 when creating partial subregs.
Index: gcc/lra-constraints.c
===================================================================
--- gcc/lra-constraints.c 2018-01-20 13:43:02.060083731 +0000
+++ gcc/lra-constraints.c 2018-01-26 13:22:46.350577506 +0000
@@ -945,7 +945,10 @@ match_reload (signed char out, signed ch
if (SCALAR_INT_MODE_P (inmode))
new_out_reg = gen_lowpart_SUBREG (outmode, reg);
else
- new_out_reg = gen_rtx_SUBREG (outmode, reg, 0);
+ {
+ poly_uint64 offset = subreg_lowpart_offset (outmode, inmode);
+ new_out_reg = gen_rtx_SUBREG (outmode, reg, offset);
+ }
LRA_SUBREG_P (new_out_reg) = 1;
/* If the input reg is dying here, we can use the same hard
register for REG and IN_RTX. We do it only for original
@@ -965,7 +968,10 @@ match_reload (signed char out, signed ch
if (SCALAR_INT_MODE_P (outmode))
new_in_reg = gen_lowpart_SUBREG (inmode, reg);
else
- new_in_reg = gen_rtx_SUBREG (inmode, reg, 0);
+ {
+ poly_uint64 offset = subreg_lowpart_offset (inmode, outmode);
+ new_in_reg = gen_rtx_SUBREG (inmode, reg, offset);
+ }
/* NEW_IN_REG is non-paradoxical subreg. We don't want
NEW_OUT_REG living above. We add clobber clause for
this. This is just a temporary clobber. We can remove
next reply other threads:[~2018-01-26 13:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-26 13:34 Richard Sandiford [this message]
2018-01-30 7:12 ` Jeff Law
2018-01-31 0:15 ` Eric Botcazou
2018-01-31 17:36 ` Segher Boessenkool
2018-01-31 17:36 ` Segher Boessenkool
2018-01-31 19:46 ` Richard Sandiford
2018-02-02 14:18 ` Richard Sandiford
2018-02-02 19:23 ` Segher Boessenkool
2018-02-06 20:37 ` Vladimir Makarov
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=87inbopx9c.fsf@linaro.org \
--to=richard.sandiford@linaro.org \
--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).