> -----Original Message-----
> From: Richard Biener <[email protected]>
> Sent: Wednesday, June 17, 2026 8:33 PM
> To: [email protected]
> Cc: Liu, Hongtao <[email protected]>
> Subject: [PATCH 5/5] [x86] use recorded vector composition type for costing
> 
> We're making vector construction extra costly but too much because we up to
> now do not know the actual vector composition type used.  This makes use of
> this now available information.
> 
> Prerequesites changed in this [v2], we now get vec_deconstruct, counting
> only once instead of nunits time.  I've checked this works out and I now see
> 
> XPASS: gcc.target/i386/pr89618-2.c scan-tree-dump vect "loop vectorized
> using 16 byte vectors"
> 
> which I'll double-check before removing the XFAIL.  I do want to get rid of 
> that
> 
> +      stmt_cost *= (GET_MODE_BITSIZE (TYPE_MODE (ls_type))
> +                   / GET_MODE_BITSIZE (TYPE_MODE (ls_eltype)) + 1);
> 
> scaling, at least at this very place, and at most keep an overall counter of
> construction/deconstructions to apply a penalty at the end.  For V2SI (de-
> )composition counting 3 times the actual cost is overzealous at least.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
> 
> OK in principle?

Ok.
> 
> I'm waiting on the other target maintainers for the vec_deconstruct
> prerequesite.
> 
>       * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
>       Use vector construction scaling also for mult-lane
>       VMAT_STRIDED_SLP but use vector composition type recorded
>       to avoid excessive over-costing.
> ---
>  gcc/config/i386/i386.cc | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index
> c0a0204b9b6..2b4d878a550 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -26731,15 +26731,20 @@ ix86_vector_costs::add_stmt_cost (int count,
> vect_cost_for_stmt kind,
>    if ((kind == vec_construct || kind == vec_deconstruct)
>        && ((node
>          && (((SLP_TREE_MEMORY_ACCESS_TYPE (node) ==
> VMAT_ELEMENTWISE
> -              || (SLP_TREE_MEMORY_ACCESS_TYPE (node) ==
> VMAT_STRIDED_SLP
> -                  && SLP_TREE_LANES (node) == 1))
> +              || SLP_TREE_MEMORY_ACCESS_TYPE (node) ==
> VMAT_STRIDED_SLP)
>               && (TREE_CODE (DR_STEP (STMT_VINFO_DATA_REF
>                                       (SLP_TREE_REPRESENTATIVE
> (node))))
>                   != INTEGER_CST))
>              || mat_gather_scatter_p (SLP_TREE_MEMORY_ACCESS_TYPE
> (node))))))
>      {
> -      stmt_cost = ix86_default_vector_cost (kind, mode);
> -      stmt_cost *= (TYPE_VECTOR_SUBPARTS (vectype) + 1);
> +      auto lsdata = static_cast<vect_load_store_data *> (node->data);
> +      tree ls_type = lsdata->ls_type ? lsdata->ls_type : vectype;
> +      tree ls_eltype
> +     = lsdata->ls_eltype ? lsdata->ls_eltype : TREE_TYPE (ls_type);
> +      stmt_cost = ix86_vector_cd_cost (TYPE_MODE (ls_type),
> +                                    TYPE_MODE (ls_eltype));
> +      stmt_cost *= (GET_MODE_BITSIZE (TYPE_MODE (ls_type))
> +                 / GET_MODE_BITSIZE (TYPE_MODE (ls_eltype)) + 1);
>      }
>    else if ((kind == vec_construct || kind == scalar_to_vec)
>          && node
> --
> 2.51.0

Reply via email to