]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Fix ICE in JSON tuning schema with dispatch scheduling and update schema...
authorSoumya AR <soumyaa@nvidia.com>
Tue, 10 Feb 2026 08:58:47 +0000 (08:58 +0000)
committerSoumya AR <soumyaa@nvidia.com>
Thu, 12 Feb 2026 06:09:34 +0000 (11:39 +0530)
This patch fixes the following bugs:

1) For SVE vector costs [sve_vec_cost], the JSON schema did not list the
inherited members from the base structure, only the SVE specific ones. Updated
the schema to include all the members and regenerated the printing/parsing
routines.

2) After dispatch scheduling, if someone uses -fdump-tuning-model with
mcpu=olympus, it will have the flag for dispatch scheduling enabled. Then, if
someone uses that dump against any -mcpu other than Olympus for tuning, it will
ICE as we enable dispatch scheduling but don't provide the data. Updated this
to clear the flag if dispatch_constraints is NULL.

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64-json-schema.h: Include inherited members for
SVE vector costs.
* config/aarch64/aarch64-json-tunings-parser-generated.inc
(parse_vec_costs_sve): Regenerate.
* config/aarch64/aarch64-json-tunings-parser.cc
(aarch64_load_tuning_params_from_json_string): Clear dispatch scheduling
flag if dispatch_constraints is NULL.
* config/aarch64/aarch64-json-tunings-printer-generated.inc
(serialize_vec_costs_sve): Regenerate.

gcc/config/aarch64/aarch64-json-schema.h
gcc/config/aarch64/aarch64-json-tunings-parser-generated.inc
gcc/config/aarch64/aarch64-json-tunings-parser.cc
gcc/config/aarch64/aarch64-json-tunings-printer-generated.inc

