aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-slp.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-09-14 15:46:08 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-09-14 15:46:08 +0000
commit794e31808f1554d51f0f0357c3a74a6365f0a274 (patch)
treed491aa520d3a8de4b35dbdde63439716c15b6f8d /gcc/tree-vect-slp.c
parent9e822269364f5268b2bdc82530fd6c871f47b1bc (diff)
downloadgcc-794e31808f1554d51f0f0357c3a74a6365f0a274.zip
gcc-794e31808f1554d51f0f0357c3a74a6365f0a274.tar.gz
gcc-794e31808f1554d51f0f0357c3a74a6365f0a274.tar.bz2
Use vec<> in build_vector
This patch makes build_vector take the elements as a vec<> rather than a tree *. This is useful for SVE because it bundles the number of elements with the elements themselves, and enforces the fact that the number is constant. Also, I think things like the folds can be used with any generic GNU vector, not just those that match machine vectors, so the arguments to XALLOCAVEC had no clear limit. 2017-09-14 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (build_vector): Take a vec<tree> instead of a tree *. * tree.c (build_vector): Likewise. (build_vector_from_ctor): Update accordingly. (build_vector_from_val): Likewise. * gimple-fold.c (gimple_fold_stmt_to_constant_1): Likewise. * tree-ssa-forwprop.c (simplify_vector_constructor): Likewise. * tree-vect-generic.c (add_rshift): Likewise. (expand_vector_divmod): Likewise. (optimize_vector_constructor): Likewise. * tree-vect-slp.c (vect_get_constant_vectors): Likewise. (vect_transform_slp_perm_load): Likewise. (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_bswap): Likewise. (vectorizable_call): Likewise. (vect_gen_perm_mask_any): Likewise. Add elements in order. * expmed.c (make_tree): Likewise. * fold-const.c (fold_negate_expr_1): Use auto_vec<tree> when building a vector passed to build_vector. (fold_convert_const): Likewise. (exact_inverse): Likewise. (fold_ternary_loc): Likewise. (fold_relational_const): Likewise. (const_binop): Likewise. Use VECTOR_CST_ELT directly when operating on VECTOR_CSTs, rather than going through vec_cst_ctor_to_array. (const_unop): Likewise. Store the reduction accumulator in a variable rather than an array. (vec_cst_ctor_to_array): Take the number of elements as a parameter. (fold_vec_perm): Update calls accordingly. Use auto_vec<tree> for the new vector, rather than constructing it after the input arrays. (native_interpret_vector): Use auto_vec<tree> when building a vector passed to build_vector. Add elements in order. * tree-vect-loop.c (get_initial_defs_for_reduction): Use auto_vec<tree> when building a vector passed to build_vector. (vect_create_epilog_for_reduction): Likewise. (vectorizable_induction): Likewise. (get_initial_def_for_reduction): Likewise. Fix indentation of case statements. * config/sparc/sparc.c (sparc_handle_vis_mul8x16): Change n_elts to a vec<tree> *. (sparc_fold_builtin): Use auto_vec<tree> when building a vector passed to build_vector. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252760
Diffstat (limited to 'gcc/tree-vect-slp.c')
-rw-r--r--gcc/tree-vect-slp.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 3873893..32ca6af 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3105,7 +3105,6 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
unsigned nunits;
tree vec_cst;
- tree *elts;
unsigned j, number_of_places_left_in_vector;
tree vector_type;
tree vop;
@@ -3158,7 +3157,8 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
number_of_places_left_in_vector = nunits;
constant_p = true;
- elts = XALLOCAVEC (tree, nunits);
+ auto_vec<tree, 32> elts (nunits);
+ elts.quick_grow (nunits);
bool place_after_defs = false;
for (j = 0; j < number_of_copies; j++)
{
@@ -3600,10 +3600,10 @@ vect_transform_slp_perm_load (slp_tree node, vec<tree> dr_chain,
if (! noop_p)
{
- tree *mask_elts = XALLOCAVEC (tree, nunits);
+ auto_vec<tree, 32> mask_elts (nunits);
for (int l = 0; l < nunits; ++l)
- mask_elts[l] = build_int_cst (mask_element_type,
- mask[l]);
+ mask_elts.quick_push (build_int_cst (mask_element_type,
+ mask[l]));
mask_vec = build_vector (mask_type, mask_elts);
}
@@ -3759,13 +3759,14 @@ vect_schedule_slp_instance (slp_tree node, slp_instance instance,
unsigned k = 0, l;
for (j = 0; j < v0.length (); ++j)
{
- tree *melts = XALLOCAVEC (tree, TYPE_VECTOR_SUBPARTS (vectype));
- for (l = 0; l < TYPE_VECTOR_SUBPARTS (vectype); ++l)
+ unsigned int nunits = TYPE_VECTOR_SUBPARTS (vectype);
+ auto_vec<tree, 32> melts (nunits);
+ for (l = 0; l < nunits; ++l)
{
if (k >= group_size)
k = 0;
- melts[l] = build_int_cst
- (meltype, mask[k++] * TYPE_VECTOR_SUBPARTS (vectype) + l);
+ tree t = build_int_cst (meltype, mask[k++] * nunits + l);
+ melts.quick_push (t);
}
tmask = build_vector (mvectype, melts);