No. we can't.

My goal is to forbid this following situation:

bb 2:
EMPTY (no any vsetvl and rvv insn)
bb 3:
user vsetvl.

We forbid user vsetvl (bb 3) be move to bb 2 in earliest fusion since user 
vsetvl has no side effects
and we believe user vsetvl in bb 3 here is early enough.

However, if we skip that as your patch, we will end up with missing this 
optimization:

bb 2:
user vsetvl a5, a4, e8, mf4...
vle8
vse8

bb 3:
user vsetvl a5, a4, e16, mf2... -----> In phase 1 && phase 2, the local demand 
fusion will update it into (e32, m1)
vle32
vadd
vse32

If we skip at the top, we will be missing fuse user vsetvl (in bb 3 e32 m1) 
into user vsetvl (in bb 2 e8 mf4).

Thanks. 


juzhe.zh...@rivai.ai
 
From: Kito Cheng
Date: 2023-08-28 16:58
To: Robin Dapp
CC: Juzhe-Zhong; gcc-patches; kito.cheng
Subject: Re: [PATCH] RISC-V: Disable user vsetvl fusion into EMPTY block
Is it possible to skip that at the topper level like that?
 
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 682f795c8e1..654d25de593 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -3269,7 +3269,7 @@ pass_vsetvl::earliest_fusion (void)
      for (size_t i = 0; i < m_vector_manager->vector_exprs.length (); i++)
       {
         auto &expr = *m_vector_manager->vector_exprs[i];
-         if (expr.empty_p ())
+         if (expr.empty_p () || vsetvl_insn_p (expr.get_insn ()->rtl ()))
           continue;
         edge eg = INDEX_EDGE (m_vector_manager->vector_edge_list, ed);
         if (eg->src == ENTRY_BLOCK_PTR_FOR_FN (cfun)
 

Reply via email to