On Fri, Sep 4, 2026 at 9:09 PM Max Filippov <[email protected]> wrote: > > From: Takayuki 'January June' Suwa <[email protected]> > > When the target-specific implementation for the "-fzero-call-used-regs" > option was introduced in a previous commit (00e551bf "xtensa: Implement > TARGET_ZERO_CALL_USED_REGS"), > it was assumed that at least one address (general-purpose) register would > always be cleared to zero, and that register was then used to wipe out > other non-GP registers. However, it turns out that this approach fails > in very simple cases: > > /* example (-fzero-call-used-regs=used ; TARGET_HARD_FLOAT) */ > void test(void) { > asm volatile("":::"f0"); > } > > This patch resolves the issue by modifying the implementation so that, > if no address registers are cleared, the A9 register (already adopted > for various adjustments in the prologue/epilogue) is zeroed out instead > and used to clear other non-GP registers. > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (xtensa_zero_call_used_regs): > Change to assign 0 to the A9 register and then use it to clear > other non-GP registers, instead of triggering a gcc_assert() > failure when the address register is not zeroed out at all. > > gcc/testsuite: > * gcc.target/xtensa/zero-scratch-regs-1.c: New test. > --- > Changes v1->v2: > - add test > > gcc/config/xtensa/xtensa.cc | 28 ++++++++----------- > .../gcc.target/xtensa/zero-scratch-regs-1.c | 20 +++++++++++++ > 2 files changed, 31 insertions(+), 17 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/xtensa/zero-scratch-regs-1.c
Regtested for target=xtensa-linux-uclibc, no new regressions. Committed to master. -- Thanks. -- Max
