https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114747
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Kito Cheng <k...@gcc.gnu.org>: https://gcc.gnu.org/g:c4c0b0be87b4e08dab0e5e62c6f38a610a7423e7 commit r13-8701-gc4c0b0be87b4e08dab0e5e62c6f38a610a7423e7 Author: Kito Cheng <kito.ch...@sifive.com> Date: Mon May 6 23:45:22 2024 +0800 RISC-V: Fix vsetvli local eliminate [PR114747] vsetvli local eliminate is only consider the current demand instead of full demand, and it will use that incomplete info to remove vsetvli. Give following example from PR114747: vsetvli a5,a1,e8,m4,ta,mu # 57, ratio=2, sew=8, lmul=4 vsetvli zero,a5,e16,m8,ta,ma # 58, ratio=2, sew=16, lmul=8 vle8.v v8,0(a0) # 13, demand ratio=2 vzext.vf2 v24,v8 # 14, demand sew=16 and lmul=8 Insn #58 will removed because #57 has satisfied demand of #13, but it's not consider #14. It should doing more demand analyze, but this bug only present in GCC 13 branch, and we should not change too much on this release branch, so the best way is make the check more conservative - remove only if the target vsetvl_discard_result having same SEW and LMUL as the source vsetvli. gcc/ChangeLog: PR target/114747 * config/riscv/riscv-vsetvl.cc (local_eliminate_vsetvl_insn): Check target vsetvl_discard_result and source vsetvli has same SEW and LMUL. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/vsetvl/pr114747.c: New.