diff mbox series

[committed,4/n,PR,rtl-optimization/115877] Correct SUBREG handling in a destination

Message ID 5eedb951-d5e5-4d16-99f0-b676e360e263@ventanamicro.com
State New
Headers show
Series [committed,4/n,PR,rtl-optimization/115877] Correct SUBREG handling in a destination | expand

Commit Message

Jeff Law July 22, 2024, 4:15 p.m. UTC
If we encounter something during SET handling that we can not handle, 
the safe thing to do is to ignore the destination and continue the loop.

We've actually been trying to do slightly better with SUBREG 
destinations by iterating into SUBREG_REG.  It turns out that wasn't 
working as expected.

The problem is once we "continue" we lose the state that we were inside 
the SET and thus we ended up ignoring the destination completely rather 
than tracking the SUBREG_REG object.  This could be fixed by restarting 
SET processing, but I just don't see this as all that important to 
handle.  So rather than leave the code as-is, not working per design, 
I'm twiddling it to use the common 'skip subrtxs and continue' idiom 
used elsewhere.

This is a prerequisite for another patch in this series.  Specifically I 
have a patch that explicitly tracks if we skipped a destination rather 
than trying to imply it from the state of LIVE_TMP.  So this is probably 
NFC right now, but that's a short-lived NFC.

Bootstrapped and regression tested on x86 and also run as part of a 
larger kit on the crosses in my tester.

Pushing to the trunk,
Jeff
commit ab7c0aed52054976d0b5e12c52e82239d4277b98
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Mon Jul 22 10:11:57 2024 -0600

    [4/n][PR rtl-optimization/115877] Correct SUBREG handling in a destination
    
    If we encounter something during SET handling that we can not handle, the safe
    thing to do is to ignore the destination and continue the loop.
    
    We've actually been trying to do slightly better with SUBREG destinations by
    iterating into SUBREG_REG.  It turns out that wasn't working as expected.
    
    The problem is once we "continue" we lose the state that we were inside the SET
    and thus we ended up ignoring the destination completely rather than tracking
    the SUBREG_REG object.  This could be fixed by restarting SET processing, but I
    just don't see this as all that important to handle.  So rather than leave the
    code as-is, not working per design, I'm twiddling it to use the common 'skip
    subrtxs and continue' idiom used elsewhere.
    
    This is a prerequisite for another patch in this series.  Specifically I have a
    patch that explicitly tracks if we skipped a destination rather than trying to
    imply it from the state of LIVE_TMP.  So this is probably NFC right now, but
    that's a short-lived NFC.
    
    Bootstrapped and regression tested on x86 and also run as part of a larger kit
    on the crosses in my tester.
    
            PR rtl-optimization/115877
    gcc/
            * ext-dce.cc (ext_dce_process_sets): More correctly handle SUBREG
            destinations.
diff mbox series

Patch

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 44f64e2d18c..21feabd9ce3 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -270,11 +270,18 @@  ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap live_tmp)
 	    = GET_MODE_MASK (GET_MODE_INNER (GET_MODE (x)));
 	  if (SUBREG_P (x))
 	    {
-	      /* If we have a SUBREG that is too wide, just continue the loop
-		 and let the iterator go down into SUBREG_REG.  */
+	      /* If we have a SUBREG destination that is too wide, just
+		 skip the destination rather than continuing this iterator.
+		 While continuing would be better, we'd need to strip the
+		 subreg and restart within the SET processing rather than
+		 the top of the loop which just complicates the flow even
+		 more.  */
 	      if (!is_a <scalar_int_mode> (GET_MODE (SUBREG_REG (x)), &outer_mode)
 		  || GET_MODE_BITSIZE (outer_mode) > 64)
-		continue;
+		{
+		  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