tree-vectorizer.h (struct vec_info): Add stmt_vec_infos member.
authorRichard Biener <rguenther@suse.de>
Tue, 29 May 2018 11:49:44 +0000 (11:49 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 29 May 2018 11:49:44 +0000 (11:49 +0000)
2018-05-29  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (struct vec_info): Add stmt_vec_infos
member.
(stmt_vec_info_vec): Make pointer.
(init_stmt_vec_info_vec): Remove.
(free_stmt_vec_info_vec): Likewise.
(set_stmt_vec_info_vec): New function.
(free_stmt_vec_infos): Likewise.
(vinfo_for_stmt): Adjust for stmt_vec_info_vec indirection.
(set_vinfo_for_stmt): Likewise.
(get_earlier_stmt): Likewise.
(get_later_stmt): Likewise.
* tree-vectorizer.c (stmt_vec_info_vec): Make pointer.
(vec_info::vec_info): Allocate stmt_vec_infos and set the global.
(vec_info::~vec_info): Free stmt_vec_infos.
(vectorize_loops): Set the global stmt_vec_info_vec to NULL.
Remove old init_stmt_vec_info_vec/free_stmt_vec_info_vec calls.
(pass_slp_vectorize::execute): Likewise.
* tree-vect-stmts.c (init_stmt_vec_info_vec): Remove.
(free_stmt_vec_info_vec): Likewise.
(set_stmt_vec_info_vec): New function.
(free_stmt_vec_infos): Likewise.
* tree-vect-loop.c (_loop_vec_info::~_loop_vec_info): Set
the global stmt_vec_info_vec.
* tree-parloops.c (gather_scalar_reductions): Use
set_stmt_vec_info_vec/free_stmt_vec_infos and maintain a local
vector.

From-SVN: r260892

gcc/ChangeLog
gcc/tree-parloops.c
gcc/tree-vect-loop.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.c
gcc/tree-vectorizer.h

index f5c2cc16667e52a05d5730ead815c75b7effdff6..d2d02b2e0d1a5ba7d09ac5b7701d76ddb6913d72 100644 (file)
@@ -1,3 +1,32 @@
+2018-05-29  Richard Biener  <rguenther@suse.de>
+
+       * tree-vectorizer.h (struct vec_info): Add stmt_vec_infos
+       member.
+       (stmt_vec_info_vec): Make pointer.
+       (init_stmt_vec_info_vec): Remove.
+       (free_stmt_vec_info_vec): Likewise.
+       (set_stmt_vec_info_vec): New function.
+       (free_stmt_vec_infos): Likewise.
+       (vinfo_for_stmt): Adjust for stmt_vec_info_vec indirection.
+       (set_vinfo_for_stmt): Likewise.
+       (get_earlier_stmt): Likewise.
+       (get_later_stmt): Likewise.
+       * tree-vectorizer.c (stmt_vec_info_vec): Make pointer.
+       (vec_info::vec_info): Allocate stmt_vec_infos and set the global.
+       (vec_info::~vec_info): Free stmt_vec_infos.
+       (vectorize_loops): Set the global stmt_vec_info_vec to NULL.
+       Remove old init_stmt_vec_info_vec/free_stmt_vec_info_vec calls.
+       (pass_slp_vectorize::execute): Likewise.
+       * tree-vect-stmts.c (init_stmt_vec_info_vec): Remove.
+       (free_stmt_vec_info_vec): Likewise.
+       (set_stmt_vec_info_vec): New function.
+       (free_stmt_vec_infos): Likewise.
+       * tree-vect-loop.c (_loop_vec_info::~_loop_vec_info): Set
+       the global stmt_vec_info_vec.
+       * tree-parloops.c (gather_scalar_reductions): Use
+       set_stmt_vec_info_vec/free_stmt_vec_infos and maintain a local
+       vector.
+
 2018-05-29  Richard Biener  <rguenther@suse.de>
 
        * dominance.c (iterate_fix_dominators): Push/pop TV_DOMINANCE.
index 3a788ccf1b74083b07e0e6347870bde1ccddb444..aa74427296ed295465a951a2be14c863388787bb 100644 (file)
@@ -2593,8 +2593,9 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
   auto_vec<gphi *, 4> double_reduc_phis;
   auto_vec<gimple *, 4> double_reduc_stmts;
 
-  if (!stmt_vec_info_vec.exists ())
-    init_stmt_vec_info_vec ();
+  vec<stmt_vec_info> stmt_vec_infos;
+  stmt_vec_infos.create (50);
+  set_stmt_vec_info_vec (&stmt_vec_infos);
 
   simple_loop_info = vect_analyze_loop_form (loop);
   if (simple_loop_info == NULL)
@@ -2674,7 +2675,7 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
 
  gather_done:
   /* Release the claim on gimple_uid.  */
-  free_stmt_vec_info_vec ();
+  free_stmt_vec_infos (&stmt_vec_infos);
 
   if (reduction_list->elements () == 0)
     return;
index c49e1c55102d4293fae4f31cf8b00efb333aa3a4..9424b52a99bd5007b3fe6f1bc6c9d9d2e56ea4b5 100644 (file)
@@ -894,6 +894,8 @@ _loop_vec_info::~_loop_vec_info ()
   gimple_stmt_iterator si;
   int j;
 
+  /* ???  We're releasing loop_vinfos en-block.  */
+  set_stmt_vec_info_vec (&stmt_vec_infos);
   nbbs = loop->num_nodes;
   for (j = 0; j < nbbs; j++)
     {
index 66c78de8e2ace3da4c81dc87b91fd78ead5ed306..759ea23b6f2121f7f52fd76652a5f740feaee97d 100644 (file)
@@ -9862,28 +9862,27 @@ new_stmt_vec_info (gimple *stmt, vec_info *vinfo)
 }
 
 
-/* Create a hash table for stmt_vec_info. */
+/* Set the current stmt_vec_info vector to V.  */
 
 void
-init_stmt_vec_info_vec (void)
+set_stmt_vec_info_vec (vec<stmt_vec_info> *v)
 {
-  gcc_assert (!stmt_vec_info_vec.exists ());
-  stmt_vec_info_vec.create (50);
+  stmt_vec_info_vec = v;
 }
 
-
-/* Free hash table for stmt_vec_info. */
+/* Free the stmt_vec_info entries in V and release V.  */
 
 void
-free_stmt_vec_info_vec (void)
+free_stmt_vec_infos (vec<stmt_vec_info> *v)
 {
   unsigned int i;
   stmt_vec_info info;
-  FOR_EACH_VEC_ELT (stmt_vec_info_vec, i, info)
+  FOR_EACH_VEC_ELT (*v, i, info)
     if (info != NULL)
       free_stmt_vec_info (STMT_VINFO_STMT (info));
-  gcc_assert (stmt_vec_info_vec.exists ());
-  stmt_vec_info_vec.release ();
+  if (v == stmt_vec_info_vec)
+    stmt_vec_info_vec = NULL;
+  v->release ();
 }
 
 
index 86cd025fe7398c2bc934a1dc5e7a4ea89c6a76c5..8ff90b37ee65f452294431ae4ccc10e742f04916 100644 (file)
@@ -85,7 +85,7 @@ along with GCC; see the file COPYING3.  If not see
 source_location vect_location;
 
 /* Vector mapping GIMPLE stmt to stmt_vec_info. */
-vec<stmt_vec_info> stmt_vec_info_vec;
+vec<stmt_vec_info> *stmt_vec_info_vec;
 
 /* Dump a cost entry according to args to F.  */
 
@@ -456,6 +456,8 @@ vec_info::vec_info (vec_info::vec_kind kind_in, void *target_cost_data_in)
     ddrs (vNULL),
     target_cost_data (target_cost_data_in)
 {
+  stmt_vec_infos.create (50);
+  set_stmt_vec_info_vec (&stmt_vec_infos);
 }
 
 vec_info::~vec_info ()
@@ -477,6 +479,7 @@ vec_info::~vec_info ()
   free_data_refs (datarefs);
   free_dependence_relations (ddrs);
   destroy_cost_data (target_cost_data);
+  free_stmt_vec_infos (&stmt_vec_infos);
 }
 
 /* A helper function to free scev and LOOP niter information, as well as
@@ -682,7 +685,7 @@ vectorize_loops (void)
   if (cfun->has_simduid_loops)
     note_simd_array_uses (&simd_array_to_simduid_htab);
 
-  init_stmt_vec_info_vec ();
+  set_stmt_vec_info_vec (NULL);
 
   /*  ----------- Analyze loops. -----------  */
 
