]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH 1/3] RISC-V: Improve codegen for negative repeating large constants
authorRaphael Moreira Zinsly <rzinsly@ventanamicro.com>
Wed, 4 Sep 2024 23:21:24 +0000 (17:21 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Wed, 4 Sep 2024 23:21:24 +0000 (17:21 -0600)
commitcbea72b265e4c9d1a595bd3ecd11b325021925d0
tree95fbbc06c55296715ac38294251939c4d14aafae
parent5326306e7d9d36eccc2c2f02e1357818625f057b
[PATCH 1/3] RISC-V: Improve codegen for negative repeating large constants

Improve handling of constants where its upper and lower 32-bit
halves are the same and have negative values.

e.g. for:

unsigned long f (void) { return 0xf0f0f0f0f0f0f0f0UL; }

Without the patch:

li      a0,-252645376
addi    a0,a0,240
li      a5,-252645376
addi    a5,a5,241
slli    a5,a5,32
add     a0,a5,a0

With the patch:

li      a5,252645376
addi    a5,a5,-241
slli    a0,a5,32
add     a0,a0,a5
xori    a0,a0,-1

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_split_integer_cost): Adjust the
cost of negative repeating constants.
(riscv_split_integer): Handle negative repeating constants.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/synthesis-11.c: New test.
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/synthesis-11.c [new file with mode: 0644]