https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127075
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Robin Dapp <[email protected]>: https://gcc.gnu.org/g:a924d879f01d00d6c29e870c51bebcbf5e5a96eb commit r17-4724-ga924d879f01d00d6c29e870c51bebcbf5e5a96eb Author: Robin Dapp <[email protected]> Date: Fri Sep 25 15:39:34 2026 +0200 RISC-V: Consider spills in conv-dynamic LMUL [PR127075]. This patch makes -mrvv-max-lmul=conv-dynamic spill aware. As reported by Anton, Peter in PR127075, we don't consider spilling when letting the LMUL decision just be dependent on the size ratio of largest and smallest type. This causes spills when building x264 with the conv-dynamic mode. Although the original idea was to have a more deterministic approach than pure "dynamic", determinism alone is not too helpful when spills are still possible. Thus, this patch merges the spill estimate of "dynamic" into "conv-dynamic" and also corrects some slight mistakes in "dynamic". I factored out the lmul-comparison logic into its own function so better_main_loop_than_p is a bit easier to follow. While at it, I renamed some functions and computed the type size ratio in add_stmt_cost which is much more straightforward than before. PR target/127075 gcc/ChangeLog: * config/riscv/riscv-vector-costs.cc (compute_estimated_lmul): Rename... (estimate_lmul): ...To this. (compute_lmul_from_conversion_ratio): Remove. (costs::compute_live_ranges_and_lmul): Remove param. (costs::compute_conversion_dynamic_lmul): Remove. (costs::has_unexpected_spills_p): Rename... (costs::has_spills_p): ...To This. (costs::record_lmul_spills): Adjust comment. (costs::record_potential_unexpected_spills): Rename... (costs::record_potential_spills): ...To this. (costs::compare_lmul_to): New function. (costs::better_main_loop_than_p): Call new function. (costs::record_type_sizes): New function. (costs::add_stmt_cost): Call new function. (costs::finish_cost): Compute type ratio for LMUL. * config/riscv/riscv-vector-costs.h: Declare new function. gcc/testsuite/ChangeLog: * gcc.dg/vect/costmodel/riscv/rvv/pr127075.c: New test.