@@ -923,8 +926,6 @@ vectorize_loops (void)
       loop->aux = NULL;
     }
 
-  free_stmt_vec_info_vec ();
-
   /* Fold IFN_GOMP_SIMD_{VF,LANE,LAST_LANE,ORDERED_{START,END}} builtins.  */
   if (cfun->has_simduid_loops)
     adjust_simduid_builtins (simduid_to_vf_htab);
@@ -1062,8 +1063,6 @@ pass_slp_vectorize::execute (function *fun)
        }
     }
 
-  init_stmt_vec_info_vec ();
-
   FOR_EACH_BB_FN (bb, fun)
     {
       if (vect_slp_bb (bb))
@@ -1071,8 +1070,6 @@ pass_slp_vectorize::execute (function *fun)
                         "basic block vectorized\n");
     }
 
-  free_stmt_vec_info_vec ();
-
   if (!in_loop_pipeline)
     {
       scev_finalize ();
index ef8b69512179b2f26e99dfedb9bca1a360dd6d12..f7646349b65b6590f459d8ed02e3bcddffbb2ac6 100644 (file)
@@ -197,6 +197,9 @@ struct vec_info {
   /* The type of vectorization.  */
   vec_kind kind;
 
+  /* The mapping of GIMPLE UID to stmt_vec_info.  */
+  vec<struct _stmt_vec_info *> stmt_vec_infos;
+
   /* All SLP instances.  */
   auto_vec<slp_instance> slp_instances;
 
@@ -1009,10 +1012,10 @@ struct dataref_aux {
        && TYPE_PRECISION (TYPE) == 1           \
        && TYPE_UNSIGNED (TYPE)))
 
-extern vec<stmt_vec_info> stmt_vec_info_vec;
+extern vec<stmt_vec_info> *stmt_vec_info_vec;
 
-void init_stmt_vec_info_vec (void);
-void free_stmt_vec_info_vec (void);
+void set_stmt_vec_info_vec (vec<stmt_vec_info> *);
+void free_stmt_vec_infos (vec<stmt_vec_info> *);
 
 /* Return a stmt_vec_info corresponding to STMT.  */
 
@@ -1023,7 +1026,7 @@ vinfo_for_stmt (gimple *stmt)
   if (uid <= 0)
     return NULL;
 
-  return stmt_vec_info_vec[uid - 1];
+  return (*stmt_vec_info_vec)[uid - 1];
 }
 
 /* Set vectorizer information INFO for STMT.  */
