diff mbox series

[committed] Fix liveness computation for shift/rotate counts in ext-dce

Message ID 6e02b77e-ff50-44a0-b60c-8094fc32347b@gmail.com
State New
Headers show
Series [committed] Fix liveness computation for shift/rotate counts in ext-dce | expand

Commit Message

Jeff Law July 16, 2024, 12:18 a.m. UTC
So as I've noted before I believe the control flow in ext-dce.cc is 
horribly messy.  While investigating a fix for 115877 I came across 
another problem related to control flow handling.

Specifically, if we have an binary op which implies the 2nd operand is 
fully live, then we'd actually fail to mark that operand as live.

We essentially broke out of the loop which was supposed to be safe.  But 
Y was a REG and if Y is a REG or CONST_INT we skip sub-rtxs and thus 
failed to process that operand (the shift count) at all.

Rather than muck around with control flow, we can just set all the bits 
as live in DST_MASK and let normal processing continue.  With all the 
bits live IN DST_MASK all the bits implied by the mode of the argument 
will also be live.

No testcase.

Bootstrapped and regression tested on x86.  Pushing to the trunk.

jeff
commit b31b8af807f5459674b0b310cb62a5bc81b676e7
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Mon Jul 15 18:15:33 2024 -0600

    Fix liveness computation for shift/rotate counts in ext-dce
    
    So as I've noted before I believe the control flow in ext-dce.cc is horribly
    messy.  While investigating a fix for 115877 I came across another problem
    related to control flow handling.
    
    Specifically, if we have an binary op which implies the 2nd operand is fully
    live, then we'd actually fail to mark that operand as live.
    
    We essentially broke out of the loop which was supposed to be safe.  But Y was
    a REG and if Y is a REG or CONST_INT we skip sub-rtxs and thus failed to
    process that operand (the shift count) at all.
    
    Rather than muck around with control flow, we can just set all the bits as live
    in DST_MASK and let normal processing continue.  With all the bits live IN
    DST_MASK all the bits implied by the mode of the argument will also be live.
    
    No testcase.
    
    Bootstrapped and regression tested on x86.  Pushing to the trunk.
    
    gcc/
            * ext-dce.cc (ext_dce_process_uses): Simplify control flow and fix
            liveness computation for shift/rotate counts.
diff mbox series

Patch

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 2869a389c3a..6c961feee63 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -632,10 +632,11 @@  ext_dce_process_uses (rtx_insn *insn, rtx obj, bitmap live_tmp)
 		  else if (!CONSTANT_P (y))
 		    break;
 
-		  /* We might have (ashift (const_int 1) (reg...)) */
-		  /* XXX share this logic with code below.  */
+		  /* We might have (ashift (const_int 1) (reg...))
+		     By setting dst_mask we can continue iterating on the
+		     the next operand and it will be considered fully live.  */
 		  if (binop_implies_op2_fully_live (GET_CODE (src)))
-		    break;
+		    dst_mask = -1;
 
 		  /* If this was anything but a binary operand, break the inner
 		     loop.  This is conservatively correct as it will cause the