middle-end: Refactor and expose some vectorizer helper functions.
This is a small refactoring which exposes some helper functions in the vectorizer so they can be used in other places. 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.
This commit is contained in:
parent
501f470267
commit
10bbba9145
|
@ -5281,7 +5281,7 @@ const unsigned int NUM_PATTERNS = ARRAY_SIZE (vect_vect_recog_func_ptrs);
|
||||||
|
|
||||||
/* Mark statements that are involved in a pattern. */
|
/* Mark statements that are involved in a pattern. */
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
vect_mark_pattern_stmts (vec_info *vinfo,
|
vect_mark_pattern_stmts (vec_info *vinfo,
|
||||||
stmt_vec_info orig_stmt_info, gimple *pattern_stmt,
|
stmt_vec_info orig_stmt_info, gimple *pattern_stmt,
|
||||||
tree pattern_vectype)
|
tree pattern_vectype)
|
||||||
|
|
|
@ -176,15 +176,18 @@ vect_free_slp_instance (slp_instance instance)
|
||||||
|
|
||||||
/* Create an SLP node for SCALAR_STMTS. */
|
/* Create an SLP node for SCALAR_STMTS. */
|
||||||
|
|
||||||
static slp_tree
|
slp_tree
|
||||||
vect_create_new_slp_node (slp_tree node,
|
vect_create_new_slp_node (slp_tree node,
|
||||||
vec<stmt_vec_info> scalar_stmts, unsigned nops)
|
vec<stmt_vec_info> scalar_stmts, unsigned nops)
|
||||||
{
|
{
|
||||||
SLP_TREE_SCALAR_STMTS (node) = scalar_stmts;
|
SLP_TREE_SCALAR_STMTS (node) = scalar_stmts;
|
||||||
SLP_TREE_CHILDREN (node).create (nops);
|
SLP_TREE_CHILDREN (node).create (nops);
|
||||||
SLP_TREE_DEF_TYPE (node) = vect_internal_def;
|
SLP_TREE_DEF_TYPE (node) = vect_internal_def;
|
||||||
SLP_TREE_REPRESENTATIVE (node) = scalar_stmts[0];
|
if (scalar_stmts.exists ())
|
||||||
SLP_TREE_LANES (node) = scalar_stmts.length ();
|
{
|
||||||
|
SLP_TREE_REPRESENTATIVE (node) = scalar_stmts[0];
|
||||||
|
SLP_TREE_LANES (node) = scalar_stmts.length ();
|
||||||
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,6 +525,19 @@ vec_info::add_stmt (gimple *stmt)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Record that STMT belongs to the vectorizable region. Create a new
|
||||||
|
stmt_vec_info and mark VECINFO as being related and return the new
|
||||||
|
stmt_vec_info. */
|
||||||
|
|
||||||
|
stmt_vec_info
|
||||||
|
vec_info::add_pattern_stmt (gimple *stmt, stmt_vec_info stmt_info)
|
||||||
|
{
|
||||||
|
stmt_vec_info res = new_stmt_vec_info (stmt);
|
||||||
|
set_vinfo_for_stmt (stmt, res, false);
|
||||||
|
STMT_VINFO_RELATED_STMT (res) = stmt_info;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* If STMT has an associated stmt_vec_info, return that vec_info, otherwise
|
/* If STMT has an associated stmt_vec_info, return that vec_info, otherwise
|
||||||
return null. It is safe to call this function on any statement, even if
|
return null. It is safe to call this function on any statement, even if
|
||||||
it might not be part of the vectorizable region. */
|
it might not be part of the vectorizable region. */
|
||||||
|
@ -702,12 +715,12 @@ vec_info::new_stmt_vec_info (gimple *stmt)
|
||||||
/* Associate STMT with INFO. */
|
/* Associate STMT with INFO. */
|
||||||
|
|
||||||
void
|
void
|
||||||
vec_info::set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info)
|
vec_info::set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info, bool check_ro)
|
||||||
{
|
{
|
||||||
unsigned int uid = gimple_uid (stmt);
|
unsigned int uid = gimple_uid (stmt);
|
||||||
if (uid == 0)
|
if (uid == 0)
|
||||||
{
|
{
|
||||||
gcc_assert (!stmt_vec_info_ro);
|
gcc_assert (!check_ro || !stmt_vec_info_ro);
|
||||||
gcc_checking_assert (info);
|
gcc_checking_assert (info);
|
||||||
uid = stmt_vec_infos.length () + 1;
|
uid = stmt_vec_infos.length () + 1;
|
||||||
gimple_set_uid (stmt, uid);
|
gimple_set_uid (stmt, uid);
|
||||||
|
|
|
@ -114,6 +114,8 @@ typedef hash_map<tree_operand_hash,
|
||||||
SLP
|
SLP
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
typedef struct _slp_tree *slp_tree;
|
typedef struct _slp_tree *slp_tree;
|
||||||
|
typedef vec<std::pair<unsigned, unsigned> > lane_permutation_t;
|
||||||
|
typedef vec<unsigned> load_permutation_t;
|
||||||
|
|
||||||
/* A computation tree of an SLP instance. Each node corresponds to a group of
|
/* A computation tree of an SLP instance. Each node corresponds to a group of
|
||||||
stmts to be packed in a SIMD stmt. */
|
stmts to be packed in a SIMD stmt. */
|
||||||
|
@ -134,11 +136,11 @@ struct _slp_tree {
|
||||||
|
|
||||||
/* Load permutation relative to the stores, NULL if there is no
|
/* Load permutation relative to the stores, NULL if there is no
|
||||||
permutation. */
|
permutation. */
|
||||||
vec<unsigned> load_permutation;
|
load_permutation_t load_permutation;
|
||||||
/* Lane permutation of the operands scalar lanes encoded as pairs
|
/* Lane permutation of the operands scalar lanes encoded as pairs
|
||||||
of { operand number, lane number }. The number of elements
|
of { operand number, lane number }. The number of elements
|
||||||
denotes the number of output lanes. */
|
denotes the number of output lanes. */
|
||||||
vec<std::pair<unsigned, unsigned> > lane_permutation;
|
lane_permutation_t lane_permutation;
|
||||||
|
|
||||||
tree vectype;
|
tree vectype;
|
||||||
/* Vectorized stmt/s. */
|
/* Vectorized stmt/s. */
|
||||||
|
@ -362,6 +364,7 @@ public:
|
||||||
~vec_info ();
|
~vec_info ();
|
||||||
|
|
||||||
stmt_vec_info add_stmt (gimple *);
|
stmt_vec_info add_stmt (gimple *);
|
||||||
|
stmt_vec_info add_pattern_stmt (gimple *, stmt_vec_info);
|
||||||
stmt_vec_info lookup_stmt (gimple *);
|
stmt_vec_info lookup_stmt (gimple *);
|
||||||
stmt_vec_info lookup_def (tree);
|
stmt_vec_info lookup_def (tree);
|
||||||
stmt_vec_info lookup_single_use (tree);
|
stmt_vec_info lookup_single_use (tree);
|
||||||
|
@ -407,7 +410,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
stmt_vec_info new_stmt_vec_info (gimple *stmt);
|
stmt_vec_info new_stmt_vec_info (gimple *stmt);
|
||||||
void set_vinfo_for_stmt (gimple *, stmt_vec_info);
|
void set_vinfo_for_stmt (gimple *, stmt_vec_info, bool = true);
|
||||||
void free_stmt_vec_infos ();
|
void free_stmt_vec_infos ();
|
||||||
void free_stmt_vec_info (stmt_vec_info);
|
void free_stmt_vec_info (stmt_vec_info);
|
||||||
};
|
};
|
||||||
|
@ -2005,8 +2008,12 @@ extern void duplicate_and_interleave (vec_info *, gimple_seq *, tree,
|
||||||
vec<tree>, unsigned int, vec<tree> &);
|
vec<tree>, unsigned int, vec<tree> &);
|
||||||
extern int vect_get_place_in_interleaving_chain (stmt_vec_info, stmt_vec_info);
|
extern int vect_get_place_in_interleaving_chain (stmt_vec_info, stmt_vec_info);
|
||||||
extern bool vect_update_shared_vectype (stmt_vec_info, tree);
|
extern bool vect_update_shared_vectype (stmt_vec_info, tree);
|
||||||
|
extern slp_tree vect_create_new_slp_node (vec<stmt_vec_info>, unsigned);
|
||||||
|
|
||||||
/* In tree-vect-patterns.c. */
|
/* In tree-vect-patterns.c. */
|
||||||
|
extern void
|
||||||
|
vect_mark_pattern_stmts (vec_info *, stmt_vec_info, gimple *, tree);
|
||||||
|
|
||||||
/* Pattern recognition functions.
|
/* Pattern recognition functions.
|
||||||
Additional pattern recognition functions can (and will) be added
|
Additional pattern recognition functions can (and will) be added
|
||||||
in the future. */
|
in the future. */
|
||||||
|
|
Loading…
Reference in New Issue