diff mbox series

[v2,2/16] middle-end: Refactor and expose some vectorizer helper functions.

Message ID 20200925142740.GA12448@arm.com
State New
Headers show
Series middle-end Add support for SLP vectorization of complex number instructions. | expand

Commit Message

Tamar Christina Sept. 25, 2020, 2:27 p.m. UTC
Hi All,

This is a small refactoring which exposes some helper functions in the
vectorizer so they can be used in other places.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	* tree-vect-patterns.c (vect_mark_pattern_stmts): Remove static.
	* tree-vect-slp.c (vect_free_slp_tree,
	vect_build_slp_tree): Remove static.
	(struct bst_traits, bst_traits::hash, bst_traits::equal): Move...
	* tree-vectorizer.h (struct bst_traits, bst_traits::hash,
	bst_traits::equal): ... to here.
	(vect_mark_pattern_stmts, vect_free_slp_tree,
	vect_build_slp_tree): Declare.

--

Comments

Tamar Christina Nov. 3, 2020, 3:06 p.m. UTC | #1
Hi All,

This patch is a respin of the previous one defining a new helper
function add_pattern_stmt.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	* tree-vect-patterns.c (vect_mark_pattern_stmts): Remove static inline.
	* tree-vect-slp.c (vect_create_new_slp_node): Remove static and only
	set smts if valid.
	* tree-vectorizer.c (vec_info::add_pattern_stmt): New.
	(vec_info::set_vinfo_for_stmt): Optionally enforce read-only.
	* tree-vectorizer.h (struct _slp_tree): Use new types.
	(lane_permutation_t, lane_permutation_t): New.
	(vect_create_new_slp_node, vect_mark_pattern_stmts): New.

> -----Original Message-----
> From: Gcc-patches <gcc-patches-bounces@gcc.gnu.org> On Behalf Of Tamar
> Christina
> Sent: Friday, September 25, 2020 3:28 PM
> To: gcc-patches@gcc.gnu.org
> Cc: nd <nd@arm.com>; rguenther@suse.de; ook@ucw.cz
> Subject: [PATCH v2 2/16]middle-end: Refactor and expose some vectorizer
> helper functions.
> 
> Hi All,
> 
> This is a small refactoring which exposes some helper functions in the
> vectorizer so they can be used in other places.
> 
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> 
> Ok for master?
> 
> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	* tree-vect-patterns.c (vect_mark_pattern_stmts): Remove static.
> 	* tree-vect-slp.c (vect_free_slp_tree,
> 	vect_build_slp_tree): Remove static.
> 	(struct bst_traits, bst_traits::hash, bst_traits::equal): Move...
> 	* tree-vectorizer.h (struct bst_traits, bst_traits::hash,
> 	bst_traits::equal): ... to here.
> 	(vect_mark_pattern_stmts, vect_free_slp_tree,
> 	vect_build_slp_tree): Declare.
> 
> --
Richard Biener Nov. 4, 2020, 11:09 a.m. UTC | #2
On Tue, 3 Nov 2020, Tamar Christina wrote:

> Hi All,
> 
> This patch is a respin of the previous one defining a new helper
> function add_pattern_stmt.
> 
> Ok for master?

OK if the rest is approved.

> Thanks,
> Tamar
> 
> gcc/ChangeLog:
> 
> 	* tree-vect-patterns.c (vect_mark_pattern_stmts): Remove static inline.
> 	* tree-vect-slp.c (vect_create_new_slp_node): Remove static and only
> 	set smts if valid.
> 	* tree-vectorizer.c (vec_info::add_pattern_stmt): New.
> 	(vec_info::set_vinfo_for_stmt): Optionally enforce read-only.
> 	* tree-vectorizer.h (struct _slp_tree): Use new types.
> 	(lane_permutation_t, lane_permutation_t): New.
> 	(vect_create_new_slp_node, vect_mark_pattern_stmts): New.
> 
> > -----Original Message-----
> > From: Gcc-patches <gcc-patches-bounces@gcc.gnu.org> On Behalf Of Tamar
> > Christina
> > Sent: Friday, September 25, 2020 3:28 PM
> > To: gcc-patches@gcc.gnu.org
> > Cc: nd <nd@arm.com>; rguenther@suse.de; ook@ucw.cz
> > Subject: [PATCH v2 2/16]middle-end: Refactor and expose some vectorizer
> > helper functions.
> > 
> > Hi All,
> > 
> > This is a small refactoring which exposes some helper functions in the
> > vectorizer so they can be used in other places.
> > 
> > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
> > 
> > Ok for master?
> > 
> > Thanks,
> > Tamar
> > 
> > gcc/ChangeLog:
> > 
> > 	* tree-vect-patterns.c (vect_mark_pattern_stmts): Remove static.
> > 	* tree-vect-slp.c (vect_free_slp_tree,
> > 	vect_build_slp_tree): Remove static.
> > 	(struct bst_traits, bst_traits::hash, bst_traits::equal): Move...
> > 	* tree-vectorizer.h (struct bst_traits, bst_traits::hash,
> > 	bst_traits::equal): ... to here.
> > 	(vect_mark_pattern_stmts, vect_free_slp_tree,
> > 	vect_build_slp_tree): Declare.
> > 
> > --
>
diff mbox series

Patch

diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index db45740da3cba14a3552f9446651e8f289187fbb..3bacd5c827e1a6436c5916022c04e0d6594c316a 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -5169,7 +5169,7 @@  const unsigned int NUM_PATTERNS = ARRAY_SIZE (vect_vect_recog_func_ptrs);
 
 /* Mark statements that are involved in a pattern.  */
 
