From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: Remove word_mode hack for split bitfields
Date: Thu, 26 May 2016 15:47:00 -0000 [thread overview]
Message-ID: <8760u0evj5.fsf@e105548-lin.cambridge.arm.com> (raw)
This patch is effectively reverting a change from 1994. The reason
I think it's a hack is that store_bit_field_1 is creating a subreg
reference to one word of a field even though it has already proven that
the field spills into the following word. We then rely on the special
SUBREG handling in store_split_bit_field to ignore the extent of op0 and
look inside the SUBREG_REG regardless. I don't see any reason why we can't
pass the original op0 to store_split_bit_field instead.
Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install?
Thanks,
Richard
gcc/
* expmed.c (store_bit_field_1): Do not restrict a multiword op0
to one word if the field is known to overlap other words.
(extract_bit_field_1): Likewise.
(store_split_bit_field): Remove compensating code.
(extract_split_bit_field): Likewise.
diff --git a/gcc/expmed.c b/gcc/expmed.c
index ec968da..6645a53 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -967,11 +967,7 @@ store_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
If the region spans two words, defer to store_split_bit_field. */
if (!MEM_P (op0) && GET_MODE_SIZE (GET_MODE (op0)) > UNITS_PER_WORD)
{
- op0 = simplify_gen_subreg (word_mode, op0, GET_MODE (op0),
- bitnum / BITS_PER_WORD * UNITS_PER_WORD);
- gcc_assert (op0);
- bitnum %= BITS_PER_WORD;
- if (bitnum + bitsize > BITS_PER_WORD)
+ if (bitnum % BITS_PER_WORD + bitsize > BITS_PER_WORD)
{
if (!fallback_p)
return false;
@@ -980,6 +976,10 @@ store_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
bitregion_end, value, reverse);
return true;
}
+ op0 = simplify_gen_subreg (word_mode, op0, GET_MODE (op0),
+ bitnum / BITS_PER_WORD * UNITS_PER_WORD);
+ gcc_assert (op0);
+ bitnum %= BITS_PER_WORD;
}
/* From here on we can assume that the field to be stored in fits
@@ -1383,25 +1383,8 @@ store_split_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize,
bitsdone, NULL_RTX, 1, false);
}
- /* If OP0 is a register, then handle OFFSET here.
-
- When handling multiword bitfields, extract_bit_field may pass
- down a word_mode SUBREG of a larger REG for a bitfield that actually
- crosses a word boundary. Thus, for a SUBREG, we must find
- the current word starting from the base register. */
- if (GET_CODE (op0) == SUBREG)
- {
- int word_offset = (SUBREG_BYTE (op0) / UNITS_PER_WORD)
- + (offset * unit / BITS_PER_WORD);
- machine_mode sub_mode = GET_MODE (SUBREG_REG (op0));
- if (sub_mode != BLKmode && GET_MODE_SIZE (sub_mode) < UNITS_PER_WORD)
- word = word_offset ? const0_rtx : op0;
- else
- word = operand_subword_force (SUBREG_REG (op0), word_offset,
- GET_MODE (SUBREG_REG (op0)));
- offset &= BITS_PER_WORD / unit - 1;
- }
- else if (REG_P (op0))
+ /* If OP0 is a register, then handle OFFSET here. */
+ if (SUBREG_P (op0) || REG_P (op0))
{
machine_mode op0_mode = GET_MODE (op0);
if (op0_mode != BLKmode && GET_MODE_SIZE (op0_mode) < UNITS_PER_WORD)
@@ -1787,10 +1770,7 @@ extract_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
If the region spans two words, defer to extract_split_bit_field. */
if (!MEM_P (op0) && GET_MODE_SIZE (GET_MODE (op0)) > UNITS_PER_WORD)
{
- op0 = simplify_gen_subreg (word_mode, op0, GET_MODE (op0),
- bitnum / BITS_PER_WORD * UNITS_PER_WORD);
- bitnum %= BITS_PER_WORD;
- if (bitnum + bitsize > BITS_PER_WORD)
+ if (bitnum % BITS_PER_WORD + bitsize > BITS_PER_WORD)
{
if (!fallback_p)
return NULL_RTX;
@@ -1798,6 +1778,9 @@ extract_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize,
reverse);
return convert_extracted_bit_field (target, mode, tmode, unsignedp);
}
+ op0 = simplify_gen_subreg (word_mode, op0, GET_MODE (op0),
+ bitnum / BITS_PER_WORD * UNITS_PER_WORD);
+ bitnum %= BITS_PER_WORD;
}
/* From here on we know the desired field is smaller than a word.
@@ -2109,20 +2092,8 @@ extract_split_bit_field (rtx op0, unsigned HOST_WIDE_INT bitsize,
thissize = MIN (bitsize - bitsdone, BITS_PER_WORD);
thissize = MIN (thissize, unit - thispos);
- /* If OP0 is a register, then handle OFFSET here.
-
- When handling multiword bitfields, extract_bit_field may pass
- down a word_mode SUBREG of a larger REG for a bitfield that actually
- crosses a word boundary. Thus, for a SUBREG, we must find
- the current word starting from the base register. */
- if (GET_CODE (op0) == SUBREG)
- {
- int word_offset = (SUBREG_BYTE (op0) / UNITS_PER_WORD) + offset;
- word = operand_subword_force (SUBREG_REG (op0), word_offset,
- GET_MODE (SUBREG_REG (op0)));
- offset = 0;
- }
- else if (REG_P (op0))
+ /* If OP0 is a register, then handle OFFSET here. */
+ if (SUBREG_P (op0) || REG_P (op0))
{
word = operand_subword_force (op0, offset, GET_MODE (op0));
offset = 0;
next reply other threads:[~2016-05-26 14:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 15:47 Richard Sandiford [this message]
2016-05-31 12:48 ` Bernd Schmidt
2016-06-01 12:41 ` Richard Sandiford
2016-06-06 11:12 ` Bernd Schmidt
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=8760u0evj5.fsf@e105548-lin.cambridge.arm.com \
--to=richard.sandiford@arm.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).