On Sat, May 10, 2025 at 12:51 PM Takayuki 'January June' Suwa <jjsuwa_sys3...@yahoo.co.jp> wrote: > > Until now (presumably after transition to LRA), hard registers storing > function arguments or return values were spilling undesirably when > TARGET_HARD_FLOAT is enabled. > > /* example */ > float test0(float a, float b) { > return a + b; > } > extern float foo(void); > float test1(void) { > return foo() * 3.14f; > } > > ;; before > test0: > entry sp, 48 > wfr f0, a2 > wfr f1, a3 > add.s f0, f0, f1 > s32i.n a2, sp, 0 ;; unwanted spilling-out > s32i.n a3, sp, 4 ;; > rfr a2, f0 > retw.n > .literal .LC1, 1078523331 > test1: > entry sp, 48 > call8 foo > l32r a8, .LC1 > wfr f0, a10 > wfr f1, a8 > mul.s f0, f0, f1 > s32i.n a10, sp, 0 ;; unwanted spilling-out > rfr a2, f0 > retw.n > > Ultimately, that is because the costs of moving between integer and > floating-point hard registers are undefined and the default (large value) > is used. This patch fixes this. > > ;; after > test0: > entry sp, 32 > wfr f1, a2 > wfr f0, a3 > add.s f0, f1, f0 > rfr a2, f0 > retw.n > .literal .LC1, 1078523331 > test1: > entry sp, 32 > call8 foo > l32r a8, .LC1 > wfr f1, a10 > wfr f0, a8 > mul.s f0, f1, f0 > rfr a2, f0 > retw.n > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (xtensa_register_move_cost): > Add appropriate move costs between AR_REGS and FP_REGS. > --- > gcc/config/xtensa/xtensa.cc | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-)
Regtested for target=xtensa-linux-uclibc, no new regressions. Committed to master. That's a nice fix, thank you Suwa-san! -- Thanks. -- Max