> -----Original Message-----
> From: Saurabh Jha via Sourceware Forge <forge-bot+saurabh.jha@forge-
> stage.sourceware.org>
> Sent: 30 October 2026 13:10
> To: gcc-patches mailing list <[email protected]>
> Cc: Tamar Christina <[email protected]>
> Subject: [PATCH v1 1/3] aarch64: Add two new fields to the tuning models for
> vector comparisons
> 
> From: Saurabh Jha <[email protected]>
> 
> Currently, we model vector comparisons using two fields,
> int_cmp_pred_ops and fp_cmp_pred_ops. As a consequence, we are only
> modelling the predication cost for comparison operations, which is
> not accurate.
> 
> We add two new fields, int_cmp_ops and fp_cmp_ops, that model the
> general cost of vector comparisons. We initialise these fields to 0
> in the tuning models for all cores.

0 is an odd one. For the fp_cmp_pred_ops this made sense as these
are additional cost on top of the general_ops of the instruction itself
which defaults to 1.

But for int_cmp_ops this then means implicitly that it's an "additional"
cost, so the comment and field names are misleading since setting
it to 1 actually means all int compares make 2 general ops.

So I think the default should be 1 and in the adjustment you just -1 it
to get the additional cost.

That makes it make more sense I think.

> 
> Regression tested on aarch64-linux-gnu and found no regressions.
> 
> gcc/ChangeLog:
> 
>       * config/aarch64/aarch64-protos.h
>       (struct aarch64_sve_vec_issue_info): Add fields int_cmp_ops and
>       fp_cmp_ops.

Adding a new field requires you to update the json serializers/deserializers.
So you also need to change gcc/config/aarch64/aarch64-json-schema.h which
should regenerate the other files.

Thanks,
Tamar

