https://gcc.gnu.org/g:3a08e8b95a4c6b793b50e58b8fb5eaa9308cf5b3

commit r17-6107-g3a08e8b95a4c6b793b50e58b8fb5eaa9308cf5b3
Author: xiezhiheng <[email protected]>
Date:   Wed Nov 4 08:49:34 2026 +0000

    aarch64: Prefer full-vector SVE main loops for hip12
    
    For the assembly of fully-masked WHILELO loops, such as the following:
    
    .L2:
      ld1h    z31.h, p7/z, [x0, x2, lsl 1]
      ld1h    z30.h, p7/z, [x1, x2, lsl 1]
      ...
      whilelo p7.h, w2, w4
      b.any   .L2
    
    When WHILELO computes the predicate register p7, register dependencies
    prevent the load instruction of the next loop iteration from being issued.
    This behavior performs poorly on the hip12 core, and performance
    regressions have been observed on hip12 for general fully-masked WHILELO
    loop cases. Therefore, on the hip12 core, param_vect_partial_vector_usage
    is set to 1 to generate full-vector main loops.
    
    Bootstrapped and tested on aarch64-linux-gnu.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-tuning-flags.def 
(AARCH64_EXTRA_TUNING_OPTION):
            Add PREFER_SVE_FULL_VECTORS tune parameter.
            * config/aarch64/aarch64.cc (aarch64_override_options_internal):
            Set param_vect_partial_vector_usage to 1.
            * config/aarch64/tuning_models/hip12.h: Set tune parameter
            PREFER_SVE_FULL_VECTORS.
    
    Signed-off-by: Zhiheng Xie <[email protected]>

Diff:
---
 gcc/config/aarch64/aarch64-tuning-flags.def | 4 ++++
 gcc/config/aarch64/aarch64.cc               | 8 ++++++++
 gcc/config/aarch64/tuning_models/hip12.h    | 3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def 
b/gcc/config/aarch64/aarch64-tuning-flags.def
index 64a773be34c0..b29189bac728 100644
--- a/gcc/config/aarch64/aarch64-tuning-flags.def
+++ b/gcc/config/aarch64/aarch64-tuning-flags.def
@@ -84,4 +84,8 @@ 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)
 
+/* Enable if the target prefers full-vector main loops rather than
+   fully-masked whilelo loops (i.e. -param=vect-partial-vector-usage=1).  */
+AARCH64_EXTRA_TUNING_OPTION ("prefer_sve_full_vectors", 
PREFER_SVE_FULL_VECTORS)
+
 #undef AARCH64_EXTRA_TUNING_OPTION
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index bd33334b4bdb..263c0afd4abc 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -20474,6 +20474,14 @@ aarch64_override_options_internal (struct gcc_options 
*opts,
       & AARCH64_EXTRA_TUNE_DISPATCH_SCHED)
     gcc_assert (aarch64_tune_params.dispatch_constraints != NULL);
 
+  /* Prefer SVE main loops that operate on full vectors, handling the
+     tail in a separate epilogue rather than with fully-masked WHILELO
+     loops.  */
+  if (aarch64_tune_params.extra_tuning_flags
+      & AARCH64_EXTRA_TUNE_PREFER_SVE_FULL_VECTORS)
+    SET_OPTION_IF_UNSET (opts, opts_set, param_vect_partial_vector_usage,
+                        1);
+
   /* Enable possible unprofitable vectorization.  */
   if (opts->x_flag_aarch64_max_vectorization)
     SET_OPTION_IF_UNSET (opts, opts_set,
diff --git a/gcc/config/aarch64/tuning_models/hip12.h 
b/gcc/config/aarch64/tuning_models/hip12.h
index cfb204b2e533..30d07d990a06 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_PREFER_SVE_FULL_VECTORS),    /* tune_flags.  */
   &generic_armv8_a_prefetch_tune,
   AARCH64_LDP_STP_POLICY_ALWAYS,    /* ldp_policy_model.  */
   AARCH64_LDP_STP_POLICY_ALWAYS,    /* stp_policy_model.  */

Reply via email to