aarch64: increase SVE structural memop costs for Neoverse-V2+

Message ID 20261008163139.274892-1-artemiy.volkov@arm.com
State New
Delegated to: Tamar Christina
Headers
Series aarch64: increase SVE structural memop costs for Neoverse-V2+ |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed

Commit Message

Artemiy Volkov Oct. 8, 2026, 4:31 p.m. UTC
  After r17-4605-g38370907dce41b which rectified costing for non-uniform
loads, the vectorizer started to prefer some SVE epilogues to AdvSIMD
ones, and this has led to performance degradations when ld4w/st4w's
are involved (see also the related change in r17-2685-gad8686f649cfec).
Reflect the fact that SVE structured loads have higher latency and much
lower throughput than AdvSIMD ones (11 vs 8 and 1/9 vs 1 for 4-component
structs on Neoverse-V2, according to [0]) by adjusting corresponding
fields in relevant tuning models.

This fully recovers the 736.ocio_r numbers (+9.8%).

Bootstrapped and regtested on aarch64-linux-gnu.

[0] https://support.arm.com/documentation/109898/0300/

gcc/ChangeLog:

        * config/aarch64/tuning_models/neoversev2.h: Increase SVE structural
	  load/store costs.
        * config/aarch64/tuning_models/neoversev3.h: Likewise.
        * config/aarch64/tuning_models/neoversev3ae.h: Likewise.
---
 gcc/config/aarch64/tuning_models/neoversev2.h   | 6 +++---
 gcc/config/aarch64/tuning_models/neoversev3.h   | 6 +++---
 gcc/config/aarch64/tuning_models/neoversev3ae.h | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
  

Comments

Wilco Dijkstra Oct. 22, 2026, 4:44 p.m. UTC | #1
Hi Artemiy,

> After r17-4605-g38370907dce41b which rectified costing for non-uniform
> loads, the vectorizer started to prefer some SVE epilogues to AdvSIMD
> ones, and this has led to performance degradations when ld4w/st4w's
> are involved (see also the related change in r17-2685-gad8686f649cfec).
> Reflect the fact that SVE structured loads have higher latency and much
> lower throughput than AdvSIMD ones (11 vs 8 and 1/9 vs 1 for 4-component
> structs on Neoverse-V2, according to [0]) by adjusting corresponding
> fields in relevant tuning models.
>
> This fully recovers the 736.ocio_r numbers (+9.8%).

LGTM, OK.

Cheers,
Wilco
  
Tamar Christina Oct. 22, 2026, 6:10 p.m. UTC | #2
> -----Original Message-----
> From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
> Sent: 22 October 2026 17:45
> To: Artemiy Volkov <Artemiy.Volkov@arm.com>; gcc-patches@gcc.gnu.org
> Cc: Tamar Christina <Tamar.Christina@arm.com>; Richard Earnshaw
> <Richard.Earnshaw@arm.com>
> Subject: Re: [PATCH] aarch64: increase SVE structural memop costs for
> Neoverse-V2+
> 
> Hi Artemiy,
> 
> > After r17-4605-g38370907dce41b which rectified costing for non-uniform
> > loads, the vectorizer started to prefer some SVE epilogues to AdvSIMD
> > ones, and this has led to performance degradations when ld4w/st4w's
> > are involved (see also the related change in r17-2685-gad8686f649cfec).
> > Reflect the fact that SVE structured loads have higher latency and much
> > lower throughput than AdvSIMD ones (11 vs 8 and 1/9 vs 1 for 4-
> component
> > structs on Neoverse-V2, according to [0]) by adjusting corresponding
> > fields in relevant tuning models.
> >
> > This fully recovers the 736.ocio_r numbers (+9.8%).
> 
> LGTM, OK.

No, this isn't right.  The cost as the field says measures the difference in
*permute* costs of LDn instructions. It is not the latency of the LDn instruction
but instead measures the additional costs of a LD1 vs the LDn.

This because the vectorizer is asking us to make a choice between Load lanes
and load + permute.   So these numbers will increase the costs of LDn immensely
to a value that's not reflected in the SWoG.


You have something else going wrong here.

Thanks,
Tamar
> 
> Cheers,
> Wilco
  
