]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add checks for node in aarch64 vector cost modeling
authorRichard Biener <rguenther@suse.de>
Thu, 31 Jul 2025 11:23:09 +0000 (13:23 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 31 Jul 2025 11:33:17 +0000 (13:33 +0200)
After removing STMT_VINFO_MEMORY_ACCESS_TYPE we now ICE when costing
for scalar stmts required in the epilog since the cost model tries
to pattern-match gathers (an earlier patch tried to improve this
by introducing stmt groups, but that was on hold due to negative
feedback).  The following shot-cuts those attempts when node is NULL
as that then cannot be a vector stmt.  Another possibility would be
to gate on vect_body, or restructure everything.

Note we now ensure that when m_costing_for_scalar node is NULL.

* config/aarch64/aarch64.cc (aarch64_detect_vector_stmt_subtype):
Check for node before dereferencing.
(aarch64_vector_costs::add_stmt_cost): Likewise.

gcc/config/aarch64/aarch64.cc

index a761addc06cba5fec6ac24675a42d561cf8b1b2f..ed37824b6a2465fc49f826fd385fa783e2b8346a 100644 (file)
@@ -17465,6 +17465,7 @@ aarch64_detect_vector_stmt_subtype (vec_info *vinfo, vect_cost_for_stmt kind,
      for each element.  We therefore need to divide the full-instruction
      cost by the number of elements in the vector.  */
   if (kind == scalar_load
+      && node
       && sve_costs
       && SLP_TREE_MEMORY_ACCESS_TYPE (node) == VMAT_GATHER_SCATTER)
     {
@@ -17478,6 +17479,7 @@ aarch64_detect_vector_stmt_subtype (vec_info *vinfo, vect_cost_for_stmt kind,
   /* Detect cases in which a scalar_store is really storing one element
      in a scatter operation.  */
   if (kind == scalar_store
+      && node
       && sve_costs
       && SLP_TREE_MEMORY_ACCESS_TYPE (node) == VMAT_GATHER_SCATTER)
     return sve_costs->scatter_store_elt_cost;
@@ -18005,7 +18007,7 @@ aarch64_vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind,
 
       /* Check if we've seen an SVE gather/scatter operation and which size.  */
       if (kind == scalar_load
-         && !m_costing_for_scalar
+         && node
          && vectype
          && aarch64_sve_mode_p (TYPE_MODE (vectype))
          && SLP_TREE_MEMORY_ACCESS_TYPE (node) == VMAT_GATHER_SCATTER)