https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113247
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Pan Li <pa...@gcc.gnu.org>: https://gcc.gnu.org/g:7be87b7d2e330afd14a7cc028f64d88f80e12f40 commit r14-7245-g7be87b7d2e330afd14a7cc028f64d88f80e12f40 Author: Juzhe-Zhong <juzhe.zh...@rivai.ai> Date: Mon Jan 15 20:00:14 2024 +0800 RISC-V: Fix regression (GCC-14 compare with GCC-13.2) of SHA256 from coremark-pro This patch fixes -70% performance drop from GCC-13.2 to GCC-14 with -march=rv64gcv in real hardware. The root cause is incorrect cost model cause inefficient vectorization which makes us performance drop significantly. So this patch does: 1. Adjust vector to scalar cost by introducing v to scalar reg move. 2. Adjust vec_construct cost since we does spend NUNITS instructions to construct the vector. Tested on both RV32/RV64 no regression, Rebase to the trunk and commit it as it is approved by Robin. PR target/113247 gcc/ChangeLog: * config/riscv/riscv-protos.h (struct regmove_vector_cost): Add vector to scalar regmove. * config/riscv/riscv-vector-costs.cc (adjust_stmt_cost): Ditto. * config/riscv/riscv.cc (riscv_builtin_vectorization_cost): Adjust vec_construct cost. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vls/reduc-19.c: Adapt test. * gcc.target/riscv/rvv/autovec/vls/reduc-20.c: Ditto. * gcc.target/riscv/rvv/autovec/vls/reduc-21.c: Ditto. * gcc.dg/vect/costmodel/riscv/rvv/pr113247-1.c: New test. * gcc.dg/vect/costmodel/riscv/rvv/pr113247-2.c: New test. * gcc.dg/vect/costmodel/riscv/rvv/pr113247-3.c: New test. * gcc.dg/vect/costmodel/riscv/rvv/pr113247-4.c: New test.