On Thu, Jan 11, 2024 at 11:20 AM juzhe.zh...@rivai.ai
<juzhe.zh...@rivai.ai> wrote:
>
> Ok I see your idea and we need to adjust scalar_to_vec accurately. Inside the 
> loop we have these 2 scalar_to_vec:
>
> 1. MIN_EXPR <patt_28, 15> 1 times scalar_to_vec costs 1 in prologue
>
>    This scalar_to_vec cost should be 0 or 1 since it only generate single 
> instructions: vmv.v.i v16,15
>
> 2. 32872 >> patt_26 1 times scalar_to_vec costs 1 in prologue
>
>    This cost should be higher since it cost 3 instructions:
>     li a4,-32768
>     addiw a4,a4,104
>     vmv.v.x v16,a4
>
> Am I correct ?
>
> I guess if we cost 1 case as 1 cost and 2 case as 3 cost. Then we will be 
> good.

The cost model interface isn't set up very well to cost different constants
differently.  For scalar_to_vec we should get the backend the actual scalar
to duplicate but we don't.

> ________________________________
> juzhe.zh...@rivai.ai
>
>
> From: Robin Dapp
> Date: 2024-01-11 18:14
> To: juzhe.zh...@rivai.ai; Richard Biener
> CC: rdapp.gcc; gcc-patches; kito.cheng; Kito.cheng; jeffreyalaw
> Subject: Re: [PATCH] RISC-V: Increase scalar_to_vec_cost from 1 to 3
> >  Yeah... I just noticed. I should set it as 4 to fix it with biggest VLEN 
> > size,
> > that is, -march=rv64gcv_zvl4096b --param=riscv-autovec-lmul=m8...
> >
> > I am confused now how to fix this case.
>
> 4 is definitely too high compared to a regular instruction.
> vmv.vx could even be zero-cost for constants.
>
> To catch constants we could add handling in add_stmt_cost, inspecting
> the stmt directly.
>
> Regards
> Robin
>

Reply via email to