> -----Original Message-----
> From: xiezhiheng <[email protected]>
> Sent: 30 October 2026 03:48
> To: Tamar Christina <[email protected]>; [email protected]
> Cc: Kyrylo Tkachov <[email protected]>; [email protected]
> Subject: RE: [PATCH 2/2] sched: Return delta when the pressure is below the
> peak pressure
> 
> > -----Original Message-----
> > From: Tamar Christina <[email protected]>
> > Sent: Thursday, October 29, 2026 10:09 PM
> > To: xiezhiheng <[email protected]>; [email protected]
> > Cc: Kyrylo Tkachov <[email protected]>; [email protected]
> > Subject: RE: [PATCH 2/2] sched: Return delta when the pressure is below the
> peak pressure
> >
> > > -----Original Message-----
> > > From: xiezhiheng <[email protected]>
> > > Sent: 29 October 2026 03:40
> > > To: [email protected]
> > > Cc: Kyrylo Tkachov <[email protected]>; Tamar Christina
> > > <[email protected]>; [email protected]
> > > Subject: [PATCH 2/2] sched: Return delta when the pressure is below the
> peak
> > > pressure
> > >
> > > After applying the hip12 scheduling model, 507.cactuBSSN_r shows a
> ~12%
> > > performance regression. The reason is the same as the issue described in
> > > PR/114729, but that patch cannot fix this problem.
> > >
> > > I have enhanced this as follows: in model_excess_group_cost, originally
> > > the pressure increase was returned only when the pressure exceeded the
> > > peak pressure; now the delta is also returned when the pressure is below
> > > the peak pressure, in order to reduce spills. The change is controlled by
> > > the --param=cycle-accurate-model= option.
> > >
> > > As discussed in PR/114729, the "model" heuristic currently used by default
> > > on AArch64 is pretty old. However, the cortex-a57 scheduling model used
> > > by many AArch64 cores is also fairly old, so perhaps the default behavior
> > > of the scheduling algorithm is well matched to cortex-a57. Therefore,
> > > I only enable cycle-accurate-model=0 by default for the more modern
> hip12
> > > scheduling model.
> > >
> > > On hip12, the actually executed instructions are as follows, (-O3 -
> > > mcpu=native)
> > >
> > >   Original:                      1,207,015,685,661      instructions:u
> > >   Apply hip12 scheduling model:  1,522,907,774,690      instructions:u
> > >   Apply this patch:              1,278,756,677,944      instructions:u
> > >
> > > gcc/ChangeLog:
> > >
> > >   * config/aarch64/aarch64.cc (aarch64_override_options_internal):
> > >   Set cycle-accurate-model to 0 for hip12.
> > >   * haifa-sched.cc (model_excess_group_cost): Return delta if
> > >   param_cycle_accurate_model is 0.
> > >
> > > Signed-off-by: Zhiheng Xie <[email protected]>
> > > ---
> > >  gcc/config/aarch64/aarch64.cc | 5 +++++
> > >  gcc/haifa-sched.cc            | 4 ++++
> > >  2 files changed, 9 insertions(+)
> > >
> > > diff --git a/gcc/config/aarch64/aarch64.cc
> b/gcc/config/aarch64/aarch64.cc
> > > index 9290677655a..561516a3c79 100644
> > > --- a/gcc/config/aarch64/aarch64.cc
> > > +++ b/gcc/config/aarch64/aarch64.cc
> > > @@ -20323,6 +20323,11 @@ aarch64_override_options_internal (struct
> > > gcc_options *opts,
> > >                  param_sched_pressure_algorithm,
> > >                  SCHED_PRESSURE_MODEL);
> > >
> > > +  if (tune->tune == &hip12_tunings)
> > > +    SET_OPTION_IF_UNSET (opts, opts_set,
> > > +                  param_cycle_accurate_model,
> > > +                  0);
> >
> > Please make this a tune parameter and add it to the cost model instead.
> > See aarch64-tuning-flags.def
> >
> > This would also better allow us to experiment in the other cost models.
> >
> 
> Here is the patch v2. Bootstrapped and tested on aarch64-linux-gnu.
> 
> 
> After applying the hip12 scheduling model, 507.cactuBSSN_r shows a ~12%
> performance regression. The reason is the same as the issue described in
> PR/114729, but that patch cannot fix this problem.
> 
> I have enhanced this as follows: in model_excess_group_cost, originally
> the pressure increase was returned only when the pressure exceeded the
> peak pressure; now the delta is also returned when the pressure is below
> the peak pressure, in order to reduce spills. The change is controlled by
> the --param=cycle-accurate-model= option.
> 
> As discussed in PR/114729, the "model" heuristic currently used by default
> on AArch64 is pretty old. However, the cortex-a57 scheduling model used
> by many AArch64 cores is also fairly old, so perhaps the default behavior
> of the scheduling algorithm is well matched to cortex-a57. Therefore,
> I add an additional DISABLE_CYCLE_ACCURATE_MODEL tune parameter to
> control
> the behavior.
> 
> On hip12, the actually executed instructions on 507.cactuBSSN_r are
> as follows, (w/ option -O3 -mcpu=native)
> 
>   Original:                      1,207,015,685,661      instructions:u
>   Apply hip12 scheduling model:  1,522,907,774,690      instructions:u
>   Apply this patch:              1,278,756,677,944      instructions:u
> 
> gcc/ChangeLog:
> 
>       * config/aarch64/aarch64-tuning-flags.def
> (AARCH64_EXTRA_TUNING_OPTION):
>       Add DISABLE_CYCLE_ACCURATE_MODEL tune parameter.
>       * config/aarch64/aarch64.cc (aarch64_override_options_internal):
>       Set param_cycle_accurate_model to 0.
>       * config/aarch64/tuning_models/hip12.h: Set tune parameter
>       DISABLE_CYCLE_ACCURATE_MODEL.
>       * haifa-sched.cc (model_excess_group_cost): Return delta if
>       param_cycle_accurate_model is 0.
> 
> Signed-off-by: Zhiheng Xie <[email protected]>
> ---
>  gcc/config/aarch64/aarch64-tuning-flags.def | 3 +++
>  gcc/config/aarch64/aarch64.cc               | 6 ++++++
>  gcc/config/aarch64/tuning_models/hip12.h    | 3 ++-
>  gcc/haifa-sched.cc                          | 4 ++++
>  4 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def
> b/gcc/config/aarch64/aarch64-tuning-flags.def
> index 64a773be34c..f756cae4edd 100644
> --- a/gcc/config/aarch64/aarch64-tuning-flags.def
> +++ b/gcc/config/aarch64/aarch64-tuning-flags.def
> @@ -84,4 +84,7 @@ AARCH64_EXTRA_TUNING_OPTION
> ("narrow_gp_writes", NARROW_GP_WRITES)
>  /* Enable when the target prefers SVE merging movimm over zeroing.  */
>  AARCH64_EXTRA_TUNING_OPTION ("avoid_zeroing_movimm",
> AVOID_MOVIMM_Z)
> 
> +/* Set param_cycle_accurate_model to 0 for the target.  */
> +AARCH64_EXTRA_TUNING_OPTION ("disable-cycle-accurate-model",
> DISABLE_CYCLE_ACCURATE_MODEL)
> +

