]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Fix vl_used_by_non_rvv_insn logic of vsetvl pass
authorgarthlei <garthlei@linux.alibaba.com>
Wed, 11 Sep 2024 09:09:37 +0000 (17:09 +0800)
committerPan Li <pan2.li@intel.com>
Thu, 12 Sep 2024 01:14:58 +0000 (09:14 +0800)
commitc08e493ceee47bbeb466eeef100be7c1dd01a4e5
tree552c80ec508143e9a127a203e80d72516dcf296f
parentba393bf8879e5cf1f917bd88246d6b80ac081052
RISC-V: Fix vl_used_by_non_rvv_insn logic of vsetvl pass

This patch fixes a bug in the current vsetvl pass.  The current pass uses
`m_vl` to determine whether the dest operand has been used by non-RVV
instructions.  However, `m_vl` may have been modified as a result of an
`update_avl` call, and thus would be no longer the dest operand of the
original instruction.  This can lead to incorrect vsetvl eliminations, as is
shown in the testcase.  In this patch, we create a `dest_vl` variable for
this scenerio.

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc: Use `dest_vl` for dest VL operand

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/vsetvl_bug-3.c: New test.
gcc/config/riscv/riscv-vsetvl.cc
gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vsetvl_bug-3.c [new file with mode: 0644]