Tamar Christina Oct. 22, 2026, 6:15 p.m. UTC | #3
> -----Original Message-----
> From: Tamar Christina <Tamar.Christina@arm.com>
> Sent: 22 October 2026 19:11
> To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>; Artemiy Volkov
> <Artemiy.Volkov@arm.com>; gcc-patches@gcc.gnu.org
> Cc: Richard Earnshaw <Richard.Earnshaw@arm.com>
> Subject: RE: [PATCH] aarch64: increase SVE structural memop costs for
> Neoverse-V2+
> 
> 
> 
> > -----Original Message-----
> > From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
> > Sent: 22 October 2026 17:45
> > To: Artemiy Volkov <Artemiy.Volkov@arm.com>; gcc-patches@gcc.gnu.org
> > Cc: Tamar Christina <Tamar.Christina@arm.com>; Richard Earnshaw
> > <Richard.Earnshaw@arm.com>
> > Subject: Re: [PATCH] aarch64: increase SVE structural memop costs for
> > Neoverse-V2+
> >
> > Hi Artemiy,
> >
> > > After r17-4605-g38370907dce41b which rectified costing for non-uniform
> > > loads, the vectorizer started to prefer some SVE epilogues to AdvSIMD
> > > ones, and this has led to performance degradations when ld4w/st4w's
> > > are involved (see also the related change in r17-2685-gad8686f649cfec).
> > > Reflect the fact that SVE structured loads have higher latency and much
> > > lower throughput than AdvSIMD ones (11 vs 8 and 1/9 vs 1 for 4-
> > component
> > > structs on Neoverse-V2, according to [0]) by adjusting corresponding
> > > fields in relevant tuning models.
> > >
> > > This fully recovers the 736.ocio_r numbers (+9.8%).
> >
> > LGTM, OK.
> 
> No, this isn't right.  The cost as the field says measures the difference in
> *permute* costs of LDn instructions. It is not the latency of the LDn instruction
> but instead measures the additional costs of a LD1 vs the LDn.
> 
> This because the vectorizer is asking us to make a choice between Load lanes
> and load + permute.   So these numbers will increase the costs of LDn
> immensely
> to a value that's not reflected in the SWoG.
> 
> 
> You have something else going wrong here.

You are likely hitting that the way *throughput* is calculated needs an update, there
is an inconsistency in how we cost load_lanes and load_lanes with gaps.

But due to a disagreement with Richard S on the calculations it hasn't been updated yet [1]

[1] https://patchwork.ozlabs.org/project/gcc/patch/patch-20510-tamar@arm.com/#3687409

But the latency costs in the cost structures are correct.

Thanks,
Tamar

> 
> Thanks,
> Tamar
> >
> > Cheers,
> > Wilco
  

Patch

diff --git a/gcc/config/aarch64/tuning_models/neoversev2.h b/gcc/config/aarch64/tuning_models/neoversev2.h
index 73408977251..b70f5c787c1 100644
--- a/gcc/config/aarch64/tuning_models/neoversev2.h
+++ b/gcc/config/aarch64/tuning_models/neoversev2.h
@@ -70,9 +70,9 @@  static const sve_vec_cost neoversev2_sve_vector_cost =
   {
     2, /* int_stmt_cost  */
     2, /* fp_stmt_cost  */
-    3, /* ld2_st2_permute_cost  */
-    4, /* ld3_st3_permute_cost  */
-    4, /* ld4_st4_permute_cost  */
+    8, /* ld2_st2_permute_cost  */
+    11, /* ld3_st3_permute_cost  */
+    15, /* ld4_st4_permute_cost  */
     2, /* permute_cost  */
     /* Theoretically, a reduction involving 15 scalar ADDs could
        complete in ~5 cycles and would have a cost of 15.  [SU]ADDV
diff --git a/gcc/config/aarch64/tuning_models/neoversev3.h b/gcc/config/aarch64/tuning_models/neoversev3.h
index 7e0144032dc..d86d269aeee 100644
--- a/gcc/config/aarch64/tuning_models/neoversev3.h
+++ b/gcc/config/aarch64/tuning_models/neoversev3.h
@@ -68,9 +68,9 @@  static const sve_vec_cost neoversev3_sve_vector_cost =
   {
     2, /* int_stmt_cost  */
     2, /* fp_stmt_cost  */
-    2, /* ld2_st2_permute_cost  */
-    3, /* ld3_st3_permute_cost  */
-    3, /* ld4_st4_permute_cost  */
+    8, /* ld2_st2_permute_cost  */
+    11, /* ld3_st3_permute_cost  */
+    15, /* ld4_st4_permute_cost  */
     2, /* permute_cost  */
     /* Theoretically, a reduction involving 15 scalar ADDs could
        complete in ~4 cycles and would have a cost of 15.  [SU]ADDV
diff --git a/gcc/config/aarch64/tuning_models/neoversev3ae.h b/gcc/config/aarch64/tuning_models/neoversev3ae.h
index bbe4dc54701..cbb2927f045 100644
--- a/gcc/config/aarch64/tuning_models/neoversev3ae.h
+++ b/gcc/config/aarch64/tuning_models/neoversev3ae.h
@@ -68,9 +68,9 @@  static const sve_vec_cost neoversev3ae_sve_vector_cost =
   {
     2, /* int_stmt_cost  */
     2, /* fp_stmt_cost  */
-    2, /* ld2_st2_permute_cost  */
-    3, /* ld3_st3_permute_cost  */
-    3, /* ld4_st4_permute_cost  */
+    8, /* ld2_st2_permute_cost  */
+    11, /* ld3_st3_permute_cost  */
+    15, /* ld4_st4_permute_cost  */
     2, /* permute_cost  */
     /* Theoretically, a reduction involving 15 scalar ADDs could
        complete in ~4 cycles and would have a cost of 15.  [SU]ADDV