> I actually had a version like this:
>
> /* In riscv_builtin_vectorization_cost: */
> case vec_perm:
> return common_costs->permute_cost[LMUL_1];
> /* In adjust_stmt_cost: */
> if (VECTOR_TYPE_P (vectype))
> {
> if (kind == vec_perm)
> stmt_cost = common_costs->permute_cost[vlmul];
> else
> stmt_cost *= get_lmul_cost_scaling (TYPE_MODE (vectype));
> }
>
> I ended up changing it to the current version because the cost table
> already gives the full per-LMUL costs, so return permute_cost[LMUL_1] in
> builtin_vectorization_cost, but in adjust_stmt_cost, we dont use it,
> and yet lookup permute_cost again and overwrite the stmt_cost. that
> felt a bit weird.
> On the other hand, this way put the LMUL scaling adjust in one place,
> so both ok to me. your call.
Yes, not ideal either with looking up permute_cost twice but I'd prefer
get_lmul_cost_scaling to continue to handle the scaling. We already get
the lmul in there anyway and it has the linear scaling built in.
Therefore it seems most natural to me, for now at least.
Then we would always have:
stmt_cost *= get_lmul_cost_scaling (kind, TYPE_MODE (vectype))
and have that determine the scaling per 'kind'.
But of course not a big deal either way.
--
Regards
Robin