From: Robin Dapp <[email protected]>

With the vectorizer now passing vect_gather_load and vect_scatter_store,
the aarch64 code needs a bit of updating, which this patch does.

gcc/ChangeLog:

        * config/aarch64/aarch64.cc (aarch64_detect_vector_stmt_subtype):
        Simplify gather/scatter detection.
        (aarch64_vector_costs::count_ops): Get units from vectype
        instead of count.
        (aarch64_vector_costs::add_stmt_cost): Simplify detection.
---
 gcc/config/aarch64/aarch64.cc | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 6c1229d0a95..4dfb205ee77 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18398,27 +18398,22 @@ aarch64_detect_vector_stmt_subtype (vec_info *vinfo, 
vect_cost_for_stmt kind,
   if (vect_is_store_elt_extraction (kind, stmt_info))
     return simd_costs->store_elt_extra_cost;
 
-  /* Detect SVE gather loads, which are costed as a single scalar_load
-     for each element.  We therefore need to divide the full-instruction
-     cost by the number of elements in the vector.  */
-  if (kind == scalar_load
+  /* Detect SVE gather loads.  */
+  if (kind == vector_gather_load
       && node
-      && sve_costs
-      && mat_gather_scatter_p (SLP_TREE_MEMORY_ACCESS_TYPE (node)))
+      && sve_costs)
     {
-      unsigned int nunits = vect_nunits_for_cost (vectype);
       /* Test for VNx2 modes, which have 64-bit containers.  */
       if (known_eq (GET_MODE_NUNITS (TYPE_MODE (vectype)), aarch64_sve_vg))
-       return { sve_costs->gather_load_x64_cost, nunits };
-      return { sve_costs->gather_load_x32_cost, nunits };
+       return sve_costs->gather_load_x64_cost;
+      return sve_costs->gather_load_x32_cost;
     }
 
   /* Detect cases in which a scalar_store is really storing one element
      in a scatter operation.  */
-  if (kind == scalar_store
+  if (kind == vector_scatter_store
       && node
-      && sve_costs
-      && mat_gather_scatter_p (SLP_TREE_MEMORY_ACCESS_TYPE (node)))
+      && sve_costs)
     return sve_costs->scatter_store_elt_cost;
 
   /* Detect cases in which vec_to_scalar represents an in-loop reduction.  */
@@ -18872,10 +18867,10 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
   /* Add any overhead associated with gather loads and scatter stores.  */
   if (stmt_info
       && sve_issue
-      && (kind == scalar_load || kind == scalar_store)
-      && mat_gather_scatter_p (SLP_TREE_MEMORY_ACCESS_TYPE (node)))
+      && (kind == vector_gather_load || kind == vector_scatter_store))
     {
-      unsigned int pairs = CEIL (count, 2);
+      unsigned int pairs = CEIL (vect_nunits_for_cost
+                                (STMT_VINFO_VECTYPE (stmt_info)), 2);
       ops->pred_ops += sve_issue->gather_scatter_pair_pred_ops * pairs;
       ops->general_ops += sve_issue->gather_scatter_pair_general_ops * pairs;
     }
@@ -19270,11 +19265,10 @@ aarch64_vector_costs::add_stmt_cost (int count, 
vect_cost_for_stmt kind,
                                                        stmt_cost);
 
       /* Check if we've seen an SVE gather/scatter operation and which size.  
*/
-      if (kind == scalar_load
+      if (kind == vector_gather_load
          && node
          && vectype
-         && aarch64_sve_mode_p (TYPE_MODE (vectype))
-         && mat_gather_scatter_p (SLP_TREE_MEMORY_ACCESS_TYPE (node)))
+         && aarch64_sve_mode_p (TYPE_MODE (vectype)))
        {
          const sve_vec_cost *sve_costs = aarch64_tune_params.vec_costs->sve;
          if (sve_costs)
-- 
2.56.0

Reply via email to