>       * config/aarch64/aarch64.cc
>       (aarch64_vector_costs::count_ops): Include the cost of
>       int_cmp_ops and fp_cmp_ops in general cost.
>       * config/aarch64/tuning_models/cortexx925.h: Add new cmp fields.
>       * config/aarch64/tuning_models/generic_armv9_a.h: Likewise.
>       * config/aarch64/tuning_models/hip12.h: Likewise.
>       * config/aarch64/tuning_models/neoverse512tvb.h: Likewise.
>       * config/aarch64/tuning_models/neoversen2.h: Likewise.
>       * config/aarch64/tuning_models/neoversen3.h: Likewise.
>       * config/aarch64/tuning_models/neoversev1.h: Likewise.
>       * config/aarch64/tuning_models/neoversev2.h: Likewise.
>       * config/aarch64/tuning_models/neoversev3.h: Likewise.
>       * config/aarch64/tuning_models/neoversev3ae.h: Likewise.
>       * config/aarch64/tuning_models/olympus.h: Likewise.
> ---
>  gcc/config/aarch64/aarch64-protos.h                | 12 ++++++++++++
>  gcc/config/aarch64/aarch64.cc                      | 13 +++++++++----
>  gcc/config/aarch64/tuning_models/cortexx925.h      |  2 ++
>  gcc/config/aarch64/tuning_models/generic_armv9_a.h |  2 ++
>  gcc/config/aarch64/tuning_models/hip12.h           |  2 ++
>  gcc/config/aarch64/tuning_models/neoverse512tvb.h  |  2 ++
>  gcc/config/aarch64/tuning_models/neoversen2.h      |  2 ++
>  gcc/config/aarch64/tuning_models/neoversen3.h      |  2 ++
>  gcc/config/aarch64/tuning_models/neoversev1.h      |  2 ++
>  gcc/config/aarch64/tuning_models/neoversev2.h      |  2 ++
>  gcc/config/aarch64/tuning_models/neoversev3.h      |  2 ++
>  gcc/config/aarch64/tuning_models/neoversev3ae.h    |  2 ++
>  gcc/config/aarch64/tuning_models/olympus.h         |  2 ++
>  13 files changed, 43 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/config/aarch64/aarch64-protos.h
> b/gcc/config/aarch64/aarch64-protos.h
> index bccdbffc194b5..800903d8ba9cd 100644
> --- a/gcc/config/aarch64/aarch64-protos.h
> +++ b/gcc/config/aarch64/aarch64-protos.h
> @@ -403,14 +403,18 @@ struct aarch64_sve_vec_issue_info :
> aarch64_simd_vec_issue_info
>      (aarch64_simd_vec_issue_info base,
>       unsigned int pred_ops_per_cycle,
>       unsigned int while_pred_ops,
> +     unsigned int int_cmp_ops,
>       unsigned int int_cmp_pred_ops,
> +     unsigned int fp_cmp_ops,
>       unsigned int fp_cmp_pred_ops,
>       unsigned int gather_scatter_pair_general_ops,
>       unsigned int gather_scatter_pair_pred_ops)
>      : aarch64_simd_vec_issue_info (base),
>        pred_ops_per_cycle (pred_ops_per_cycle),
>        while_pred_ops (while_pred_ops),
> +      int_cmp_ops (int_cmp_ops),
>        int_cmp_pred_ops (int_cmp_pred_ops),
> +      fp_cmp_ops (fp_cmp_ops),
>        fp_cmp_pred_ops (fp_cmp_pred_ops),
>        gather_scatter_pair_general_ops (gather_scatter_pair_general_ops),
>        gather_scatter_pair_pred_ops (gather_scatter_pair_pred_ops)
> @@ -423,10 +427,18 @@ struct aarch64_sve_vec_issue_info :
> aarch64_simd_vec_issue_info
>       instruction.  */
>    unsigned int while_pred_ops;
> 
> +  /* How many general operations are generated by an integer
> +     comparison instruction.  */
> +  unsigned int int_cmp_ops;
> +
>    /* How many predicate operations are generated by an integer
>       comparison instruction.  */
>    unsigned int int_cmp_pred_ops;
> 
> +  /* How many general operations are generated by a floating-point
> +     comparison instruction.  */
> +  unsigned int fp_cmp_ops;
> +
>    /* How many predicate operations are generated by a floating-point
>       comparison instruction.  */
>    unsigned int fp_cmp_pred_ops;
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index 9290677655aa3..f580ed3e2ff42 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -18789,10 +18789,15 @@ aarch64_vector_costs::count_ops (unsigned
> int count, vect_cost_for_stmt kind,
>        && (kind == vector_stmt || kind == vec_to_scalar))
>      if (tree type = vect_comparison_type (stmt_info))
>        {
> -     unsigned int base = (FLOAT_TYPE_P (type)
> -                          ? sve_issue->fp_cmp_pred_ops
> -                          : sve_issue->int_cmp_pred_ops);
> -     ops->pred_ops += base * count;
> +     auto cmp_ops = (FLOAT_TYPE_P (type)
> +                     ? sve_issue->fp_cmp_ops
> +                     : sve_issue->int_cmp_ops);
> +     ops->general_ops += cmp_ops * count;
> +
> +     auto cmp_pred_ops = (FLOAT_TYPE_P (type)
> +                         ? sve_issue->fp_cmp_pred_ops
> +                         : sve_issue->int_cmp_pred_ops);
> +     ops->pred_ops += cmp_pred_ops * count;
>        }
> 
>    /* Add any extra overhead associated with LD[234] and ST[234] operations.
> */
> diff --git a/gcc/config/aarch64/tuning_models/cortexx925.h
> b/gcc/config/aarch64/tuning_models/cortexx925.h
> index 2a73b36970655..6bdf30f9ee1b8 100644
> --- a/gcc/config/aarch64/tuning_models/cortexx925.h
> +++ b/gcc/config/aarch64/tuning_models/cortexx925.h
> @@ -161,7 +161,9 @@ static const aarch64_sve_vec_issue_info
> cortexx925_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    1, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    0, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    0, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/generic_armv9_a.h
> b/gcc/config/aarch64/tuning_models/generic_armv9_a.h
> index 05e777d20efb3..67fe7db31ba7c 100644
> --- a/gcc/config/aarch64/tuning_models/generic_armv9_a.h
> +++ b/gcc/config/aarch64/tuning_models/generic_armv9_a.h
> @@ -180,7 +180,9 @@ static const aarch64_sve_vec_issue_info
> generic_armv9_a_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    2, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    2, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    1, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/hip12.h
> b/gcc/config/aarch64/tuning_models/hip12.h
> index cfb204b2e5337..e4e64f50d416e 100644
> --- a/gcc/config/aarch64/tuning_models/hip12.h
> +++ b/gcc/config/aarch64/tuning_models/hip12.h
> @@ -159,7 +159,9 @@ static const aarch64_sve_vec_issue_info
> hip12_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    2, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    2, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    1, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoverse512tvb.h
> b/gcc/config/aarch64/tuning_models/neoverse512tvb.h
> index d6e2c2e8120d7..68da9ad25d214 100644
> --- a/gcc/config/aarch64/tuning_models/neoverse512tvb.h
> +++ b/gcc/config/aarch64/tuning_models/neoverse512tvb.h
> @@ -100,7 +100,9 @@ static const aarch64_sve_vec_issue_info
> neoverse512tvb_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    2, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    2, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    1, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoversen2.h
> b/gcc/config/aarch64/tuning_models/neoversen2.h
> index 21597e6b50f83..8bc4b2f095be9 100644
> --- a/gcc/config/aarch64/tuning_models/neoversen2.h
> +++ b/gcc/config/aarch64/tuning_models/neoversen2.h
> @@ -161,7 +161,9 @@ static const aarch64_sve_vec_issue_info
> neoversen2_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    2, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    2, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    1, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoversen3.h
> b/gcc/config/aarch64/tuning_models/neoversen3.h
> index 37f9819148f66..89a868460b0b8 100644
> --- a/gcc/config/aarch64/tuning_models/neoversen3.h
> +++ b/gcc/config/aarch64/tuning_models/neoversen3.h
> @@ -161,7 +161,9 @@ static const aarch64_sve_vec_issue_info
> neoversen3_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    1, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    0, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    0, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoversev1.h
> b/gcc/config/aarch64/tuning_models/neoversev1.h
> index 004676a8dbacf..89f6f938a049d 100644
> --- a/gcc/config/aarch64/tuning_models/neoversev1.h
> +++ b/gcc/config/aarch64/tuning_models/neoversev1.h
> @@ -170,7 +170,9 @@ static const aarch64_sve_vec_issue_info
> neoversev1_sve_issue_info =
>    },
>    1, /* pred_ops_per_cycle  */
>    2, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    2, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    1, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoversev2.h
> b/gcc/config/aarch64/tuning_models/neoversev2.h
> index 734089772517e..27550f6709e12 100644
> --- a/gcc/config/aarch64/tuning_models/neoversev2.h
> +++ b/gcc/config/aarch64/tuning_models/neoversev2.h
> @@ -163,7 +163,9 @@ static const aarch64_sve_vec_issue_info
> neoversev2_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    2, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    2, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    1, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoversev3.h
> b/gcc/config/aarch64/tuning_models/neoversev3.h
> index 7e0144032dc60..c6b8b0a411998 100644
> --- a/gcc/config/aarch64/tuning_models/neoversev3.h
> +++ b/gcc/config/aarch64/tuning_models/neoversev3.h
> @@ -161,7 +161,9 @@ static const aarch64_sve_vec_issue_info
> neoversev3_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    1, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    0, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    0, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/neoversev3ae.h
> b/gcc/config/aarch64/tuning_models/neoversev3ae.h
> index bbe4dc5470152..bc58cda04c3e9 100644
> --- a/gcc/config/aarch64/tuning_models/neoversev3ae.h
> +++ b/gcc/config/aarch64/tuning_models/neoversev3ae.h
> @@ -161,7 +161,9 @@ static const aarch64_sve_vec_issue_info
> neoversev3ae_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    1, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    0, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    0, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> diff --git a/gcc/config/aarch64/tuning_models/olympus.h
> b/gcc/config/aarch64/tuning_models/olympus.h
> index 1e701722e2248..bbb32bbc15a4f 100644
> --- a/gcc/config/aarch64/tuning_models/olympus.h
> +++ b/gcc/config/aarch64/tuning_models/olympus.h
> @@ -132,7 +132,9 @@ static aarch64_sve_vec_issue_info
> olympus_sve_issue_info =
>    },
>    2, /* pred_ops_per_cycle  */
>    1, /* while_pred_ops  */
> +  0, /* int_cmp_ops  */
>    0, /* int_cmp_pred_ops  */
> +  0, /* fp_cmp_ops  */
>    0, /* fp_cmp_pred_ops  */
>    1, /* gather_scatter_pair_general_ops  */
>    1 /* gather_scatter_pair_pred_ops  */
> --
> 2.56.0

Reply via email to