Commit b00cb3bf by Richard Sandiford Committed by Richard Sandiford

Use ssizetype selectors for autovectorised VEC_PERM_EXPRs

The previous patches mean that there's no reason that constant
VEC_PERM_EXPRs need to have the same shape as the data inputs.
This patch makes the autovectoriser use sizetype elements instead,
so that indices don't get truncated for large or variable-length
vectors.

2018-01-02  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* tree-cfg.c (verify_gimple_assign_ternary): Allow the size of
	the selector elements to be different from the data elements
	if the selector is a VECTOR_CST.
	* tree-vect-stmts.c (vect_gen_perm_mask_any): Use a vector of
	ssizetype for the selector.

From-SVN: r256100
parent d3867483
2018-01-02 Richard Sandiford <richard.sandiford@linaro.org> 2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
* tree-cfg.c (verify_gimple_assign_ternary): Allow the size of
the selector elements to be different from the data elements
if the selector is a VECTOR_CST.
* tree-vect-stmts.c (vect_gen_perm_mask_any): Use a vector of
ssizetype for the selector.
2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
* optabs.c (shift_amt_for_vec_perm_mask): Try using series_p * optabs.c (shift_amt_for_vec_perm_mask): Try using series_p
before testing each element individually. before testing each element individually.
* tree-vect-generic.c (lower_vec_perm): Likewise. * tree-vect-generic.c (lower_vec_perm): Likewise.
...@@ -4428,8 +4428,11 @@ verify_gimple_assign_ternary (gassign *stmt) ...@@ -4428,8 +4428,11 @@ verify_gimple_assign_ternary (gassign *stmt)
} }
if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE
|| GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs3_type))) || (TREE_CODE (rhs3) != VECTOR_CST
!= GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (rhs1_type)))) && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE
(TREE_TYPE (rhs3_type)))
!= GET_MODE_BITSIZE (SCALAR_TYPE_MODE
(TREE_TYPE (rhs1_type))))))
{ {
error ("invalid mask type in vector permute expression"); error ("invalid mask type in vector permute expression");
debug_generic_expr (lhs_type); debug_generic_expr (lhs_type);
......
...@@ -6535,11 +6535,12 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, ...@@ -6535,11 +6535,12 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
tree tree
vect_gen_perm_mask_any (tree vectype, const vec_perm_indices &sel) vect_gen_perm_mask_any (tree vectype, const vec_perm_indices &sel)
{ {
tree mask_elt_type, mask_type; tree mask_type;
unsigned int nunits = sel.length ();
gcc_assert (nunits == TYPE_VECTOR_SUBPARTS (vectype));
mask_elt_type = lang_hooks.types.type_for_mode mask_type = build_vector_type (ssizetype, nunits);
(int_mode_for_mode (TYPE_MODE (TREE_TYPE (vectype))).require (), 1);
mask_type = get_vectype_for_scalar_type (mask_elt_type);
return vec_perm_indices_to_tree (mask_type, sel); return vec_perm_indices_to_tree (mask_type, sel);
} }
......
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