https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122846
--- Comment #3 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:45bd656eb5ce5850a6f7de34850383a326895bb8 commit r16-6587-g45bd656eb5ce5850a6f7de34850383a326895bb8 Author: Robin Dapp <[email protected]> Date: Wed Dec 10 19:02:11 2025 +0100 RISC-V: -mrvv-max-lmul=conv-dynamic [PR122846]. As discussed in the patchwork sync this patch adds a dynamic LMUL mode that sets the LMUL to the ratio of largest/smallest type size in a loop, with the maximum being LMUL8. This is supposed to imitate what other architectures implicitly do by vec_unpack_hi/lo. I have done cursory testing and obviously more coverage would be preferred. PR target/122846 gcc/ChangeLog: * config/riscv/riscv-opts.h (enum rvv_max_lmul_enum): Add RVV_CONV_DYNAMIC. (TARGET_MAX_LMUL): Ditto. * config/riscv/riscv-string.cc (use_vector_stringop_p): Use LMUL1 for RVV_CONV_DYNAMIC. (expand_rawmemchr): Ditto. (expand_strcmp): Ditto. (check_vectorise_memory_operation): Ditto. * config/riscv/riscv-vector-costs.cc (get_smallest_mode): New function. (compute_lmul_from_conversion_ratio): Calculate LMUL from largest/smallest type. (costs::has_unexpected_spills_p): Split. (costs::compute_live_ranges_and_lmul): Compute smallest type and call new function. (costs::cleanup_live_range_data): New function. (costs::compute_conversion_dynamic_lmul): New function. (costs::record_potential_unexpected_spills): Use new function. (costs::better_main_loop_than_p): Allow appropriate LMUL. * config/riscv/riscv-vector-costs.h: Declare. * config/riscv/riscv.opt: New option -mrvv-max-lmul=conv-dynamic. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/dyn-lmul-conv-1.c: New test. * gcc.target/riscv/rvv/autovec/dyn-lmul-conv-2.c: New test. * gcc.target/riscv/rvv/autovec/pr122846.c: New test.
