Prepare removal of SLP_INSTANCE_GROUP_SIZE
authorRichard Biener <rguenther@suse.de>
Wed, 6 May 2020 11:20:38 +0000 (13:20 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 6 May 2020 13:30:14 +0000 (15:30 +0200)
This removes trivial instances of SLP_INSTANCE_GROUP_SIZE and refrains
from using a "SLP instance" which nowadays is just one of the possibly
many entries into the SLP graph.

2020-05-06  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (vect_transform_slp_perm_load): Adjust.
* tree-vect-data-refs.c (vect_slp_analyze_node_dependences):
Remove slp_instance parameter, just iterate over all scalar stmts.
(vect_slp_analyze_instance_dependence): Adjust and likewise.
* tree-vect-slp.c (vect_bb_slp_scalar_cost): Remove unused BB
parameter.
(vect_schedule_slp): Just iterate over all scalar stmts.
(vect_supported_load_permutation_p): Adjust.
(vect_transform_slp_perm_load): Remove slp_instance parameter,
instead use the number of lanes in the node as group size.
* tree-vect-stmts.c (vect_model_load_cost): Get vectorization
factor instead of slp_instance as parameter.
(vectorizable_load): Adjust.

gcc/ChangeLog
gcc/tree-vect-data-refs.c
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index 0adda498ccb886a345a2d486e535b9b050d03697..9e5a434a231e27f65dda18812370edf6e4af4f2d 100644 (file)
@@ -1,3 +1,19 @@
+2020-05-06  Richard Biener  <rguenther@suse.de>
+
+       * tree-vectorizer.h (vect_transform_slp_perm_load): Adjust.
+       * tree-vect-data-refs.c (vect_slp_analyze_node_dependences):
+       Remove slp_instance parameter, just iterate over all scalar stmts.
+       (vect_slp_analyze_instance_dependence): Adjust and likewise.
+       * tree-vect-slp.c (vect_bb_slp_scalar_cost): Remove unused BB
+       parameter.
+       (vect_schedule_slp): Just iterate over all scalar stmts.
+       (vect_supported_load_permutation_p): Adjust.
+       (vect_transform_slp_perm_load): Remove slp_instance parameter,
+       instead use the number of lanes in the node as group size.
+       * tree-vect-stmts.c (vect_model_load_cost): Get vectorization
+       factor instead of slp_instance as parameter.
+       (vectorizable_load): Adjust.
+
 2020-05-06  Andreas Schwab  <schwab@suse.de>
 
        * config/aarch64/driver-aarch64.c: Include "aarch64-protos.h".
index 7e9ab3ec3332fbdb447efdec7f4b72763cefde2f..d41ba49fabfe17a8abf573f139705ed364174b94 100644 (file)
@@ -695,8 +695,7 @@ vect_slp_analyze_data_ref_dependence (vec_info *vinfo,
    disambiguating the loads.  */
 
 static bool
-vect_slp_analyze_node_dependences (vec_info *vinfo,
-                                  slp_instance instance, slp_tree node,
+vect_slp_analyze_node_dependences (vec_info *vinfo, slp_tree node,
                                   vec<stmt_vec_info> stores,
                                   stmt_vec_info last_store_info)
 {
@@ -704,7 +703,7 @@ vect_slp_analyze_node_dependences (vec_info *vinfo,
      in NODE verifying we can sink them up to the last stmt in the
      group.  */
   stmt_vec_info last_access_info = vect_find_last_scalar_stmt_in_slp (node);
-  for (unsigned k = 0; k < SLP_INSTANCE_GROUP_SIZE (instance); ++k)
+  for (unsigned k = 0; k < SLP_TREE_SCALAR_STMTS (node).length (); ++k)
     {
       stmt_vec_info access_info = SLP_TREE_SCALAR_STMTS (node)[k];
       if (access_info == last_access_info)
@@ -794,13 +793,12 @@ vect_slp_analyze_instance_dependence (vec_info *vinfo, slp_instance instance)
   stmt_vec_info last_store_info = NULL;
   if (store)
     {
-      if (! vect_slp_analyze_node_dependences (vinfo, instance, store,
-                                              vNULL, NULL))
+      if (! vect_slp_analyze_node_dependences (vinfo, store, vNULL, NULL))
        return false;
 
       /* Mark stores in this instance and remember the last one.  */
       last_store_info = vect_find_last_scalar_stmt_in_slp (store);
-      for (unsigned k = 0; k < SLP_INSTANCE_GROUP_SIZE (instance); ++k)
+      for (unsigned k = 0; k < SLP_TREE_SCALAR_STMTS (store).length (); ++k)
        gimple_set_visited (SLP_TREE_SCALAR_STMTS (store)[k]->stmt, true);
     }
 
@@ -811,7 +809,7 @@ vect_slp_analyze_instance_dependence (vec_info *vinfo, slp_instance instance)
   slp_tree load;
   unsigned int i;
   FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (instance), i, load)
-    if (! vect_slp_analyze_node_dependences (vinfo, instance, load,
+    if (! vect_slp_analyze_node_dependences (vinfo, load,
                                             store
                                             ? SLP_TREE_SCALAR_STMTS (store)
                                             : vNULL, last_store_info))
@@ -822,7 +820,7 @@ vect_slp_analyze_instance_dependence (vec_info *vinfo, slp_instance instance)
 
   /* Unset the visited flag.  */
   if (store)
-    for (unsigned k = 0; k < SLP_INSTANCE_GROUP_SIZE (instance); ++k)
+    for (unsigned k = 0; k < SLP_TREE_SCALAR_STMTS (store).length (); ++k)
       gimple_set_visited (SLP_TREE_SCALAR_STMTS (store)[k]->stmt, false);
 
   return res;
index f83b568dcc11f19e0e357da3965a3194614b8e0d..c097840b09ab73a09a8db89cd3d59a14fa1b4f7d 100644 (file)
@@ -2018,7 +2018,7 @@ vect_supported_load_permutation_p (vec_info *vinfo, slp_instance slp_instn)
              vec<tree> tem;
              unsigned n_perms;
              if (!vect_transform_slp_perm_load (vinfo, node, tem, NULL,
-                                                1, slp_instn, true, &n_perms))
+                                                1, true, &n_perms))
                {
                  if (dump_enabled_p ())
                    dump_printf_loc (MSG_MISSED_OPTIMIZATION,
@@ -2044,7 +2044,7 @@ vect_supported_load_permutation_p (vec_info *vinfo, slp_instance slp_instn)
   FOR_EACH_VEC_ELT (SLP_INSTANCE_LOADS (slp_instn), i, node)
     if (node->load_permutation.exists ()
        && !vect_transform_slp_perm_load (vinfo, node, vNULL, NULL, test_vf,
-                                         slp_instn, true, &n_perms))
+                                         true, &n_perms))
       return false;
 
   return true;
@@ -2930,7 +2930,7 @@ vect_slp_analyze_operations (vec_info *vinfo)
    update LIFE according to uses of NODE.  */
 
 static void 
-vect_bb_slp_scalar_cost (vec_info *vinfo, basic_block bb,
+vect_bb_slp_scalar_cost (vec_info *vinfo,
                         slp_tree node, vec<bool, va_heap> *life,
                         stmt_vector_for_cost *cost_vec,
                         hash_set<slp_tree> &visited)
@@ -3002,7 +3002,7 @@ vect_bb_slp_scalar_cost (vec_info *vinfo, basic_block bb,
          /* Do not directly pass LIFE to the recursive call, copy it to
             confine changes in the callee to the current child/subtree.  */
          subtree_life.safe_splice (*life);
-         vect_bb_slp_scalar_cost (vinfo, bb, child, &subtree_life, cost_vec,
+         vect_bb_slp_scalar_cost (vinfo, child, &subtree_life, cost_vec,
                                   visited);
          subtree_life.truncate (0);
        }
@@ -3028,7 +3028,7 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
     {
       auto_vec<bool, 20> life;
       life.safe_grow_cleared (SLP_INSTANCE_GROUP_SIZE (instance));
-      vect_bb_slp_scalar_cost (bb_vinfo, BB_VINFO_BB (bb_vinfo),
+      vect_bb_slp_scalar_cost (bb_vinfo,
                               SLP_INSTANCE_TREE (instance),
                               &life, &scalar_costs, visited);
     }
@@ -3866,13 +3866,12 @@ bool
 vect_transform_slp_perm_load (vec_info *vinfo,
                              slp_tree node, vec<tree> dr_chain,
                              gimple_stmt_iterator *gsi, poly_uint64 vf,
-                             slp_instance slp_node_instance, bool analyze_only,
-                             unsigned *n_perms)
+                             bool analyze_only, unsigned *n_perms)
 {
   stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0];
   int vec_index = 0;
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);
-  unsigned int group_size = SLP_INSTANCE_GROUP_SIZE (slp_node_instance);
+  unsigned int group_size = SLP_TREE_SCALAR_STMTS (node).length ();
   unsigned int mask_element;
   machine_mode mode;
 
@@ -4351,8 +4350,7 @@ vect_schedule_slp (vec_info *vinfo)
       if (is_a <loop_vec_info> (vinfo))
        vect_remove_slp_scalar_calls (vinfo, root);
 
-      for (j = 0; SLP_TREE_SCALAR_STMTS (root).iterate (j, &store_info)
-                  && j < SLP_INSTANCE_GROUP_SIZE (instance); j++)
+      for (j = 0; SLP_TREE_SCALAR_STMTS (root).iterate (j, &store_info); j++)
         {
          if (!STMT_VINFO_DATA_REF (store_info))
            break;
index c41c7e3eb9b3a1fe1ebe3ad07635b1f9c66e5cbf..38285871de63ca1db5b10fdf7b2e3e2d7f4e5da6 100644 (file)
@@ -1174,9 +1174,8 @@ vect_get_store_cost (vec_info *vinfo, stmt_vec_info stmt_info, int ncopies,
 
 static void
 vect_model_load_cost (vec_info *vinfo,
-                     stmt_vec_info stmt_info, unsigned ncopies,
+                     stmt_vec_info stmt_info, unsigned ncopies, poly_uint64 vf,
                      vect_memory_access_type memory_access_type,
-                     slp_instance instance,
                      slp_tree slp_node,
                      stmt_vector_for_cost *cost_vec)
 {
@@ -1198,10 +1197,8 @@ vect_model_load_cost (vec_info *vinfo,
       unsigned n_perms;
       unsigned assumed_nunits
        = vect_nunits_for_cost (STMT_VINFO_VECTYPE (first_stmt_info));
-      unsigned slp_vf = (ncopies * assumed_nunits) / instance->group_size; 
       vect_transform_slp_perm_load (vinfo, slp_node, vNULL, NULL,
-                                   slp_vf, instance, true,
-                                   &n_perms);
+                                   vf, true, &n_perms);
       inside_cost += record_stmt_cost (cost_vec, n_perms, vec_perm,
                                       first_stmt_info, 0, vect_body);
       /* And adjust the number of loads performed.  This handles
@@ -8839,8 +8836,8 @@ vectorizable_load (vec_info *vinfo,
                                  memory_access_type, &gs_info, mask);
 
       STMT_VINFO_TYPE (stmt_info) = load_vec_info_type;
-      vect_model_load_cost (vinfo, stmt_info, ncopies, memory_access_type,
-                           slp_node_instance, slp_node, cost_vec);
+      vect_model_load_cost (vinfo, stmt_info, ncopies, vf, memory_access_type,
+                           slp_node, cost_vec);
       return true;
     }
 
@@ -9137,7 +9134,7 @@ vectorizable_load (vec_info *vinfo,
        {
          unsigned n_perms;
          vect_transform_slp_perm_load (vinfo, slp_node, dr_chain, gsi, vf,
-                                       slp_node_instance, false, &n_perms);
+                                       false, &n_perms);
        }
       return true;
     }
@@ -9896,8 +9893,7 @@ vectorizable_load (vec_info *vinfo,
         {
          unsigned n_perms;
           if (!vect_transform_slp_perm_load (vinfo, slp_node, dr_chain, gsi, vf,
-                                             slp_node_instance, false,
-                                            &n_perms))
+                                            false, &n_perms))
             {
               dr_chain.release ();
               return false;
index a47ba1a6742a52424fcfe8b630efa2173fc882dc..da6d37ac199feef6e6b6df7be92dabc1fae4da9f 100644 (file)
@@ -1852,7 +1852,7 @@ extern tree cse_and_gimplify_to_preheader (loop_vec_info, tree);
 extern void vect_free_slp_instance (slp_instance, bool);
 extern bool vect_transform_slp_perm_load (vec_info *, slp_tree, vec<tree>,
                                          gimple_stmt_iterator *, poly_uint64,
-                                         slp_instance, bool, unsigned *);
+                                         bool, unsigned *);
 extern bool vect_slp_analyze_operations (vec_info *);
 extern void vect_schedule_slp (vec_info *);
 extern opt_result vect_analyze_slp (vec_info *, unsigned);