]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Enable Hoist to GCSE simple constants
authorVineet Gupta <vineetg@rivosinc.com>
Mon, 7 Aug 2023 20:45:29 +0000 (13:45 -0700)
committerVineet Gupta <vineetg@rivosinc.com>
Fri, 25 Aug 2023 19:20:18 +0000 (12:20 -0700)
commitb41d7eb0e14785ff0ad6e6922cbd4c880e680bf9
treec051cbe9583c301683b7f9f05c0af9c5384b18a3
parentd9a0d692ffc6951c5670f54c3f4f17ec64a58600
RISC-V: Enable Hoist to GCSE simple constants

Hoist want_to_gcse_p () calls rtx_cost () to compute max distance for
hoist candidates. For a simple const (say 6 which needs seperate insn "LI 6")
backend currently returns 0, causing Hoist to bail and elide GCSE.

Note that constants requiring more than 1 insns to setup were working
fine since riscv_rtx_costs () was returning non-zero (although that
itself might need refining: see bugzilla 111139).

To keep testsuite parity, some V tests need updating which started failing
in the new costing regime.

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_rtx_costs): Adjust const_int
cost. Add some comments about different constants handling.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/gcse-const.c: New Test
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-7.c: Remove test
for Jump.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-8.c: Ditto.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/gcse-const.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_conflict-7.c
gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_conflict-8.c