RISC-V: Fix bugs for refine vsetvl a5, zero into vsetvl zero, zero incorrectly
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Tue, 3 Jan 2023 06:55:30 +0000 (14:55 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 26 Jan 2023 18:53:00 +0000 (02:53 +0800)
commit005fad9d251b7ce6c009b646e213fbbf8d43a02b
tree6ba4b2e4745d5a5104b80c8ad9f25d4333b18b6d
parent91a41201b5cea1d72cd84e0e8751289774fcba42
RISC-V: Fix bugs for refine vsetvl a5, zero into vsetvl zero, zero incorrectly

Currently we support this optimization:

bb 0:
 vsetvli a5,zero,e32,mf2
bb 1:
 vsetvli a5,zero,e64,m1 --> vsetvli zero,zero,e64,m1

According RVV ISA, we can do this optimization only if both RATIO and AVL are equal.
However, current VSETVL PASS missed the check of AVL. This patch add this condition
check to fix bugs.

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (vector_infos_manager::all_same_avl_p): New function.
(pass_vsetvl::can_refine_vsetvl_p): Add AVL check.
(pass_vsetvl::commit_vsetvls): Ditto.
* config/riscv/riscv-vsetvl.h: New function declaration.
gcc/config/riscv/riscv-vsetvl.cc
gcc/config/riscv/riscv-vsetvl.h