Commit faf63e39 by Richard Henderson Committed by Richard Henderson

target.h (targetm.vectorize.builtin_vec_perm_ok): New.

	* target.h (targetm.vectorize.builtin_vec_perm_ok): New.
	* target-def.h (TARGET_VECTORIZE_BUILTIN_VEC_PERM_OK): New.
	* hooks.h, hooks.c (hook_bool_tree_tree_true): New.
	* tree-vect-slp.c (vect_create_mask_and_perm): Don't create
	the vector constant here...
	(vect_transform_slp_perm_load): ... do it here instead.  Validate
	that the permutation vector is implementable by the target.

From-SVN: r154665
parent dac29646
2009-11-25 Richard Henderson <rth@redhat.com>
* target.h (targetm.vectorize.builtin_vec_perm_ok): New.
* target-def.h (TARGET_VECTORIZE_BUILTIN_VEC_PERM_OK): New.
* hooks.h, hooks.c (hook_bool_tree_tree_true): New.
* tree-vect-slp.c (vect_create_mask_and_perm): Don't create
the vector constant here...
(vect_transform_slp_perm_load): ... do it here instead. Validate
that the permutation vector is implementable by the target.
2009-11-25 Jakub Jelinek <jakub@redhat.com> 2009-11-25 Jakub Jelinek <jakub@redhat.com>
* config/rs6000/sysv4.opt (mregnames): Change Var to rs6000_regnames. * config/rs6000/sysv4.opt (mregnames): Change Var to rs6000_regnames.
...@@ -221,6 +221,12 @@ hook_bool_tree_tree_false (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED) ...@@ -221,6 +221,12 @@ hook_bool_tree_tree_false (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
} }
bool bool
hook_bool_tree_tree_true (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
{
return true;
}
bool
hook_bool_tree_bool_false (tree a ATTRIBUTE_UNUSED, bool b ATTRIBUTE_UNUSED) hook_bool_tree_bool_false (tree a ATTRIBUTE_UNUSED, bool b ATTRIBUTE_UNUSED)
{ {
return false; return false;
......
...@@ -50,6 +50,7 @@ extern bool hook_bool_rtx_int_int_intp_bool_false (rtx, int, int, int *, bool); ...@@ -50,6 +50,7 @@ extern bool hook_bool_rtx_int_int_intp_bool_false (rtx, int, int, int *, bool);
extern bool hook_bool_constcharptr_size_t_false (const char *, size_t); extern bool hook_bool_constcharptr_size_t_false (const char *, size_t);
extern bool hook_bool_size_t_constcharptr_int_true (size_t, const char *, int); extern bool hook_bool_size_t_constcharptr_int_true (size_t, const char *, int);
extern bool hook_bool_tree_tree_false (tree, tree); extern bool hook_bool_tree_tree_false (tree, tree);
extern bool hook_bool_tree_tree_true (tree, tree);
extern bool hook_bool_tree_bool_false (tree, bool); extern bool hook_bool_tree_bool_false (tree, bool);
extern void hook_void_void (void); extern void hook_void_void (void);
......
...@@ -391,6 +391,8 @@ ...@@ -391,6 +391,8 @@
#define TARGET_VECTOR_ALIGNMENT_REACHABLE \ #define TARGET_VECTOR_ALIGNMENT_REACHABLE \
default_builtin_vector_alignment_reachable default_builtin_vector_alignment_reachable
#define TARGET_VECTORIZE_BUILTIN_VEC_PERM 0 #define TARGET_VECTORIZE_BUILTIN_VEC_PERM 0
#define TARGET_VECTORIZE_BUILTIN_VEC_PERM_OK \
hook_bool_tree_tree_true
#define TARGET_SUPPORT_VECTOR_MISALIGNMENT \ #define TARGET_SUPPORT_VECTOR_MISALIGNMENT \
default_builtin_support_vector_misalignment default_builtin_support_vector_misalignment
...@@ -405,7 +407,8 @@ ...@@ -405,7 +407,8 @@
TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST, \ TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST, \
TARGET_VECTOR_ALIGNMENT_REACHABLE, \ TARGET_VECTOR_ALIGNMENT_REACHABLE, \
TARGET_VECTORIZE_BUILTIN_VEC_PERM, \ TARGET_VECTORIZE_BUILTIN_VEC_PERM, \
TARGET_SUPPORT_VECTOR_MISALIGNMENT \ TARGET_VECTORIZE_BUILTIN_VEC_PERM_OK, \
TARGET_SUPPORT_VECTOR_MISALIGNMENT \
} }
#define TARGET_DEFAULT_TARGET_FLAGS 0 #define TARGET_DEFAULT_TARGET_FLAGS 0
......
...@@ -490,6 +490,10 @@ struct gcc_target ...@@ -490,6 +490,10 @@ struct gcc_target
/* Target builtin that implements vector permute. */ /* Target builtin that implements vector permute. */
tree (* builtin_vec_perm) (tree, tree*); tree (* builtin_vec_perm) (tree, tree*);
/* Return true if a vector created for builtin_vec_perm is valid. */
bool (* builtin_vec_perm_ok) (tree, tree);
/* Return true if the target supports misaligned store/load of a /* Return true if the target supports misaligned store/load of a
specific factor denoted in the third parameter. The last parameter specific factor denoted in the third parameter. The last parameter
is true if the access is defined in a packed struct. */ is true if the access is defined in a packed struct. */
......
...@@ -1630,28 +1630,19 @@ vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0, ...@@ -1630,28 +1630,19 @@ vect_get_slp_defs (slp_tree slp_node, VEC (tree,heap) **vec_oprnds0,
static inline void static inline void
vect_create_mask_and_perm (gimple stmt, gimple next_scalar_stmt, vect_create_mask_and_perm (gimple stmt, gimple next_scalar_stmt,
int *mask_array, int mask_nunits, tree mask, int first_vec_indx, int second_vec_indx,
tree mask_element_type, tree mask_type,
int first_vec_indx, int second_vec_indx,
gimple_stmt_iterator *gsi, slp_tree node, gimple_stmt_iterator *gsi, slp_tree node,
tree builtin_decl, tree vectype, tree builtin_decl, tree vectype,
VEC(tree,heap) *dr_chain, VEC(tree,heap) *dr_chain,
int ncopies, int vect_stmts_counter) int ncopies, int vect_stmts_counter)
{ {
tree t = NULL_TREE, mask_vec, mask, perm_dest; tree perm_dest;
gimple perm_stmt = NULL; gimple perm_stmt = NULL;
stmt_vec_info next_stmt_info; stmt_vec_info next_stmt_info;
int i, group_size, stride, dr_chain_size; int i, group_size, stride, dr_chain_size;
tree first_vec, second_vec, data_ref; tree first_vec, second_vec, data_ref;
VEC (tree, heap) *params = NULL; VEC (tree, heap) *params = NULL;
/* Create a vector mask. */
for (i = mask_nunits - 1; i >= 0; --i)
t = tree_cons (NULL_TREE, build_int_cst (mask_element_type, mask_array[i]),
t);
mask_vec = build_vector (mask_type, t);
mask = vect_init_vector (stmt, mask_vec, mask_type, NULL);
group_size = VEC_length (gimple, SLP_TREE_SCALAR_STMTS (node)); group_size = VEC_length (gimple, SLP_TREE_SCALAR_STMTS (node));
stride = SLP_TREE_NUMBER_OF_VEC_STMTS (node) / ncopies; stride = SLP_TREE_NUMBER_OF_VEC_STMTS (node) / ncopies;
dr_chain_size = VEC_length (tree, dr_chain); dr_chain_size = VEC_length (tree, dr_chain);
...@@ -1890,7 +1881,28 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tree, heap) *dr_chain, ...@@ -1890,7 +1881,28 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tree, heap) *dr_chain,
if (index == mask_nunits) if (index == mask_nunits)
{ {
index = 0; tree mask_vec = NULL;
while (--index >= 0)
{
tree t = build_int_cst (mask_element_type, mask[index]);
mask_vec = tree_cons (NULL, t, mask_vec);
}
mask_vec = build_vector (mask_type, mask_vec);
index = 0;
if (!targetm.vectorize.builtin_vec_perm_ok (vectype,
mask_vec))
{
if (vect_print_dump_info (REPORT_DETAILS))
{
fprintf (vect_dump, "unsupported vect permute ");
print_generic_expr (vect_dump, mask_vec, 0);
}
free (mask);
return false;
}
if (!analyze_only) if (!analyze_only)
{ {
if (need_next_vector) if (need_next_vector)
...@@ -1903,10 +1915,9 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tree, heap) *dr_chain, ...@@ -1903,10 +1915,9 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tree, heap) *dr_chain,
SLP_TREE_SCALAR_STMTS (node), scalar_index++); SLP_TREE_SCALAR_STMTS (node), scalar_index++);
vect_create_mask_and_perm (stmt, next_scalar_stmt, vect_create_mask_and_perm (stmt, next_scalar_stmt,
mask, mask_nunits, mask_element_type, mask_type, mask_vec, first_vec_index, second_vec_index,
first_vec_index, second_vec_index, gsi, node, gsi, node, builtin_decl, vectype, dr_chain,
builtin_decl, vectype, dr_chain, ncopies, ncopies, vect_stmts_counter++);
vect_stmts_counter++);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment