diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index ac56acebe016058cbbc9599cef348ec4211c19d6..32b272ac443cac6bbaf2695c81078a9c8c2a656d 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -5216,7 +5216,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 e97fbe897a76008d50ee94c3b1b009344cc37d4a..30036ec84c74a0e428cc661eacf565224047f9e0 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -148,15 +148,18 @@ vect_free_slp_instance (slp_instance instance) /* Create an SLP node for SCALAR_STMTS. */ -static slp_tree +slp_tree vect_create_new_slp_node (slp_tree node, vec scalar_stmts, unsigned nops) { SLP_TREE_SCALAR_STMTS (node) = scalar_stmts; SLP_TREE_CHILDREN (node).create (nops); SLP_TREE_DEF_TYPE (node) = vect_internal_def; - SLP_TREE_REPRESENTATIVE (node) = scalar_stmts[0]; - SLP_TREE_LANES (node) = scalar_stmts.length (); + if (scalar_stmts.exists ()) + { + SLP_TREE_REPRESENTATIVE (node) = scalar_stmts[0]; + SLP_TREE_LANES (node) = scalar_stmts.length (); + } return node; } diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index fbf5291cf065f3944040937db92d3997acd45f23..4bd454cfb185d7036843fc7140b073f525b2ec6a 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -115,6 +115,8 @@ typedef hash_map > lane_permutation_t; +typedef vec load_permutation_t; extern object_allocator<_slp_tree> *slp_tree_pool; @@ -137,11 +139,11 @@ struct _slp_tree { /* Load permutation relative to the stores, NULL if there is no permutation. */ - vec load_permutation; + load_permutation_t load_permutation; /* Lane permutation of the operands scalar lanes encoded as pairs of { operand number, lane number }. The number of elements denotes the number of output lanes. */ - vec > lane_permutation; + lane_permutation_t lane_permutation; tree vectype; /* Vectorized stmt/s. */ @@ -348,6 +350,7 @@ public: ~vec_info (); 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_def (tree); stmt_vec_info lookup_single_use (tree); @@ -393,7 +396,7 @@ public: private: 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_info (stmt_vec_info); }; @@ -1975,8 +1978,12 @@ extern void duplicate_and_interleave (vec_info *, gimple_seq *, tree, vec, unsigned int, vec &); 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 slp_tree vect_create_new_slp_node (vec, unsigned); /* 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. */ diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index b63dda31a0839b094985d306a993503cc00dd7eb..d81774b242569262a51b7be02815acd6d1a6bfd0 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -525,6 +525,19 @@ vec_info::add_stmt (gimple *stmt) 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 return null. It is safe to call this function on any statement, even if 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. */ 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); if (uid == 0) { - gcc_assert (!stmt_vec_info_ro); + gcc_assert (!check_ro || !stmt_vec_info_ro); gcc_checking_assert (info); uid = stmt_vec_infos.length () + 1; gimple_set_uid (stmt, uid);