@@ -1035,14 +1038,14 @@ set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info)
   if (uid == 0)
     {
       gcc_checking_assert (info);
-      uid = stmt_vec_info_vec.length () + 1;
+      uid = stmt_vec_info_vec->length () + 1;
       gimple_set_uid (stmt, uid);
-      stmt_vec_info_vec.safe_push (info);
+      stmt_vec_info_vec->safe_push (info);
     }
   else
     {
       gcc_checking_assert (info == NULL);
-      stmt_vec_info_vec[uid - 1] = info;
+      (*stmt_vec_info_vec)[uid - 1] = info;
     }
 }
 
@@ -1065,8 +1068,8 @@ get_earlier_stmt (gimple *stmt1, gimple *stmt2)
   if (uid1 == 0 || uid2 == 0)
     return NULL;
 
-  gcc_checking_assert (uid1 <= stmt_vec_info_vec.length ()
-                      && uid2 <= stmt_vec_info_vec.length ());
+  gcc_checking_assert (uid1 <= stmt_vec_info_vec->length ()
+                      && uid2 <= stmt_vec_info_vec->length ());
 
   if (uid1 < uid2)
     return stmt1;
@@ -1093,8 +1096,8 @@ get_later_stmt (gimple *stmt1, gimple *stmt2)
   if (uid1 == 0 || uid2 == 0)
     return NULL;
 
-  gcc_assert (uid1 <= stmt_vec_info_vec.length ());
-  gcc_assert (uid2 <= stmt_vec_info_vec.length ());
+  gcc_assert (uid1 <= stmt_vec_info_vec->length ());
+  gcc_assert (uid2 <= stmt_vec_info_vec->length ());
 
   if (uid1 > uid2)
     return stmt1;