public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/ext-dce)] Fix ups. Hack around subreg voidmode problem
@ 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:a68b2684bfa6d0e10a38d5023cf6984d8130226f

commit a68b2684bfa6d0e10a38d5023cf6984d8130226f
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Fri Nov 17 11:17:47 2023 -0700

    Fix ups.  Hack around subreg voidmode problem

Diff:
---
 gcc/ext-dce.cc      | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 gcc/simplify-rtx.cc |  4 ++++
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 8a63d408494..94335325dca 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -150,11 +150,57 @@ ext_dce_process_sets (rtx_insn *insn, bitmap livenow, bitmap live_tmp)
 	  if (VECTOR_MODE_P (GET_MODE (x)) || GET_MODE (x) > E_DImode)
 	    continue;
 
-	  /* We could have (strict_low_part (subreg ...)).  It's always safe
-	     to leave bits live, even when they are not.  So we can just
-	     strip the STRICT_LOW_PART for now.  Similarly for a paradoxical
-	     SUBREG.  */
-	  if (GET_CODE (x) == STRICT_LOW_PART || paradoxical_subreg_p (x))
+	  /* We could have (strict_low_part (subreg ...)).  We can not just
+	     strip the STRICT_LOW_PART as that would result in clearing
+	     some bits in LIVENOW that are still live.  So process the
+	     STRICT_LOW_PART specially.  */
+	  if (GET_CODE (x) == STRICT_LOW_PART)
+	    {
+	      x = XEXP (x, 0);
+
+	      /* The only valid operand of a STRICT_LOW_PART is a non
+		 paradoxical SUBREG.  */
+	      gcc_assert (SUBREG_P (x) && !paradoxical_subreg_p (x));
+
+	      /* I think we should always see a REG here.  But let's
+		 be sure.  */
+	      gcc_assert (REG_P (SUBREG_REG (x)));
+
+	      /* We don't track values larger than DImode.  */
+	      gcc_assert (GET_MODE (x) <= E_DImode);
+
+	      /* But the inner mode might be larger, just punt for
+		 that case.  Remember, we can not just continue to process
+		 the inner RTXs due to the STRICT_LOW_PART.  */
+	      if (GET_MODE (SUBREG_REG (x)) > E_DImode)
+		{
+		  /* Skip the subrtxs of the STRICT_LOW_PART.  We can't
+		     process them because it'll set objects as no longer
+		     live when they are in fact still live.  */
+		  iter.skip_subrtxes ();
+		  continue;
+		}
+
+	      /* The mode of the SUBREG tells us how many bits we can
+		 clear.  */
+	      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);
+
+	      machine_mode mode = GET_MODE (x);
+	      HOST_WIDE_INT size = GET_MODE_SIZE (mode).to_constant ();
+	      bitmap_clear_range (livenow, 4 * rn, size);
+
+	      /* We have fully processed this destination.  */
+	      iter.skip_subrtxes ();
+	      continue;
+	    }
+
+	  /* We can safely strip a paradoxical subreg.  The inner mode will
+	     be narrower than the outer mode.  We'll clear fewer bits in
+	     LIVENOW than we'd like, but that's always safe.  */
+	  if (paradoxical_subreg_p (x))
 	    x = XEXP (x, 0);
 
 	  /* Similarly if we have a SUBREG of a wide mode.  Do this after
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 69d87579d9c..caaed3625f6 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -7545,6 +7545,10 @@ rtx
 simplify_context::simplify_subreg (machine_mode outermode, rtx op,
 				   machine_mode innermode, poly_uint64 byte)
 {
+  /* XXX */
+  if (innermode == VOIDmode)
+    return NULL_RTX;
+
   /* Little bit of sanity checking.  */
   gcc_assert (innermode != VOIDmode);
   gcc_assert (outermode != VOIDmode);

^ 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 ups. Hack around subreg voidmode problem 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).