https://gcc.gnu.org/g:dcba59a336f5307d577fd3bacae65258447d1803

commit r17-844-gdcba59a336f5307d577fd3bacae65258447d1803
Author: Philipp Tomsich <[email protected]>
Date:   Fri Mar 20 17:14:00 2026 +0100

    ext-dce: fix off-by-one in subreg liveness for 32-bit modes
    
    ext_dce_process_uses uses `size >= 32` to decide whether group 3
    (bits 32-63) is live for a lowpart subreg source.  For SImode subregs
    (size == 32), this incorrectly marks bits 32-63 as live, preventing
    the pass from recognizing that the upper half of a DImode register is
    dead.  This blocks lw -> lwu narrowing on RV64.
    
    Change the condition to `size > 32`, consistent with the other
    thresholds in the same block (size > 8, size > 16).  The size > 32
    case is still reachable via SUBREG_PROMOTED_VAR_P which widens size
    beyond the outer mode.
    
    gcc/ChangeLog:
    
            * ext-dce.cc (ext_dce_process_uses): Fix off-by-one: use
            size > 32 instead of size >= 32 for group 3 liveness.
    
    Co-authored-by: Konstantinos Eleftheriou <[email protected]>

Diff:
---
 gcc/ext-dce.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 9475b18cd344..86457d31af52 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -1353,7 +1353,7 @@ ext_dce_process_uses (rtx_insn *insn, rtx obj,
            bitmap_set_bit (livenow, rn + 1);
          if (size > 16)
            bitmap_set_bit (livenow, rn + 2);
-         if (size >= 32)
+         if (size > 32)
            bitmap_set_bit (livenow, rn + 3);
          iter.skip_subrtxes ();
        }

Reply via email to