]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[LRA]: Fix a bug in updating live info in rematerialization
authorVladimir N. Makarov <vmakarov@redhat.com>
Wed, 29 Apr 2026 13:37:11 +0000 (09:37 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Wed, 29 Apr 2026 15:39:40 +0000 (11:39 -0400)
LRA rematerialization ignores that a pseudo can require more one hard reg
when updating live hard reg info.  This can result in wrong
rematerialization. The patch fixes this.

gcc/ChangeLog:

* lra-remat.cc (do_remat): Use the right nregs for pseudo hard reg
when updating live hard regs.

gcc/lra-remat.cc

index c4da3f75e59855eff9f8e4d78c97b6095608df9b..20d9f47d2e9a24a20c4e0e9abbc1c92b9b35f288 100644 (file)
@@ -1073,11 +1073,17 @@ do_remat (void)
       CLEAR_HARD_REG_SET (live_hard_regs);
       EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), 0, regno, bi)
        {
-         int hard_regno = regno < FIRST_PSEUDO_REGISTER
-                          ? regno
-                          : reg_renumber[regno];
-         if (hard_regno >= 0)
-           SET_HARD_REG_BIT (live_hard_regs, hard_regno);
+         int nregs = 1;
+         int hard_regno = regno;
+         if (regno >= FIRST_PSEUDO_REGISTER)
+           {
+             hard_regno = reg_renumber[regno];
+             if (hard_regno < 0)
+               continue;
+             nregs = hard_regno_nregs (hard_regno, PSEUDO_REGNO_MODE (regno));
+           }
+         for (int i = 0; i < nregs; i++)
+           SET_HARD_REG_BIT (live_hard_regs, hard_regno + i);
        }
       bitmap_and (avail_cands, &get_remat_bb_data (bb)->avin_cands,
                  &get_remat_bb_data (bb)->livein_cands);