Minor nit, can you make this DISABLE_CYCLE_ACCURATE_SCHED_MODEL?
So it's not confused with the latency modelling in the vectorizer.

Patch is OK with that change.  But I can't approve the middle-end bit.

Once middle-end maintainer does I can apply the updated patch for you.

Thanks,
Tamar

>  #undef AARCH64_EXTRA_TUNING_OPTION
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index 9290677655a..b9f5df82f45 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -20323,6 +20323,12 @@ aarch64_override_options_internal (struct
> gcc_options *opts,
>                      param_sched_pressure_algorithm,
>                      SCHED_PRESSURE_MODEL);
> 
> +  if (aarch64_tune_params.extra_tuning_flags
> +      & AARCH64_EXTRA_TUNE_DISABLE_CYCLE_ACCURATE_MODEL)
> +    SET_OPTION_IF_UNSET (opts, opts_set,
> +                      param_cycle_accurate_model,
> +                      0);
> +
>    /* Validate the guard size.  */
>    int guard_size = param_stack_clash_protection_guard_size;
> 
> diff --git a/gcc/config/aarch64/tuning_models/hip12.h
> b/gcc/config/aarch64/tuning_models/hip12.h
> index cfb204b2e53..39b5462926e 100644
> --- a/gcc/config/aarch64/tuning_models/hip12.h
> +++ b/gcc/config/aarch64/tuning_models/hip12.h
> @@ -217,7 +217,8 @@ static const struct tune_params hip12_tunings =
>    0,    /* max_case_values.  */
>    tune_params::AUTOPREFETCHER_WEAK,    /* autoprefetcher_model.  */
>    (AARCH64_EXTRA_TUNE_BASE
> -   | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT),    /*
> tune_flags.  */
> +   | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT
> +   | AARCH64_EXTRA_TUNE_DISABLE_CYCLE_ACCURATE_MODEL),    /*
> tune_flags.  */
>    &generic_armv8_a_prefetch_tune,
>    AARCH64_LDP_STP_POLICY_ALWAYS,    /* ldp_policy_model.  */
>    AARCH64_LDP_STP_POLICY_ALWAYS,    /* stp_policy_model.  */
> diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc
> index e0505e9db64..51b47764d25 100644
> --- a/gcc/haifa-sched.cc
> +++ b/gcc/haifa-sched.cc
> @@ -2428,6 +2428,10 @@ model_excess_group_cost (struct
> model_pressure_group *group,
>        if (pressure > group->limits[pci].pressure)
>       return model_spill_cost (cl, group->limits[pci].orig_pressure,
>                                pressure);
> +      /* If target prefers fewer spills, return the +ve delta indicating
> +      pressure increase.  */
> +      else if (!param_cycle_accurate_model)
> +     return delta;
>      }
> 
>    return 0;
> --
> 2.43.0
> 
> 
> > Thanks,
> > Tamar
> >
> > > +
> > >    /* Validate the guard size.  */
> > >    int guard_size = param_stack_clash_protection_guard_size;
> > >
> > > diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc
> > > index e0505e9db64..51b47764d25 100644
> > > --- a/gcc/haifa-sched.cc
> > > +++ b/gcc/haifa-sched.cc
> > > @@ -2428,6 +2428,10 @@ model_excess_group_cost (struct
> > > model_pressure_group *group,
> > >        if (pressure > group->limits[pci].pressure)
> > >   return model_spill_cost (cl, group->limits[pci].orig_pressure,
> > >                            pressure);
> > > +      /* If target prefers fewer spills, return the +ve delta indicating
> > > +  pressure increase.  */
> > > +      else if (!param_cycle_accurate_model)
> > > + return delta;
> > >      }
> > >
> > >    return 0;
> > > --
> > > 2.43.0
> >

Reply via email to