]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Un-factor vectorizable_load parts
authorRichard Biener <rguenther@suse.de>
Mon, 28 Jul 2025 13:04:01 +0000 (15:04 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 29 Jul 2025 06:40:07 +0000 (08:40 +0200)
When the costing refactoring happened we ended up with some strange
inter-mixing of VMAT unrelated code.  The following moves stuff
closer to where it's actually used, at the expense of duplicating
some lines.

* tree-vect-stmts.cc (vectorizable_load): Un-factor VMAT
specific code to their handling blocks.

gcc/tree-vect-stmts.cc

index 155330f22434bb166d6ffb7937d4527376957053..4cf6c3b1a6f5552a32161e9f688984e7d0175f3f 100644 (file)
@@ -10200,29 +10200,6 @@ vectorizable_load (vec_info *vinfo,
 
   tree bump;
   tree vec_offset = NULL_TREE;
-  if (STMT_VINFO_GATHER_SCATTER_P (stmt_info))
-    {
-      aggr_type = NULL_TREE;
-      bump = NULL_TREE;
-    }
-  else if (memory_access_type == VMAT_GATHER_SCATTER)
-    {
-      aggr_type = elem_type;
-      if (!costing_p)
-       vect_get_strided_load_store_ops (stmt_info, vectype, loop_vinfo,
-                                        gsi, &gs_info,
-                                        &bump, &vec_offset, loop_lens);
-    }
-  else
-    {
-      if (memory_access_type == VMAT_LOAD_STORE_LANES)
-       aggr_type = build_array_type_nelts (elem_type, group_size * nunits);
-      else
-       aggr_type = vectype;
-      if (!costing_p)
-       bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type,
-                                           memory_access_type, loop_lens);
-    }
 
   auto_vec<tree> vec_offsets;
   auto_vec<tree> vec_masks;
@@ -10237,6 +10214,11 @@ vectorizable_load (vec_info *vinfo,
       gcc_assert (alignment_support_scheme == dr_aligned
                  || alignment_support_scheme == dr_unaligned_supported);
 
+      aggr_type = build_array_type_nelts (elem_type, group_size * nunits);
+      if (!costing_p)
+       bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type,
+                                           memory_access_type, loop_lens);
+
       unsigned int inside_cost = 0, prologue_cost = 0;
       /* For costing some adjacent vector loads, we'd like to cost with
         the total number of them once instead of cost each one by one. */
@@ -10398,20 +10380,31 @@ vectorizable_load (vec_info *vinfo,
     {
       gcc_assert (!grouped_load && !slp_perm);
 
-      unsigned int inside_cost = 0, prologue_cost = 0;
-
       /* 1. Create the vector or array pointer update chain.  */
-      if (!costing_p)
+      if (STMT_VINFO_GATHER_SCATTER_P (stmt_info))
        {
-         if (STMT_VINFO_GATHER_SCATTER_P (stmt_info))
+         aggr_type = NULL_TREE;
+         bump = NULL_TREE;
+         if (!costing_p)
            vect_get_gather_scatter_ops (loop, slp_node, &gs_info, &dataref_ptr,
                                         &vec_offsets);
-         else
-           dataref_ptr
-             = vect_create_data_ref_ptr (vinfo, first_stmt_info, aggr_type,
-                                         at_loop, offset, &dummy, gsi,
-                                         &ptr_incr, false, bump);
        }
+      else
+       {
+         aggr_type = elem_type;
+         if (!costing_p)
+           {
+             vect_get_strided_load_store_ops (stmt_info, vectype, loop_vinfo,
+                                              gsi, &gs_info,
+                                              &bump, &vec_offset, loop_lens);
+             dataref_ptr
+                 = vect_create_data_ref_ptr (vinfo, first_stmt_info, aggr_type,
+                                             at_loop, offset, &dummy, gsi,
+                                             &ptr_incr, false, bump);
+           }
+       }
+
+      unsigned int inside_cost = 0, prologue_cost = 0;
 
       gimple *new_stmt = NULL;
       for (i = 0; i < vec_num; i++)
@@ -10733,6 +10726,11 @@ vectorizable_load (vec_info *vinfo,
       return true;
     }
 
+  aggr_type = vectype;
+  if (!costing_p)
+    bump = vect_get_data_ptr_increment (vinfo, gsi, dr_info, aggr_type,
+                                       memory_access_type, loop_lens);
+
   poly_uint64 group_elt = 0;
   unsigned int inside_cost = 0, prologue_cost = 0;
   /* For costing some adjacent vector loads, we'd like to cost with