]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ext-dce: fix off-by-one in subreg liveness for 32-bit modes
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Fri, 20 Mar 2026 16:14:00 +0000 (17:14 +0100)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Wed, 27 May 2026 17:20:51 +0000 (19:20 +0200)
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 <konstantinos.eleftheriou@vrull.eu>
gcc/ext-dce.cc

index 9475b18cd3445aa9058790a2277eb39594b08455..86457d31af522dd15534d260cfa396847bc83793 100644 (file)
@@ -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 ();
        }