On Wed, May 15, 2024, 12:17 PM Wilco Dijkstra <wilco.dijks...@arm.com>
wrote:

> Improve costing of ctz - both TARGET_CSSC and vector cases were not
> handled yet.
>
> Passes regress & bootstrap - OK for commit?
>

I should note popcount has a similar issue which I hope to fix next week.
Popcount cost is used during expand so it is very useful to be slightly
more correct.

Thanks,
Andrew



> gcc:
>         * config/aarch64/aarch64.cc (aarch64_rtx_costs): Improve CTZ
> costing.
>
> ---
>
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index
> fe13c9a0d4863041eb9101882ea57c2094240d16..2a6f76f4008839bf0aa158504430af9b7777971c
> 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -14309,10 +14309,24 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int
> outer ATTRIBUTE_UNUSED,
>        return false;
>
>      case CTZ:
> -      *cost = COSTS_N_INSNS (2);
> -
> -      if (speed)
> -       *cost += extra_cost->alu.clz + extra_cost->alu.rev;
> +      if (VECTOR_MODE_P (mode))
> +       {
> +         *cost = COSTS_N_INSNS (3);
> +         if (speed)
> +           *cost += extra_cost->vect.alu * 3;
> +       }
> +      else if (TARGET_CSSC)
> +       {
> +         *cost = COSTS_N_INSNS (1);
> +         if (speed)
> +           *cost += extra_cost->alu.clz;
> +       }
> +      else
> +       {
> +         *cost = COSTS_N_INSNS (2);
> +         if (speed)
> +           *cost += extra_cost->alu.clz + extra_cost->alu.rev;
> +       }
>        return false;
>
>      case COMPARE:
>
>

Reply via email to