RISC-V: Adjust scalar_to_vec cost
commit0acb63670bf1058fce00a75bd318c40be3bfa222
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Fri, 12 Jan 2024 09:28:44 +0000 (12 17:28 +0800)
committerPan Li <pan2.li@intel.com>
Fri, 12 Jan 2024 12:15:51 +0000 (12 20:15 +0800)
tree65c43fe3e1430701918510faf52ab58a1b142d0a
parentc75579169eba269a7c339d80b5ac0239f36a58b3
RISC-V: Adjust scalar_to_vec cost

1. Introduce vector regmove new tune info.
2. Adjust scalar_to_vec cost in add_stmt_cost.

We will get optimal codegen after this patch with -march=rv64gcv_zvl256b:

lui a5,%hi(a)
li a4,19
sb a4,%lo(a)(a5)
li a0,0
ret

Tested on both RV32/RV64 no regression, Ok for trunk ?

PR target/113281

gcc/ChangeLog:

* config/riscv/riscv-protos.h (struct regmove_vector_cost): New struct.
(struct cpu_vector_cost): Add regmove struct.
(get_vector_costs): Export as global.
* config/riscv/riscv-vector-costs.cc (adjust_stmt_cost): Adjust scalar_to_vec cost.
(costs::add_stmt_cost): Ditto.
* config/riscv/riscv.cc (get_common_costs): Export global function.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr113209.c: Adapt test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113281-1.c: New test.
* gcc.dg/vect/costmodel/riscv/rvv/pr113281-2.c: New test.
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv-vector-costs.cc
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr113281-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr113281-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113209.c