Skip to content

Commit fad08bd

Browse files
committed
aarch64: Add initial tuning model for cortex-a320 core
gcc/ChangeLog: * config/aarch64/aarch64-cores.def (cortex-a320): Update core. * config/aarch64/aarch64.cc: Add cortexa320.h. * config/aarch64/tuning_models/cortexa320.h: New file.
1 parent 6e78326 commit fad08bd

3 files changed

Lines changed: 197 additions & 1 deletion

File tree

gcc/config/aarch64/aarch64-cores.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ AARCH64_CORE("cortex-a720", cortexa720, cortexa57, V9_2A, (SVE2_BITPERM, MEMTA
217217
AARCH64_CORE("cortex-a720ae", cortexa720ae, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen2, 0x41, 0xd89, -1)
218218
AARCH64_CORE("cortex-a725", cortexa725, cortexa57, V9_2A, (SVE2_BITPERM, MEMTAG, PROFILE), neoversen3, 0x41, 0xd87, -1)
219219

220-
AARCH64_CORE("cortex-a320", cortexa320, cortexa53, V9_2A, (SVE2_BITPERM, MEMTAG), cortexa53, 0x41, 0xd8f, -1)
220+
AARCH64_CORE("cortex-a320", cortexa320, cortexa53, V9_2A, (SVE2_BITPERM, MEMTAG), cortexa320, 0x41, 0xd8f, -1)
221221

222222
AARCH64_CORE("cortex-x2", cortexx2, cortexa57, V9A, (SVE2_BITPERM, MEMTAG, I8MM, BF16), neoversen2, 0x41, 0xd48, -1)
223223

gcc/config/aarch64/aarch64.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ static const struct aarch64_flag_desc aarch64_tuning_flags[] =
416416
#include "tuning_models/generic.h"
417417
#include "tuning_models/generic_armv8_a.h"
418418
#include "tuning_models/generic_armv9_a.h"
419+
#include "tuning_models/cortexa320.h"
419420
#include "tuning_models/cortexa35.h"
420421
#include "tuning_models/cortexa53.h"
421422
#include "tuning_models/cortexa57.h"
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
/* Tuning model description for AArch64 architecture.
2+
Copyright (C) 2009-2026 Free Software Foundation, Inc.
3+
4+
This file is part of GCC.
5+
6+
GCC is free software; you can redistribute it and/or modify it
7+
under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 3, or (at your option)
9+
any later version.
10+
11+
GCC is distributed in the hope that it will be useful, but
12+
WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with GCC; see the file COPYING3. If not see
18+
<http://www.gnu.org/licenses/>. */
19+
20+
#ifndef GCC_AARCH64_H_CORTEXA320
21+
#define GCC_AARCH64_H_CORTEXA320
22+
23+
#include "generic.h"
24+
25+
static const struct cpu_addrcost_table cortexa320_addrcost_table =
26+
{
27+
{
28+
1, /* hi */
29+
0, /* si */
30+
0, /* di */
31+
1, /* ti */
32+
},
33+
0, /* pre_modify */
34+
0, /* post_modify */
35+
2, /* post_modify_ld3_st3 */
36+
2, /* post_modify_ld4_st4 */
37+
0, /* register_offset */
38+
0, /* register_sextend */
39+
0, /* register_zextend */
40+
0 /* imm_offset */
41+
};
42+
43+
static const struct cpu_regmove_cost cortexa320_regmove_cost =
44+
{
45+
1, /* GP2GP */
46+
/* Avoid the use of slow int<->fp moves for spilling by setting
47+
their cost higher than memmov_cost. */
48+
5, /* GP2FP */
49+
5, /* FP2GP */
50+
2 /* FP2FP */
51+
};
52+
53+
static const advsimd_vec_cost cortexa320_advsimd_vector_cost =
54+
{
55+
3, /* int_stmt_cost */
56+
4, /* fp_stmt_cost */
57+
1, /* ld2_st2_permute_cost */
58+
2, /* ld3_st3_permute_cost */
59+
3, /* ld4_st4_permute_cost */
60+
3, /* permute_cost */
61+
3, /* reduc_i8_cost */
62+
4, /* reduc_i16_cost */
63+
4, /* reduc_i32_cost */
64+
3, /* reduc_i64_cost */
65+
12, /* reduc_f16_cost */
66+
8, /* reduc_f32_cost */
67+
4, /* reduc_f64_cost */
68+
0, /* store_elt_extra_cost */
69+
/* This value is just inherited from the Cortex-A57 table. */
70+
8, /* vec_to_scalar_cost */
71+
/* This depends very much on what the scalar value is and
72+
where it comes from. E.g. some constants take two dependent
73+
instructions or a load, while others might be moved from a GPR.
74+
4 seems to be a reasonable compromise in practice. */
75+
4, /* scalar_to_vec_cost */
76+
5, /* align_load_cost */
77+
5, /* unalign_load_cost */
78+
/* Although stores have a latency of 2 and compete for the
79+
vector pipes, in practice it's better not to model that. */
80+
2, /* unalign_store_cost */
81+
2 /* store_cost */
82+
};
83+
84+
static const sve_vec_cost cortexa320_sve_vector_cost =
85+
{
86+
{
87+
3, /* int_stmt_cost */
88+
4, /* fp_stmt_cost */
89+
1, /* ld2_st2_permute_cost */
90+
2, /* ld3_st3_permute_cost */
91+
3, /* ld4_st4_permute_cost */
92+
3, /* permute_cost */
93+
/* Theoretically, a reduction involving 15 scalar ADDs could
94+
complete in ~15 cycles and would have a cost of 15. [SU]ADDV
95+
completes in 4 cycles, so give it a cost of 15 + -11. */
96+
4, /* reduc_i8_cost */
97+
/* Likewise for 7 scalar ADDs (~7 cycles) vs. 4: 7 + -3. */
98+
4, /* reduc_i16_cost */
99+
/* Likewise for 3 scalar ADDs (~3 cycles) vs. 4: 3 + 1. */
100+
4, /* reduc_i32_cost */
101+
/* Likewise for 1 scalar ADD (~1 cycles) vs. 4: 1 + 3. */
102+
4, /* reduc_i64_cost */
103+
/* Theoretically, a reduction involving 7 scalar FADDs could
104+
complete in ~28 cycles and would have a cost of 28. FADDV
105+
completes in 12 cycles, so give it a cost of 28 + -16. */
106+
12, /* reduc_f16_cost */
107+
/* Likewise for 3 scalar FADDs (~12 cycles) vs. 8: 12 + -4. */
108+
8, /* reduc_f32_cost */
109+
/* Likewise for 1 scalar FADD (~4 cycles) vs. 4: 4 + 0. */
110+
4, /* reduc_f64_cost */
111+
0, /* store_elt_extra_cost */
112+
/* This value is just inherited from the Cortex-A57 table. */
113+
8, /* vec_to_scalar_cost */
114+
/* See the comment above the Advanced SIMD versions. */
115+
4, /* scalar_to_vec_cost */
116+
5, /* align_load_cost */
117+
5, /* unalign_load_cost */
118+
/* Although stores have a latency of 2 and compete for the
119+
vector pipes, in practice it's better not to model that. */
120+
2, /* unalign_store_cost */
121+
2 /* store_cost */
122+
},
123+
4, /* clast_cost */
124+
25, /* fadda_f16_cost */
125+
9, /* fadda_f32_cost */
126+
3, /* fadda_f64_cost */
127+
/* A strided Advanced SIMD x64 load would take two parallel FP loads
128+
(10 cycles) plus an insertion (3 cycles). Assume a 64-bit SVE gather
129+
is 1 cycle more. The Advanced SIMD version is costed as 2 scalar loads
130+
(cost 10) and a vec_construct (cost 3). Add a full vector operation
131+
(cost 3) to that, to avoid the difference being lost in rounding.
132+
133+
There is no easy comparison between a strided Advanced SIMD x32 load
134+
and an SVE 32-bit gather, but cost an SVE 32-bit gather as 1 vector
135+
operation more than a 64-bit gather. */
136+
16, /* gather_load_x32_cost */
137+
19, /* gather_load_x64_cost */
138+
48, /* gather_load_x32_init_cost */
139+
38, /* gather_load_x64_init_cost */
140+
0 /* scatter_store_elt_cost */
141+
};
142+
143+
/* Cortexa320 costs for vector insn classes. */
144+
static const struct cpu_vector_cost cortexa320_vector_cost =
145+
{
146+
1, /* scalar_int_stmt_cost */
147+
2, /* scalar_fp_stmt_cost */
148+
4, /* scalar_load_cost */
149+
1, /* scalar_store_cost */
150+
1, /* cond_taken_branch_cost */
151+
1, /* cond_not_taken_branch_cost */
152+
&cortexa320_advsimd_vector_cost, /* advsimd */
153+
&cortexa320_sve_vector_cost, /* sve */
154+
nullptr /* issue_info */
155+
};
156+
157+
static const struct tune_params cortexa320_tunings =
158+
{
159+
&cortexa76_extra_costs,
160+
&cortexa320_addrcost_table,
161+
&cortexa320_regmove_cost,
162+
&cortexa320_vector_cost,
163+
&generic_branch_cost,
164+
&generic_approx_modes,
165+
SVE_128, /* sve_width */
166+
{ 4, /* load_int. */
167+
1, /* store_int. */
168+
5, /* load_fp. */
169+
2, /* store_fp. */
170+
4, /* load_pred. */
171+
1 /* store_pred. */
172+
}, /* memmov_cost. */
173+
1, /* issue_rate */
174+
AARCH64_FUSE_NEOVERSE_BASE, /* fusible_ops */
175+
"32:16", /* function_align. */
176+
"4", /* jump_align. */
177+
"32:16", /* loop_align. */
178+
2, /* int_reassoc_width. */
179+
4, /* fp_reassoc_width. */
180+
1, /* fma_reassoc_width. */
181+
2, /* vec_reassoc_width. */
182+
2, /* min_div_recip_mul_sf. */
183+
2, /* min_div_recip_mul_df. */
184+
0, /* max_case_values. */
185+
tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */
186+
(AARCH64_EXTRA_TUNE_CHEAP_SHIFT_EXTEND
187+
| AARCH64_EXTRA_TUNE_CSE_SVE_VL_CONSTANTS
188+
| AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* tune_flags. */
189+
&generic_armv9a_prefetch_tune,
190+
AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */
191+
AARCH64_LDP_STP_POLICY_ALWAYS, /* stp_policy_model. */
192+
nullptr /* dispatch_constraints. */
193+
};
194+
195+
#endif /* GCC_AARCH64_H_CORTEXA320. */

0 commit comments

Comments
 (0)