This can replace my earlier e-mail which addressed only ticket 117366. Since both the bugs are in one file and somewhat related, here's a larger patch that address both bugzilla tickets 117366 and 117468 (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117468): index bde06f3fa86..742b0904612 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -8274,7 +8274,7 @@ thumb1_prologue_unused_call_clobbered_lo_regs (void) bitmap prologue_live_out = df_get_live_out (ENTRY_BLOCK_PTR_FOR_FN (cfun)); for (int reg = FIRST_LO_REGNUM; reg <= LAST_LO_REGNUM; reg++) - if (!callee_saved_reg_p (reg) && !REGNO_REG_SET_P (prologue_live_out, reg)) + if (!callee_saved_reg_p (reg) && !REGNO_REG_SET_P (prologue_live_out, reg) && !fixed_regs[reg]) mask |= 1 << (reg - FIRST_LO_REGNUM); return mask; } @@ -8287,7 +8287,7 @@ thumb1_epilogue_unused_call_clobbered_lo_regs (void) bitmap epilogue_live_in = df_get_live_in (EXIT_BLOCK_PTR_FOR_FN (cfun)); for (int reg = FIRST_LO_REGNUM; reg <= LAST_LO_REGNUM; reg++) - if (!callee_saved_reg_p (reg) && !REGNO_REG_SET_P (epilogue_live_in, reg)) + if (!callee_saved_reg_p (reg) && !REGNO_REG_SET_P (epilogue_live_in, reg) && !fixed_regs[reg]) mask |= 1 << (reg - FIRST_LO_REGNUM); return mask; } @@ -26746,8 +26746,8 @@ thumb1_extra_regs_pushed (arm_stack_offsets *offsets, bool for_prologue) live_regs_mask >>= reg_base; } - while (reg_base + n_free < 8 && !(live_regs_mask & 1) - && (for_prologue || call_used_or_fixed_reg_p (reg_base + n_free))) + while (reg_base + n_free <= LAST_LO_REGNUM && !(live_regs_mask & 1) + && (for_prologue || (call_used_or_fixed_reg_p (reg_base + n_free) && !fixed_reg[reg_base + n_free]))) { live_regs_mask >>= 1; n_free++;
> On 06/11/2025 7:13 PM EDT Matt Parks <matt.pa...@go-aps.com> wrote: > > > See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117366 where it was > suggested I send this bug fix as a patch to gcc-patches. I have never > submitted to this alias so I apologize if I am not "doing it right", but here > is the diff, and the Bugzilla ticket has an example written up with good/bad > assembler code output. As the ticket notes, it has been a problem for years > and should be backported to the latest bugfix releases of older supported > versions as well. This patch reference is for master as of today, but the > base code is the same since gcc 10. >