[V2] RISC-V: Forbidden fuse vlmax vsetvl to DEMAND_NONZERO_AVL vsetvl
Checks
Commit Message
Hi,
This little patch fix the fail testcase
(gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c)
after apply this patch
(https://gcc.gnu.org/pipermail/gcc-patches/2023-August/627121.html).
The specific reason is that the vsetvl pass has bug and this patch
forbidden the fuse of this case. This patch needs to be committed
before that patch to work.
Best,
Lehua
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (pass_vsetvl::backward_demand_fusion):
Forbidden.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c:
Address failure due to uninitialized vtype register.
---
gcc/config/riscv/riscv-vsetvl.cc | 17 +++++++++++++++++
.../autovec/gather-scatter/strided_load_run-1.c | 6 ++++++
2 files changed, 23 insertions(+)
Comments
OK, thanks.
Regards
Robin
Committed, thanks Robin.
------------------ Original ------------------
From: "Robin Dapp" <rdapp.gcc@gmail.com>;
Date: Thu, Aug 17, 2023 10:10 PM
To: "Lehua Ding"<lehua.ding@rivai.ai>;"gcc-patches"<gcc-patches@gcc.gnu.org>;
Cc: "rdapp.gcc"<rdapp.gcc@gmail.com>;"juzhe.zhong"<juzhe.zhong@rivai.ai>;"kito.cheng"<kito.cheng@gmail.com>;"palmer"<palmer@rivosinc.com>;"jeffreyalaw"<jeffreyalaw@gmail.com>;
Subject: Re: [PATCH V2] RISC-V: Forbidden fuse vlmax vsetvl to DEMAND_NONZERO_AVL vsetvl
OK, thanks.
Regards
Robin
@@ -3330,6 +3330,23 @@ pass_vsetvl::backward_demand_fusion (void)
else if (block_info.reaching_out.dirty_p ())
{
/* DIRTY -> DIRTY or VALID -> DIRTY. */
+
+ /* Forbidden this case fuse because it change the value of a5.
+ bb 1: vsetvl zero, no_zero_avl
+ ...
+ use a5
+ ...
+ bb 2: vsetvl a5, zero
+ =>
+ bb 1: vsetvl a5, zero
+ ...
+ use a5
+ ...
+ bb 2:
+ */
+ if (block_info.reaching_out.demand_p (DEMAND_NONZERO_AVL)
+ && vlmax_avl_p (prop.get_avl ()))
+ continue;
vector_insn_info new_info;
if (block_info.reaching_out.compatible_p (prop))
@@ -7,6 +7,12 @@
int
main (void)
{
+ /* FIXME: The purpose of this assembly is to ensure that the vtype register is
+ initialized befor instructions such as vmv1r.v are executed. Otherwise you
+ will get illegal instruction errors when running with spike+pk. This is an
+ interim solution for reduce unnecessary failures and a unified solution
+ will come later. */
+ asm volatile("vsetivli x0, 0, e8, m1, ta, ma");
#define RUN_LOOP(DATA_TYPE, BITS) \
DATA_TYPE dest_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)]; \
DATA_TYPE dest2_##DATA_TYPE##_##BITS[(BITS - 3) * (BITS + 13)]; \