On 12/1/22 03:03, Fei Gao wrote:
The stack that save-restore reserves is not well accumulated in stack
allocation and deallocation.
This patch allows less instructions to be used in stack allocation and
deallocation if save-restore enabled.
before patch:
bar:
call t0,__riscv_save_4
addi sp,sp,-64
...
li t0,-12288
addi t0,t0,-1968 # optimized out after patch
add sp,sp,t0 # prologue
...
li t0,12288 # epilogue
addi t0,t0,2000 # optimized out after patch
add sp,sp,t0
...
addi sp,sp,32
tail __riscv_restore_4
after patch:
bar:
call t0,__riscv_save_4
addi sp,sp,-2032
...
li t0,-12288
add sp,sp,t0 # prologue
...
li t0,12288 # epilogue
add sp,sp,t0
...
addi sp,sp,2032
tail __riscv_restore_4
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_expand_prologue): consider save-restore
in stack allocation.
(riscv_expand_epilogue): consider save-restore in stack deallocation.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/stack_save_restore.c: New test.
I made a couple of whitespace fixes and pushed this to the trunk after
running it through a cross testing cycle.
Thanks!
jeff