-static inline void
+void
 vect_mark_pattern_stmts (vec_info *vinfo,
 			 stmt_vec_info orig_stmt_info, gimple *pattern_stmt,
                          tree pattern_vectype)
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index bf8ea4326597f4211d2772e9db60aa69285b5998..01189d44d892fc42b132bbb7de1c471df45518ae 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -86,7 +86,7 @@  _slp_tree::~_slp_tree ()
 
 /* Recursively free the memory allocated for the SLP tree rooted at NODE.  */
 
-static void
+void
 vect_free_slp_tree (slp_tree node)
 {
   int i;
@@ -1120,45 +1120,6 @@  vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
   return true;
 }
 
-/* Traits for the hash_set to record failed SLP builds for a stmt set.
-   Note we never remove apart from at destruction time so we do not
-   need a special value for deleted that differs from empty.  */
-struct bst_traits
-{
-  typedef vec <stmt_vec_info> value_type;
-  typedef vec <stmt_vec_info> compare_type;
-  static inline hashval_t hash (value_type);
-  static inline bool equal (value_type existing, value_type candidate);
-  static inline bool is_empty (value_type x) { return !x.exists (); }
-  static inline bool is_deleted (value_type x) { return !x.exists (); }
-  static const bool empty_zero_p = true;
-  static inline void mark_empty (value_type &x) { x.release (); }
-  static inline void mark_deleted (value_type &x) { x.release (); }
-  static inline void remove (value_type &x) { x.release (); }
-};
-inline hashval_t
-bst_traits::hash (value_type x)
-{
-  inchash::hash h;
-  for (unsigned i = 0; i < x.length (); ++i)
-    h.add_int (gimple_uid (x[i]->stmt));
-  return h.end ();
-}
-inline bool
-bst_traits::equal (value_type existing, value_type candidate)
-{
-  if (existing.length () != candidate.length ())
-    return false;
-  for (unsigned i = 0; i < existing.length (); ++i)
-    if (existing[i] != candidate[i])
-      return false;
-  return true;
-}
-
-typedef hash_map <vec <gimple *>, slp_tree,
-		  simple_hashmap_traits <bst_traits, slp_tree> >
-  scalar_stmts_to_slp_tree_map_t;
-
 static slp_tree
 vect_build_slp_tree_2 (vec_info *vinfo,
 		       vec<stmt_vec_info> stmts, unsigned int group_size,
@@ -1166,7 +1127,7 @@  vect_build_slp_tree_2 (vec_info *vinfo,
 		       bool *matches, unsigned *npermutes, unsigned *tree_size,
 		       scalar_stmts_to_slp_tree_map_t *bst_map);
 
-static slp_tree
+slp_tree
 vect_build_slp_tree (vec_info *vinfo,
 		     vec<stmt_vec_info> stmts, unsigned int group_size,
 		     poly_uint64 *max_nunits,
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 2ebcf9f9926ec7175f28391f172800499bbc59db..79926f1a43534635ddca85556a928e364022c40a 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -2047,6 +2047,9 @@  extern int vect_get_place_in_interleaving_chain (stmt_vec_info, stmt_vec_info);
 extern bool vect_update_shared_vectype (stmt_vec_info, tree);
 
 /* In tree-vect-patterns.c.  */
+extern void
+vect_mark_pattern_stmts (vec_info *, stmt_vec_info, gimple *, tree);
+
 /* Pattern recognition functions.
    Additional pattern recognition functions can (and will) be added
    in the future.  */
@@ -2058,4 +2061,51 @@  void vect_free_loop_info_assumptions (class loop *);
 gimple *vect_loop_vectorized_call (class loop *, gcond **cond = NULL);
 bool vect_stmt_dominates_stmt_p (gimple *, gimple *);
 
+/* Traits for the hash_set to record failed SLP builds for a stmt set.
+   Note we never remove apart from at destruction time so we do not
+   need a special value for deleted that differs from empty.  */
+struct bst_traits
+{
+  typedef vec <stmt_vec_info> value_type;
+  typedef vec <stmt_vec_info> compare_type;
+  static inline hashval_t hash (value_type);
+  static inline bool equal (value_type existing, value_type candidate);
+  static inline bool is_empty (value_type x) { return !x.exists (); }
+  static inline bool is_deleted (value_type x) { return !x.exists (); }
+  static const bool empty_zero_p = true;
+  static inline void mark_empty (value_type &x) { x.release (); }
+  static inline void mark_deleted (value_type &x) { x.release (); }
+  static inline void remove (value_type &x) { x.release (); }
+};
+inline hashval_t
+bst_traits::hash (value_type x)
+{
+  inchash::hash h;
+  for (unsigned i = 0; i < x.length (); ++i)
+    h.add_int (gimple_uid (x[i]->stmt));
+  return h.end ();
+}
+inline bool
+bst_traits::equal (value_type existing, value_type candidate)
+{
+  if (existing.length () != candidate.length ())
+    return false;
+  for (unsigned i = 0; i < existing.length (); ++i)
+    if (existing[i] != candidate[i])
+      return false;
+  return true;
+}
+
+typedef hash_map <vec <gimple *>, slp_tree,
+		  simple_hashmap_traits <bst_traits, slp_tree> >
+  scalar_stmts_to_slp_tree_map_t;
+
+extern void
+vect_free_slp_tree (slp_tree node);
+
+slp_tree
+vect_build_slp_tree (vec_info *, vec<stmt_vec_info>, unsigned int,
+		     poly_uint64 *, bool *, unsigned *, unsigned *,
+		     scalar_stmts_to_slp_tree_map_t *);
+
 #endif  /* GCC_TREE_VECTORIZER_H  */