[PATCH v2 09/13] vect: aarch64: Add hssr_read value to vect_cost_for_stmt.
Alfie Richards <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
This also adds some extremely basic initial cost values.
gcc/ChangeLog:
* config/aarch64/aarch64-protos.h (struct sve_vec_cost):
Add member sve_vec_cost and its initialization.
* config/aarch64/aarch64.cc (aarch64_builtin_vectorization_cost):
Add case hssr_read.
(aarch64_vector_costs::count_ops):
Add case for count_ops.
* config/aarch64/tuning_models/a64fx.h:
Add value for read_hssr_cost.
* config/aarch64/tuning_models/cortexa320.h: Likewise.
* config/aarch64/tuning_models/cortexx925.h: Likewise.
* config/aarch64/tuning_models/generic.h: Likewise.
* config/aarch64/tuning_models/generic_armv8_a.h: Likewise.
* config/aarch64/tuning_models/generic_armv9_a.h: Likewise.
* config/aarch64/tuning_models/hip12.h: Likewise.
* config/aarch64/tuning_models/neoverse512tvb.h: Likewise.
* config/aarch64/tuning_models/neoversen2.h: Likewise.
* config/aarch64/tuning_models/neoversen3.h: Likewise.
* config/aarch64/tuning_models/neoversev1.h: Likewise.
* config/aarch64/tuning_models/neoversev2.h: Likewise.
* config/aarch64/tuning_models/neoversev3.h: Likewise.
* config/aarch64/tuning_models/neoversev3ae.h: Likewise.
* config/aarch64/tuning_models/olympus.h: Likewise.
* target.h (enum vect_cost_for_stmt): Add hssr_read.
* targhooks.cc (default_builtin_vectorization_cost): Add case for
hssr_read.
* tree-vectorizer.cc (dump_stmt_cost): Add case for hssr_read.
---
gcc/config/aarch64/aarch64-protos.h | 10 ++++++++--
gcc/config/aarch64/aarch64.cc | 12 ++++++++++++
gcc/config/aarch64/tuning_models/a64fx.h | 3 ++-
gcc/config/aarch64/tuning_models/cortexa320.h | 3 ++-
gcc/config/aarch64/tuning_models/cortexx925.h | 3 ++-
gcc/config/aarch64/tuning_models/generic.h | 3 ++-
gcc/config/aarch64/tuning_models/generic_armv8_a.h | 3 ++-
gcc/config/aarch64/tuning_models/generic_armv9_a.h | 3 ++-
gcc/config/aarch64/tuning_models/hip12.h | 3 ++-
gcc/config/aarch64/tuning_models/neoverse512tvb.h | 3 ++-
gcc/config/aarch64/tuning_models/neoversen2.h | 3 ++-
gcc/config/aarch64/tuning_models/neoversen3.h | 3 ++-
gcc/config/aarch64/tuning_models/neoversev1.h | 3 ++-
gcc/config/aarch64/tuning_models/neoversev2.h | 3 ++-
gcc/config/aarch64/tuning_models/neoversev3.h | 3 ++-
gcc/config/aarch64/tuning_models/neoversev3ae.h | 3 ++-
gcc/config/aarch64/tuning_models/olympus.h | 3 ++-
gcc/target.h | 7 ++++++-
gcc/targhooks.cc | 3 +++
gcc/tree-vectorizer.cc | 3 +++
20 files changed, 62 insertions(+), 18 deletions(-)
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index bcc833cfaa1..89008aa1115 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -266,7 +266,9 @@ struct sve_vec_cost : simd_vec_cost
unsigned int gather_load_x64_cost,
unsigned int gather_load_x32_init_cost,
unsigned int gather_load_x64_init_cost,
- unsigned int scatter_store_elt_cost)
+ unsigned int scatter_store_elt_cost,
+ unsigned int read_hssr_cost
+ )
: simd_vec_cost (base),
clast_cost (clast_cost),
fadda_f16_cost (fadda_f16_cost),
@@ -276,7 +278,8 @@ struct sve_vec_cost : simd_vec_cost
gather_load_x64_cost (gather_load_x64_cost),
gather_load_x32_init_cost (gather_load_x32_init_cost),
gather_load_x64_init_cost (gather_load_x64_init_cost),
- scatter_store_elt_cost (scatter_store_elt_cost)
+ scatter_store_elt_cost (scatter_store_elt_cost),
+ read_hssr_cost (read_hssr_cost)
{}
/* The cost of a vector-to-scalar CLASTA or CLASTB instruction,
@@ -303,6 +306,9 @@ struct sve_vec_cost : simd_vec_cost
/* The per-element cost of a scatter store. */
int scatter_store_elt_cost;
+
+ /* Cost of an rdffrs. */
+ int read_hssr_cost;
};
/* Base information about how the CPU issues code, containing
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index e7522e49efd..dd5e6cdb838 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18000,6 +18000,17 @@ aarch64_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
elements = estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype));
return elements / 2 + 1;
+ case hssr_read:
+ {
+ const sve_vec_cost *sve_costs = aarch64_tune_params.vec_costs->sve;
+ /* We need SVE to have HSSR so we surely will have sve costs defined
+ too. */
+ gcc_assert (sve_costs);
+
+ /* This will be a rdffr + b.nlast. */
+ return sve_costs->read_hssr_cost + costs->cond_not_taken_branch_cost;
+ }
+
default:
gcc_unreachable ();
}
@@ -18629,6 +18640,7 @@ aarch64_vector_costs::count_ops (unsigned int count, vect_cost_for_stmt kind,
case scalar_to_vec:
case vector_stmt:
case scalar_stmt:
+ case hssr_read:
ops->general_ops += count;
break;
diff --git a/gcc/config/aarch64/tuning_models/a64fx.h b/gcc/config/aarch64/tuning_models/a64fx.h
index c3222960f17..e2db16b33e4 100644
--- a/gcc/config/aarch64/tuning_models/a64fx.h
+++ b/gcc/config/aarch64/tuning_models/a64fx.h
@@ -106,7 +106,8 @@ static const sve_vec_cost a64fx_sve_vector_cost =
32, /* gather_load_x64_cost */
0, /* gather_load_x32_init_cost */
0, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const struct cpu_vector_cost a64fx_vector_cost =
diff --git a/gcc/config/aarch64/tuning_models/cortexa320.h b/gcc/config/aarch64/tuning_models/cortexa320.h
index d5e1f2b2993..78122b03339 100644
--- a/gcc/config/aarch64/tuning_models/cortexa320.h
+++ b/gcc/config/aarch64/tuning_models/cortexa320.h
@@ -137,7 +137,8 @@ static const sve_vec_cost cortexa320_sve_vector_cost =
19, /* gather_load_x64_cost */
48, /* gather_load_x32_init_cost */
38, /* gather_load_x64_init_cost */
- 0 /* scatter_store_elt_cost */
+ 0, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
/* Cortexa320 costs for vector insn classes. */
diff --git a/gcc/config/aarch64/tuning_models/cortexx925.h b/gcc/config/aarch64/tuning_models/cortexx925.h
index 2a73b369706..cd15bd560e0 100644
--- a/gcc/config/aarch64/tuning_models/cortexx925.h
+++ b/gcc/config/aarch64/tuning_models/cortexx925.h
@@ -119,7 +119,8 @@ static const sve_vec_cost cortexx925_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info cortexx925_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/generic.h b/gcc/config/aarch64/tuning_models/generic.h
index af013e478d4..dafbd066bc9 100644
--- a/gcc/config/aarch64/tuning_models/generic.h
+++ b/gcc/config/aarch64/tuning_models/generic.h
@@ -107,7 +107,8 @@ static const sve_vec_cost generic_sve_vector_cost =
2, /* gather_load_x64_cost */
0, /* gather_load_x32_init_cost */
0, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
/* Generic costs for vector insn classes. */
diff --git a/gcc/config/aarch64/tuning_models/generic_armv8_a.h b/gcc/config/aarch64/tuning_models/generic_armv8_a.h
index 29cf3a5a7c7..61082df3b16 100644
--- a/gcc/config/aarch64/tuning_models/generic_armv8_a.h
+++ b/gcc/config/aarch64/tuning_models/generic_armv8_a.h
@@ -108,7 +108,8 @@ static const sve_vec_cost generic_armv8_a_sve_vector_cost =
2, /* gather_load_x64_cost */
12, /* gather_load_x32_init_cost */
4, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
/* Generic costs for vector insn classes. */
diff --git a/gcc/config/aarch64/tuning_models/generic_armv9_a.h b/gcc/config/aarch64/tuning_models/generic_armv9_a.h
index 05e777d20ef..d1e453b7e54 100644
--- a/gcc/config/aarch64/tuning_models/generic_armv9_a.h
+++ b/gcc/config/aarch64/tuning_models/generic_armv9_a.h
@@ -138,7 +138,8 @@ static const sve_vec_cost generic_armv9_a_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 3 /* scatter_store_elt_cost */
+ 3, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info generic_armv9_a_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/hip12.h b/gcc/config/aarch64/tuning_models/hip12.h
index cfb204b2e53..cdb589af23e 100644
--- a/gcc/config/aarch64/tuning_models/hip12.h
+++ b/gcc/config/aarch64/tuning_models/hip12.h
@@ -117,7 +117,8 @@ static const sve_vec_cost hip12_sve_vector_cost =
16, /* gather_load_x64_cost */
96, /* gather_load_x32_init_cost */
32, /* gather_load_x64_init_cost */
- 3 /* scatter_store_elt_cost */
+ 3, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info hip12_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoverse512tvb.h b/gcc/config/aarch64/tuning_models/neoverse512tvb.h
index d6e2c2e8120..82d0a7a208f 100644
--- a/gcc/config/aarch64/tuning_models/neoverse512tvb.h
+++ b/gcc/config/aarch64/tuning_models/neoverse512tvb.h
@@ -81,7 +81,8 @@ static const sve_vec_cost neoverse512tvb_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 3 /* scatter_store_elt_cost */
+ 3, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_sve_vec_issue_info neoverse512tvb_sve_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoversen2.h b/gcc/config/aarch64/tuning_models/neoversen2.h
index 21597e6b50f..033709405ed 100644
--- a/gcc/config/aarch64/tuning_models/neoversen2.h
+++ b/gcc/config/aarch64/tuning_models/neoversen2.h
@@ -119,7 +119,8 @@ static const sve_vec_cost neoversen2_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 3 /* scatter_store_elt_cost */
+ 3, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info neoversen2_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoversen3.h b/gcc/config/aarch64/tuning_models/neoversen3.h
index 37f9819148f..1ba709f820a 100644
--- a/gcc/config/aarch64/tuning_models/neoversen3.h
+++ b/gcc/config/aarch64/tuning_models/neoversen3.h
@@ -119,7 +119,8 @@ static const sve_vec_cost neoversen3_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info neoversen3_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoversev1.h b/gcc/config/aarch64/tuning_models/neoversev1.h
index 253f11e87a6..cde25124ed3 100644
--- a/gcc/config/aarch64/tuning_models/neoversev1.h
+++ b/gcc/config/aarch64/tuning_models/neoversev1.h
@@ -128,7 +128,8 @@ static const sve_vec_cost neoversev1_sve_vector_cost =
16, /* gather_load_x64_cost */
96, /* gather_load_x32_init_cost */
32, /* gather_load_x64_init_cost */
- 3 /* scatter_store_elt_cost */
+ 3, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info neoversev1_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoversev2.h b/gcc/config/aarch64/tuning_models/neoversev2.h
index 6df0cc444b8..82ad1594a95 100644
--- a/gcc/config/aarch64/tuning_models/neoversev2.h
+++ b/gcc/config/aarch64/tuning_models/neoversev2.h
@@ -121,7 +121,8 @@ static const sve_vec_cost neoversev2_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 3 /* scatter_store_elt_cost */
+ 3, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info neoversev2_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoversev3.h b/gcc/config/aarch64/tuning_models/neoversev3.h
index 7e0144032dc..c969101564b 100644
--- a/gcc/config/aarch64/tuning_models/neoversev3.h
+++ b/gcc/config/aarch64/tuning_models/neoversev3.h
@@ -119,7 +119,8 @@ static const sve_vec_cost neoversev3_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info neoversev3_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/neoversev3ae.h b/gcc/config/aarch64/tuning_models/neoversev3ae.h
index bbe4dc54701..1583033c8a0 100644
--- a/gcc/config/aarch64/tuning_models/neoversev3ae.h
+++ b/gcc/config/aarch64/tuning_models/neoversev3ae.h
@@ -119,7 +119,8 @@ static const sve_vec_cost neoversev3ae_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static const aarch64_scalar_vec_issue_info neoversev3ae_scalar_issue_info =
diff --git a/gcc/config/aarch64/tuning_models/olympus.h b/gcc/config/aarch64/tuning_models/olympus.h
index 1e701722e22..3f71402a0ac 100644
--- a/gcc/config/aarch64/tuning_models/olympus.h
+++ b/gcc/config/aarch64/tuning_models/olympus.h
@@ -90,7 +90,8 @@ static sve_vec_cost olympus_sve_vector_cost =
12, /* gather_load_x64_cost */
42, /* gather_load_x32_init_cost */
24, /* gather_load_x64_init_cost */
- 1 /* scatter_store_elt_cost */
+ 1, /* scatter_store_elt_cost */
+ 5 /* read_hssr_cost */
};
static aarch64_scalar_vec_issue_info olympus_scalar_issue_info =
diff --git a/gcc/target.h b/gcc/target.h
index 67b04f90f45..8d13846095d 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -213,7 +213,12 @@ enum vect_cost_for_stmt
vec_perm,
vec_promote_demote,
vec_construct,
- vec_deconstruct
+ vec_deconstruct,
+ /* Represents the costs of reading the HSSR state, detecting if a partial
+ read occurred, and the possible branch to fixup code.
+
+ Does not cost the fixup code itself. */
+ hssr_read
};
/* Separate locations for which the vectorizer cost model should
diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
index 388f696c8aa..2f9db33ef80 100644
--- a/gcc/targhooks.cc
+++ b/gcc/targhooks.cc
@@ -776,6 +776,9 @@ default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
case cond_branch_taken:
return 3;
+ case hssr_read:
+ return 4;
+
case vec_construct:
case vec_deconstruct:
return estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype)) - 1;
diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc
index 8c824e4ee33..398edbd7ecc 100644
--- a/gcc/tree-vectorizer.cc
+++ b/gcc/tree-vectorizer.cc
@@ -172,6 +172,9 @@ dump_stmt_cost (FILE *f, int count, enum vect_cost_for_stmt kind,
case vec_deconstruct:
ks = "vec_deconstruct";
break;
+ case hssr_read:
+ ks = "hssr_read";
+ break;
}
fprintf (f, "%s ", ks);
if (kind == unaligned_load || kind == unaligned_store)
--
2.43.0