LGTM, and I guess you will remove get_all_predecessors once LMUL cost
model can use dominator info as well?


On Mon, Sep 11, 2023 at 11:34 AM Juzhe-Zhong <juzhe.zh...@rivai.ai> wrote:
>
> I found that it's more reasonable to use existing dominance analysis.
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv-vsetvl.cc 
> (pass_vsetvl::global_eliminate_vsetvl_insn): Use dominance analysis.
>         (pass_vsetvl::init): Ditto.
>         (pass_vsetvl::done): Ditto.
>
> ---
>  gcc/config/riscv/riscv-vsetvl.cc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/riscv/riscv-vsetvl.cc 
> b/gcc/config/riscv/riscv-vsetvl.cc
> index 134b97737ae..f81361c4ccd 100644
> --- a/gcc/config/riscv/riscv-vsetvl.cc
> +++ b/gcc/config/riscv/riscv-vsetvl.cc
> @@ -4054,7 +4054,7 @@ pass_vsetvl::global_eliminate_vsetvl_insn (const 
> bb_info *bb) const
>      }
>
>    /* Step1: Reshape the VL/VTYPE status to make sure everything compatible.  
> */
> -  hash_set<basic_block> pred_cfg_bbs = get_all_predecessors (cfg_bb);
> +  auto_vec<basic_block> pred_cfg_bbs = get_dominated_by 
> (CDI_POST_DOMINATORS, cfg_bb);
>    FOR_EACH_EDGE (e, ei, cfg_bb->preds)
>      {
>        sbitmap avout = m_vector_manager->vector_avout[e->src->index];
> @@ -4243,6 +4243,7 @@ pass_vsetvl::init (void)
>      {
>        /* Initialization of RTL_SSA.  */
>        calculate_dominance_info (CDI_DOMINATORS);
> +      calculate_dominance_info (CDI_POST_DOMINATORS);
>        df_analyze ();
>        crtl->ssa = new function_info (cfun);
>      }
> @@ -4264,6 +4265,7 @@ pass_vsetvl::done (void)
>      {
>        /* Finalization of RTL_SSA.  */
>        free_dominance_info (CDI_DOMINATORS);
> +      free_dominance_info (CDI_POST_DOMINATORS);
>        if (crtl->ssa->perform_pending_updates ())
>         cleanup_cfg (0);
>        delete crtl->ssa;
> --
> 2.36.3
>

Reply via email to