| 1 |
/* Tuning model description for AArch64 architecture. |
| 2 |
Copyright (C) 2009-2025 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_GENERIC_ARMV9_A |
| 21 |
#define GCC_AARCH64_H_GENERIC_ARMV9_A |
| 22 |
|
| 23 |
#include "generic.h" |
| 24 |
#include "generic_armv8_a.h" |
| 25 |
|
| 26 |
static const struct cpu_addrcost_table generic_armv9_a_addrcost_table = |
| 27 |
{ |
| 28 |
{ |
| 29 |
1, /* hi */ |
| 30 |
0, /* si */ |
| 31 |
0, /* di */ |
| 32 |
1, /* ti */ |
| 33 |
}, |
| 34 |
0, /* pre_modify */ |
| 35 |
0, /* post_modify */ |
| 36 |
2, /* post_modify_ld3_st3 */ |
| 37 |
2, /* post_modify_ld4_st4 */ |
| 38 |
0, /* register_offset */ |
| 39 |
0, /* register_sextend */ |
| 40 |
0, /* register_zextend */ |
| 41 |
0 /* imm_offset */ |
| 42 |
}; |
| 43 |
|
| 44 |
static const struct cpu_regmove_cost generic_armv9_a_regmove_cost = |
| 45 |
{ |
| 46 |
1, /* GP2GP */ |
| 47 |
/* Spilling to int<->fp instead of memory is recommended so set |
| 48 |
realistic costs compared to memmov_cost. */ |
| 49 |
3, /* GP2FP */ |
| 50 |
2, /* FP2GP */ |
| 51 |
2 /* FP2FP */ |
| 52 |
}; |
| 53 |
|
| 54 |
static const advsimd_vec_cost generic_armv9_a_advsimd_vector_cost = |
| 55 |
{ |
| 56 |
2, /* int_stmt_cost */ |
| 57 |
2, /* fp_stmt_cost */ |
| 58 |
2, /* ld2_st2_permute_cost */ |
| 59 |
2, /* ld3_st3_permute_cost */ |
| 60 |
3, /* ld4_st4_permute_cost */ |
| 61 |
2, /* permute_cost */ |
| 62 |
4, /* reduc_i8_cost */ |
| 63 |
4, /* reduc_i16_cost */ |
| 64 |
2, /* reduc_i32_cost */ |
| 65 |
2, /* reduc_i64_cost */ |
| 66 |
6, /* reduc_f16_cost */ |
| 67 |
4, /* reduc_f32_cost */ |
| 68 |
2, /* reduc_f64_cost */ |
| 69 |
2, /* store_elt_extra_cost */ |
| 70 |
/* This value is just inherited from the Cortex-A57 table. */ |
| 71 |
8, /* vec_to_scalar_cost */ |
| 72 |
/* This depends very much on what the scalar value is and |
| 73 |
where it comes from. E.g. some constants take two dependent |
| 74 |
instructions or a load, while others might be moved from a GPR. |
| 75 |
4 seems to be a reasonable compromise in practice. */ |
| 76 |
4, /* scalar_to_vec_cost */ |
| 77 |
4, /* align_load_cost */ |
| 78 |
4, /* unalign_load_cost */ |
| 79 |
/* Although stores have a latency of 2 and compete for the |
| 80 |
vector pipes, in practice it's better not to model that. */ |
| 81 |
1, /* unalign_store_cost */ |
| 82 |
1 /* store_cost */ |
| 83 |
}; |
| 84 |
|
| 85 |
static const sve_vec_cost generic_armv9_a_sve_vector_cost = |
| 86 |
{ |
| 87 |
{ |
| 88 |
2, /* int_stmt_cost */ |
| 89 |
2, /* fp_stmt_cost */ |
| 90 |
2, /* ld2_st2_permute_cost */ |
| 91 |
3, /* ld3_st3_permute_cost */ |
| 92 |
3, /* ld4_st4_permute_cost */ |
| 93 |
2, /* permute_cost */ |
| 94 |
/* Theoretically, a reduction involving 15 scalar ADDs could |
| 95 |
complete in ~5 cycles and would have a cost of 15. [SU]ADDV |
| 96 |
completes in 9 cycles, so give it a cost of 15 + 4. */ |
| 97 |
19, /* reduc_i8_cost */ |
| 98 |
/* Likewise for 7 scalar ADDs (~3 cycles) vs. 8: 7 + 5. */ |
| 99 |
12, /* reduc_i16_cost */ |
| 100 |
/* Likewise for 3 scalar ADDs (~2 cycles) vs. 6: 3 + 4. */ |
| 101 |
7, /* reduc_i32_cost */ |
| 102 |
/* Likewise for 1 scalar ADDs (~1 cycles) vs. 4: 1 + 3. */ |
| 103 |
4, /* reduc_i64_cost */ |
| 104 |
/* Theoretically, a reduction involving 7 scalar FADDs could |
| 105 |
complete in ~8 cycles and would have a cost of 14. FADDV |
| 106 |
completes in 8 cycles, so give it a cost of 14 + 0. */ |
| 107 |
14, /* reduc_f16_cost */ |
| 108 |
/* Likewise for 3 scalar FADDs (~4 cycles) vs. 6: 6 + 2. */ |
| 109 |
8, /* reduc_f32_cost */ |
| 110 |
/* Likewise for 1 scalar FADD (~2 cycles) vs. 4: 2 + 2. */ |
| 111 |
4, /* reduc_f64_cost */ |
| 112 |
2, /* store_elt_extra_cost */ |
| 113 |
/* This value is just inherited from the Cortex-A57 table. */ |
| 114 |
8, /* vec_to_scalar_cost */ |
| 115 |
/* See the comment above the Advanced SIMD versions. */ |
| 116 |
4, /* scalar_to_vec_cost */ |
| 117 |
4, /* align_load_cost */ |
| 118 |
4, /* unalign_load_cost */ |
| 119 |
/* Although stores have a latency of 2 and compete for the |
| 120 |
vector pipes, in practice it's better not to model that. */ |
| 121 |
1, /* unalign_store_cost */ |
| 122 |
1 /* store_cost */ |
| 123 |
}, |
| 124 |
3, /* clast_cost */ |
| 125 |
10, /* fadda_f16_cost */ |
| 126 |
6, /* fadda_f32_cost */ |
| 127 |
4, /* fadda_f64_cost */ |
| 128 |
/* A strided Advanced SIMD x64 load would take two parallel FP loads |
| 129 |
(8 cycles) plus an insertion (2 cycles). Assume a 64-bit SVE gather |
| 130 |
is 1 cycle more. The Advanced SIMD version is costed as 2 scalar loads |
| 131 |
(cost 8) and a vec_construct (cost 4). Add a full vector operation |
| 132 |
(cost 2) to that, to avoid the difference being lost in rounding. |
| 133 |
|
| 134 |
There is no easy comparison between a strided Advanced SIMD x32 load |
| 135 |
and an SVE 32-bit gather, but cost an SVE 32-bit gather as 1 vector |
| 136 |
operation more than a 64-bit gather. */ |
| 137 |
14, /* gather_load_x32_cost */ |
| 138 |
12, /* gather_load_x64_cost */ |
| 139 |
42, /* gather_load_x32_init_cost */ |
| 140 |
24, /* gather_load_x64_init_cost */ |
| 141 |
3 /* scatter_store_elt_cost */ |
| 142 |
}; |
| 143 |
|
| 144 |
static const aarch64_scalar_vec_issue_info generic_armv9_a_scalar_issue_info = |
| 145 |
{ |
| 146 |
3, /* loads_stores_per_cycle */ |
| 147 |
2, /* stores_per_cycle */ |
| 148 |
4, /* general_ops_per_cycle */ |
| 149 |
0, /* fp_simd_load_general_ops */ |
| 150 |
1 /* fp_simd_store_general_ops */ |
| 151 |
}; |
| 152 |
|
| 153 |
static const aarch64_advsimd_vec_issue_info generic_armv9_a_advsimd_issue_info = |
| 154 |
{ |
| 155 |
{ |
| 156 |
3, /* loads_stores_per_cycle */ |
| 157 |
2, /* stores_per_cycle */ |
| 158 |
2, /* general_ops_per_cycle */ |
| 159 |
0, /* fp_simd_load_general_ops */ |
| 160 |
1 /* fp_simd_store_general_ops */ |
| 161 |
}, |
| 162 |
2, /* ld2_st2_general_ops */ |
| 163 |
2, /* ld3_st3_general_ops */ |
| 164 |
3 /* ld4_st4_general_ops */ |
| 165 |
}; |
| 166 |
|
| 167 |
static const aarch64_sve_vec_issue_info generic_armv9_a_sve_issue_info = |
| 168 |
{ |
| 169 |
{ |
| 170 |
{ |
| 171 |
3, /* loads_stores_per_cycle */ |
| 172 |
2, /* stores_per_cycle */ |
| 173 |
2, /* general_ops_per_cycle */ |
| 174 |
0, /* fp_simd_load_general_ops */ |
| 175 |
1 /* fp_simd_store_general_ops */ |
| 176 |
}, |
| 177 |
2, /* ld2_st2_general_ops */ |
| 178 |
2, /* ld3_st3_general_ops */ |
| 179 |
3 /* ld4_st4_general_ops */ |
| 180 |
}, |
| 181 |
2, /* pred_ops_per_cycle */ |
| 182 |
2, /* while_pred_ops */ |
| 183 |
2, /* int_cmp_pred_ops */ |
| 184 |
1, /* fp_cmp_pred_ops */ |
| 185 |
1, /* gather_scatter_pair_general_ops */ |
| 186 |
1 /* gather_scatter_pair_pred_ops */ |
| 187 |
}; |
| 188 |
|
| 189 |
static const aarch64_vec_issue_info generic_armv9_a_vec_issue_info = |
| 190 |
{ |
| 191 |
&generic_armv9_a_scalar_issue_info, |
| 192 |
&generic_armv9_a_advsimd_issue_info, |
| 193 |
&generic_armv9_a_sve_issue_info |
| 194 |
}; |
| 195 |
|
| 196 |
/* Generic_armv9_a costs for vector insn classes. */ |
| 197 |
static const struct cpu_vector_cost generic_armv9_a_vector_cost = |
| 198 |
{ |
| 199 |
1, /* scalar_int_stmt_cost */ |
| 200 |
2, /* scalar_fp_stmt_cost */ |
| 201 |
4, /* scalar_load_cost */ |
| 202 |
1, /* scalar_store_cost */ |
| 203 |
1, /* cond_taken_branch_cost */ |
| 204 |
1, /* cond_not_taken_branch_cost */ |
| 205 |
&generic_armv9_a_advsimd_vector_cost, /* advsimd */ |
| 206 |
&generic_armv9_a_sve_vector_cost, /* sve */ |
| 207 |
&generic_armv9_a_vec_issue_info /* issue_info */ |
| 208 |
}; |
| 209 |
|
| 210 |
/* Generic prefetch settings (which disable prefetch). */ |
| 211 |
static const cpu_prefetch_tune generic_armv9a_prefetch_tune = |
| 212 |
{ |
| 213 |
0, /* num_slots */ |
| 214 |
-1, /* l1_cache_size */ |
| 215 |
64, /* l1_cache_line_size */ |
| 216 |
-1, /* l2_cache_size */ |
| 217 |
true, /* prefetch_dynamic_strides */ |
| 218 |
-1, /* minimum_stride */ |
| 219 |
-1 /* default_opt_level */ |
| 220 |
}; |
| 221 |
|
| 222 |
static const struct tune_params generic_armv9_a_tunings = |
| 223 |
{ |
| 224 |
&cortexa76_extra_costs, |
| 225 |
&generic_armv9_a_addrcost_table, |
| 226 |
&generic_armv9_a_regmove_cost, |
| 227 |
&generic_armv9_a_vector_cost, |
| 228 |
&generic_branch_cost, |
| 229 |
&generic_approx_modes, |
| 230 |
SVE_SCALABLE, /* sve_width */ |
| 231 |
{ 4, /* load_int. */ |
| 232 |
1, /* store_int. */ |
| 233 |
6, /* load_fp. */ |
| 234 |
2, /* store_fp. */ |
| 235 |
6, /* load_pred. */ |
| 236 |
1 /* store_pred. */ |
| 237 |
}, /* memmov_cost. */ |
| 238 |
3, /* issue_rate */ |
| 239 |
(AARCH64_FUSE_BASE |
| 240 |
| AARCH64_FUSE_CMP_CSEL |
| 241 |
| AARCH64_FUSE_CMP_CSET), /* fusible_ops */ |
| 242 |
"32:16", /* function_align. */ |
| 243 |
"4", /* jump_align. */ |
| 244 |
"32:16", /* loop_align. */ |
| 245 |
2, /* int_reassoc_width. */ |
| 246 |
4, /* fp_reassoc_width. */ |
| 247 |
2, /* fma_reassoc_width. */ |
| 248 |
2, /* vec_reassoc_width. */ |
| 249 |
2, /* min_div_recip_mul_sf. */ |
| 250 |
2, /* min_div_recip_mul_df. */ |
| 251 |
0, /* max_case_values. */ |
| 252 |
tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ |
| 253 |
(AARCH64_EXTRA_TUNE_BASE |
| 254 |
| AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* tune_flags. */ |
| 255 |
&generic_armv9a_prefetch_tune, |
| 256 |
AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ |
| 257 |
AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ |
| 258 |
}; |
| 259 |
|
| 260 |
#endif /* GCC_AARCH64_H_GENERIC_ARMV9_A. */ |