On Fri, May 8, 2026 at 5:43 PM Richard Biener <[email protected]> wrote:
>
> The following adds special handling to OMP SIMD vector call costs
> which were not costed at all and for which a single simple vector
> stmt isn't appropriate.  PR125174 shows that even when AVX imposes
> more overhead (from also slightly bogus costing) than SSE, when
> there's two OMP SIMD calls involved doing less of those should trump
> that.  We achieve that by giving a call that is vectorized as call
> a higher cost, currently hard coded to 10 times a FMA operation
> of the corresponding mode.
>
> v2 replaces the explicit list of known functions with a check
> on available SIMD clones (all .MASK_CALL are of this class,
> guaranteed by if-conversion).
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>
> OK?
Looks reasonable to me.
>
> Thanks,
> Richard.
>
>         PR target/125174
>         * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost):
>         Cost calls as 10 times FMA.
> ---
>  gcc/config/i386/i386.cc | 40 ++++++++++++++++++++++++++--------------
>  1 file changed, 26 insertions(+), 14 deletions(-)
>
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
> index e73c2d7f7d0..9aecd51119f 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -26591,20 +26591,32 @@ ix86_vector_costs::add_stmt_cost (int count, 
> vect_cost_for_stmt kind,
>    if ((kind == vector_stmt || kind == scalar_stmt)
>        && stmt_info
>        && stmt_info->stmt
> -      && (cfn = gimple_call_combined_fn (stmt_info->stmt)) != CFN_LAST)
> -    switch (cfn)
> -      {
> -      case CFN_FMA:
> -       stmt_cost = ix86_vec_cost (mode,
> -                                  mode == SFmode ? ix86_cost->fmass
> -                                  : ix86_cost->fmasd);
> -       break;
> -      case CFN_MULH:
> -       stmt_cost = ix86_multiplication_cost (ix86_cost, mode);
> -       break;
> -      default:
> -       break;
> -      }
> +      && is_gimple_call (stmt_info->stmt))
> +    {
> +      tree fndecl = gimple_call_fndecl (stmt_info->stmt);
> +      cgraph_node *node;
> +      if ((fndecl
> +          && (node = cgraph_node::get (fndecl))
> +          && node->simd_clones)
> +         || gimple_call_internal_p (stmt_info->stmt, IFN_MASK_CALL))
> +       stmt_cost = 10 * ix86_vec_cost (mode,
> +                                       mode == SFmode ? ix86_cost->fmass
> +                                       : ix86_cost->fmasd);
> +      else if ((cfn = gimple_call_combined_fn (stmt_info->stmt)) != CFN_LAST)
> +       switch (cfn)
> +         {
> +         case CFN_FMA:
> +           stmt_cost = ix86_vec_cost (mode,
> +                                      mode == SFmode ? ix86_cost->fmass
> +                                      : ix86_cost->fmasd);
> +           break;
> +         case CFN_MULH:
> +           stmt_cost = ix86_multiplication_cost (ix86_cost, mode);
> +           break;
> +         default:
> +           break;
> +         }
> +    }
>
>    if (kind == vec_promote_demote)
>      {
> --
> 2.51.0



-- 
BR,
Hongtao

Reply via email to