]> git.ipfire.org Git - thirdparty/gcc.git/commit
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)
committerGiuliano Belinassi <giuliano.belinassi@usp.br>
Mon, 17 Aug 2020 16:20:30 +0000 (13:20 -0300)
commitc9bc25943e9e9eef7e75fdcaa7713b156bdb067e
treec904517684d9d60f981fa158a6ef370e8b53b419
parent2617a4ed6d4f945aba9644ffcb9ae1263f5ed151
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