]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix liveness computation for shift/rotate counts in ext-dce
authorJeff Law <jlaw@ventanamicro.com>
Tue, 16 Jul 2024 00:15:33 +0000 (18:15 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Tue, 16 Jul 2024 00:15:33 +0000 (18:15 -0600)
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.

gcc/ext-dce.cc

index 2869a389c3aad700c08c4553a9a1631c3a9879cf..6c961feee635c38a08ddfdff0b56be422ecfe60f 100644 (file)
@@ -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