index 32fb39300feb0c5a4aa68f6cf524c158de1bcfa1..9b6c5478d1581085cd6d8ecb4266b2206bce5ad8 100644 (file)
@@ -176,6 +176,26 @@ static const char *schema_json = R"json(
        "store_cost": "int"
       },
       "sve": {
+       "int_stmt_cost": "int",
+       "fp_stmt_cost": "int",
+       "ld2_st2_permute_cost": "int",
+       "ld3_st3_permute_cost": "int",
+       "ld4_st4_permute_cost": "int",
+       "permute_cost": "int",
+       "reduc_i8_cost": "int",
+       "reduc_i16_cost": "int",
+       "reduc_i32_cost": "int",
+       "reduc_i64_cost": "int",
+       "reduc_f16_cost": "int",
+       "reduc_f32_cost": "int",
+       "reduc_f64_cost": "int",
+       "store_elt_extra_cost": "int",
+       "vec_to_scalar_cost": "int",
+       "scalar_to_vec_cost": "int",
+       "align_load_cost": "int",
+       "unalign_load_cost": "int",
+       "unalign_store_cost": "int",
+       "store_cost": "int",
        "clast_cost": "int",
        "fadda_f16_cost": "int",
        "fadda_f32_cost": "int",
index 882d8f799755a3d304cb3adf7d8b6b79f6d80443..7943dea6ececb36f48d084bd3f793bd5be2d7a82 100644 (file)
@@ -175,6 +175,26 @@ template <typename T>
 static void
 parse_vec_costs_sve (const json::object *jo, T &sve)
 {
+  PARSE_INTEGER_FIELD (jo, "int_stmt_cost", sve.int_stmt_cost);
+  PARSE_INTEGER_FIELD (jo, "fp_stmt_cost", sve.fp_stmt_cost);
+  PARSE_INTEGER_FIELD (jo, "ld2_st2_permute_cost", sve.ld2_st2_permute_cost);
+  PARSE_INTEGER_FIELD (jo, "ld3_st3_permute_cost", sve.ld3_st3_permute_cost);
+  PARSE_INTEGER_FIELD (jo, "ld4_st4_permute_cost", sve.ld4_st4_permute_cost);
+  PARSE_INTEGER_FIELD (jo, "permute_cost", sve.permute_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_i8_cost", sve.reduc_i8_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_i16_cost", sve.reduc_i16_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_i32_cost", sve.reduc_i32_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_i64_cost", sve.reduc_i64_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_f16_cost", sve.reduc_f16_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_f32_cost", sve.reduc_f32_cost);
+  PARSE_INTEGER_FIELD (jo, "reduc_f64_cost", sve.reduc_f64_cost);
+  PARSE_INTEGER_FIELD (jo, "store_elt_extra_cost", sve.store_elt_extra_cost);
+  PARSE_INTEGER_FIELD (jo, "vec_to_scalar_cost", sve.vec_to_scalar_cost);
+  PARSE_INTEGER_FIELD (jo, "scalar_to_vec_cost", sve.scalar_to_vec_cost);
+  PARSE_INTEGER_FIELD (jo, "align_load_cost", sve.align_load_cost);
+  PARSE_INTEGER_FIELD (jo, "unalign_load_cost", sve.unalign_load_cost);
+  PARSE_INTEGER_FIELD (jo, "unalign_store_cost", sve.unalign_store_cost);
+  PARSE_INTEGER_FIELD (jo, "store_cost", sve.store_cost);
   PARSE_INTEGER_FIELD (jo, "clast_cost", sve.clast_cost);
   PARSE_INTEGER_FIELD (jo, "fadda_f16_cost", sve.fadda_f16_cost);
   PARSE_INTEGER_FIELD (jo, "fadda_f32_cost", sve.fadda_f32_cost);
index 59c745e347ef2b887684abadbc0c11f5d0feb1d7..9b7bdf535c9ba1c23ac349441014f53e3dbdb3de 100644 (file)
@@ -496,6 +496,20 @@ aarch64_load_tuning_params_from_json_string (const char *json_string,
     }
 
   parse_tunings (jo, *tune);
+
+  /* dispatch_constraints are not represented in JSON tunings.  If the JSON
+     sets DISPATCH_SCHED in extra_tuning_flags but the base model does not
+     provide dispatch_constraints, clear the flag to avoid an assertion
+     failure later.  */
+  if ((tune->extra_tuning_flags & AARCH64_EXTRA_TUNE_DISPATCH_SCHED)
+      && tune->dispatch_constraints == nullptr)
+    {
+      warning (0, "JSON tuning enables dispatch scheduling but "
+              "%<dispatch_constraints%> is not available; "
+              "disabling dispatch scheduling");
+      tune->extra_tuning_flags &= ~AARCH64_EXTRA_TUNE_DISPATCH_SCHED;
+    }
+
   return;
 }
 
index 498be96ff33ef5e169882cd5a1cd0071411e6534..e619a39749dd124fbfc915423c84a91f118f9144 100644 (file)
@@ -209,6 +209,26 @@ serialize_vec_costs_sve (const T &sve)
 {
   auto sve_obj = std::make_unique<json::object> ();
 
+  SERIALIZE_INTEGER_FIELD (sve_obj, "int_stmt_cost", sve.int_stmt_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "fp_stmt_cost", sve.fp_stmt_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "ld2_st2_permute_cost", sve.ld2_st2_permute_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "ld3_st3_permute_cost", sve.ld3_st3_permute_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "ld4_st4_permute_cost", sve.ld4_st4_permute_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "permute_cost", sve.permute_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_i8_cost", sve.reduc_i8_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_i16_cost", sve.reduc_i16_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_i32_cost", sve.reduc_i32_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_i64_cost", sve.reduc_i64_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_f16_cost", sve.reduc_f16_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_f32_cost", sve.reduc_f32_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "reduc_f64_cost", sve.reduc_f64_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "store_elt_extra_cost", sve.store_elt_extra_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "vec_to_scalar_cost", sve.vec_to_scalar_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "scalar_to_vec_cost", sve.scalar_to_vec_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "align_load_cost", sve.align_load_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "unalign_load_cost", sve.unalign_load_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "unalign_store_cost", sve.unalign_store_cost);
+  SERIALIZE_INTEGER_FIELD (sve_obj, "store_cost", sve.store_cost);
   SERIALIZE_INTEGER_FIELD (sve_obj, "clast_cost", sve.clast_cost);
   SERIALIZE_INTEGER_FIELD (sve_obj, "fadda_f16_cost", sve.fadda_f16_cost);
   SERIALIZE_INTEGER_FIELD (sve_obj, "fadda_f32_cost", sve.fadda_f32_cost);