https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119115
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Robin Dapp <rd...@gcc.gnu.org>: https://gcc.gnu.org/g:77ef91d7159613c0cfc2920ddd5a32952c61ff5b commit r15-8022-g77ef91d7159613c0cfc2920ddd5a32952c61ff5b Author: Robin Dapp <rd...@ventanamicro.com> Date: Wed Mar 5 18:16:57 2025 +0100 RISC-V: Do not delete fused vsetvl if it has uses [PR119115]. In PR119115 we end up with an orphaned vsetvli zero,t1,e16,m1,ta,ma. t1 originally came from another vsetvl that was fused from vsetvli a4,a3,e8,mf2,ta,ma vsetvli t1,a3,e8,mf2,ta,ma (1) to vsetvli zero,a3,e16,m1,ta,ma. This patch checks if t1, the VL operand of (1), has AVL uses and does not delete the vsetvl if so. While doing so, it also wraps the search for VL uses into two new functions reg_used and reg_single_use_in_avl. PR target/119115 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (reg_used): New function. (reg_single_use_in_avl): Ditto. (pre_vsetvl::fuse_local_vsetvl_info): Use reg_single_use_in_avl when checking if vsetvl can be deleted. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pr119115.c: New test.