public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/ext-dce)] Fix various cases where SUBREG_BYTE or the bitsize might not be constant
@ 2023-11-18 14:59 Jeff Law
0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-11-18 14:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2d1c6487f04200d87d8aa303f0f2916c0542e590
commit 2d1c6487f04200d87d8aa303f0f2916c0542e590
Author: Jeff Law <jlaw@ventanamicro.com>
Date: Sat Nov 18 07:58:22 2023 -0700
Fix various cases where SUBREG_BYTE or the bitsize might not be constant
Diff:
---
gcc/ext-dce.cc | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 94335325dca..844e94406f2 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -146,7 +146,9 @@ ext_dce_process_sets (rtx_insn *insn, bitmap livenow, bitmap live_tmp)
x = SET_DEST (x);
/* We don't support vector destinations or destinations
- wider than DImode. */
+ wider than DImode. It is safe to continue this loop.
+ At worst, it will leave things live which could have
+ been made dead. */
if (VECTOR_MODE_P (GET_MODE (x)) || GET_MODE (x) > E_DImode)
continue;
@@ -160,7 +162,9 @@ ext_dce_process_sets (rtx_insn *insn, bitmap livenow, bitmap live_tmp)
/* The only valid operand of a STRICT_LOW_PART is a non
paradoxical SUBREG. */
- gcc_assert (SUBREG_P (x) && !paradoxical_subreg_p (x));
+ gcc_assert (SUBREG_P (x)
+ && !paradoxical_subreg_p (x)
+ && SUBREG_BYTE (x).is_constant ());
/* I think we should always see a REG here. But let's
be sure. */
@@ -181,13 +185,14 @@ ext_dce_process_sets (rtx_insn *insn, bitmap livenow, bitmap live_tmp)
continue;
}
- /* The mode of the SUBREG tells us how many bits we can
- clear. */
+ /* Transfer all the LIVENOW bits for X into LIVE_TMP. */
HOST_WIDE_INT rn = REGNO (SUBREG_REG (x));
for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + 4; i++)
if (bitmap_bit_p (livenow, i))
bitmap_set_bit (live_tmp, i);
+ /* The mode of the SUBREG tells us how many bits we can
+ clear. */
machine_mode mode = GET_MODE (x);
HOST_WIDE_INT size = GET_MODE_SIZE (mode).to_constant ();
bitmap_clear_range (livenow, 4 * rn, size);
@@ -203,16 +208,17 @@ ext_dce_process_sets (rtx_insn *insn, bitmap livenow, bitmap live_tmp)
if (paradoxical_subreg_p (x))
x = XEXP (x, 0);
- /* Similarly if we have a SUBREG of a wide mode. Do this after
- stripping STRICT_LOW_PART or a paradoxical SUBREG to catch
- stuff like (strict_low_part (subreg:HI (reg:TI))). */
+ /* If we have a SUBREG that is too wide, just continue the loop
+ and let the iterator go down into SUBREG_REG. */
if (SUBREG_P (x) && GET_MODE (SUBREG_REG (x)) > E_DImode)
continue;
/* Phase one of destination handling. First remove any wrapper
such as SUBREG or ZERO_EXTRACT. */
unsigned HOST_WIDE_INT mask = GET_MODE_MASK (GET_MODE (x));
- if (SUBREG_P (x) && !paradoxical_subreg_p (x))
+ if (SUBREG_P (x)
+ && !paradoxical_subreg_p (x)
+ && SUBREG_BYTE (x).is_constant ())
{
bit = SUBREG_BYTE (x).to_constant () * BITS_PER_UNIT;
if (WORDS_BIG_ENDIAN)
@@ -228,6 +234,7 @@ ext_dce_process_sets (rtx_insn *insn, bitmap livenow, bitmap live_tmp)
mask = -0x100000000ULL;
x = SUBREG_REG (x);
}
+
if (GET_CODE (x) == ZERO_EXTRACT)
{
/* If either the size or the start position is unknown,
@@ -423,8 +430,8 @@ ext_dce_process_uses (rtx_insn *insn, bitmap livenow, bitmap live_tmp,
enum rtx_code code = GET_CODE (src);
/* ?!? How much of this should mirror SET handling, potentially
- being shared? */
- if (SUBREG_P (dst))
+ being shared? */
+ if (SUBREG_BYTE (dst).is_constant () && SUBREG_P (dst))
{
bit = SUBREG_BYTE (dst).to_constant () * BITS_PER_UNIT;
if (WORDS_BIG_ENDIAN)
@@ -519,7 +526,7 @@ ext_dce_process_uses (rtx_insn *insn, bitmap livenow, bitmap live_tmp,
if (GET_CODE (x) == STRICT_LOW_PART
|| paradoxical_subreg_p (x))
x = XEXP (x, 0);
- else if (SUBREG_P (y))
+ else if (SUBREG_P (y) && SUBREG_BYTE (y).is_constant ())
{
/* For anything but (subreg (reg)), break the inner loop
and process normally (conservatively). */
@@ -599,7 +606,8 @@ ext_dce_process_uses (rtx_insn *insn, bitmap livenow, bitmap live_tmp,
else if (xcode == SUBREG
&& REG_P (SUBREG_REG (x))
&& subreg_lowpart_p (x)
- && GET_MODE_BITSIZE (GET_MODE (x)).to_constant () <= 32)
+ && GET_MODE_BITSIZE (GET_MODE (x)).is_constant ()
+ && GET_MODE_BITSIZE (GET_MODE (x)).to_constant () <= 32)
{
HOST_WIDE_INT size = GET_MODE_BITSIZE (GET_MODE (x)).to_constant ();
HOST_WIDE_INT rn = 4 * REGNO (SUBREG_REG (x));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-18 14:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-18 14:59 [gcc(refs/vendors/riscv/heads/ext-dce)] Fix various cases where SUBREG_BYTE or the bitsize might not be constant Jeff Law
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).