From: Vladimir N. Makarov Date: Wed, 29 Apr 2026 13:37:11 +0000 (-0400) Subject: [LRA]: Fix a bug in updating live info in rematerialization X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef039a5bf888f736eb4504fe1322b8c1d5523dea;p=thirdparty%2Fgcc.git [LRA]: Fix a bug in updating live info in rematerialization 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. --- diff --git a/gcc/lra-remat.cc b/gcc/lra-remat.cc index c4da3f75e59..20d9f47d2e9 100644 --- a/gcc/lra-remat.cc +++ b/gcc/lra-remat.cc @@ -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);