RISC-V/libgcc: Reduce the size of RV64 millicode by 6 bytes
authorMaciej W. Rozycki <macro@wdc.com>
Fri, 31 Jul 2020 22:52:20 +0000 (23:52 +0100)
committerMaciej W. Rozycki <macro@wdc.com>
Fri, 31 Jul 2020 22:52:20 +0000 (23:52 +0100)
commit9fa4023c7aa0ab126b00fe7e640ed9858b249c77
treed5b31bcdac3dd07ec7bf1cb16466752d277e3e6c
parentd1da25fe991ca7140c4ecce39b30aacd6f78c921
RISC-V/libgcc: Reduce the size of RV64 millicode by 6 bytes

Rewrite code sequences throughout the 64-bit RISC-V `__riscv_save_*'
routines replacing `li t1, -48', `li t1, -64', and `li t1, -80',
instructions, which do not have a compressed encoding, respectively with
`li t1, 3', `li t1, 4', and `li t1, 4', which do, and then adjusting the
remaining code accordingly observing that `sub sp, sp, t1' takes the
same amount of space as an `slli t1, t1, 4'/`add sp, sp, t1' instruction
pair does, again due to the use of compressed encodings, saving 6 bytes
total.

This change does increase code size by 4 bytes for RISC-V processors
lacking the compressed instruction set, however their users couldn't
care about the code size or they would have chosen an implementation
that does have the compressed instructions, wouldn't they?

libgcc/
* config/riscv/save-restore.S [__riscv_xlen == 64]
(__riscv_save_10, __riscv_save_8, __riscv_save_6, __riscv_save_4)
(__riscv_save_2): Replace negative immediates used for the final
stack pointer adjustment with positive ones, right-shifted by 4.
libgcc/config/riscv/save-restore.S