-
- Downloads
RISC-V: optimize stack manipulation in save-restore
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/ * config/riscv/riscv.cc (riscv_expand_prologue): Consider save-restore in stack allocation. (riscv_expand_epilogue): Consider save-restore in stack deallocation. gcc/testsuite * gcc.target/riscv/stack_save_restore.c: New test.
Loading
Please register or sign in to comment