diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-09-14 15:46:08 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-09-14 15:46:08 +0000 |
commit | 794e31808f1554d51f0f0357c3a74a6365f0a274 (patch) | |
tree | d491aa520d3a8de4b35dbdde63439716c15b6f8d /gcc/tree-vect-generic.c | |
parent | 9e822269364f5268b2bdc82530fd6c871f47b1bc (diff) | |
download | gcc-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-generic.c')
-rw-r--r-- | gcc/tree-vect-generic.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index dc8b2ed..1341d66 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -398,9 +398,9 @@ add_rshift (gimple_stmt_iterator *gsi, tree type, tree op0, int *shiftcnts) if (op != unknown_optab && optab_handler (op, TYPE_MODE (type)) != CODE_FOR_nothing) { - tree *vec = XALLOCAVEC (tree, nunits); + auto_vec<tree, 32> vec (nunits); for (i = 0; i < nunits; i++) - vec[i] = build_int_cst (TREE_TYPE (type), shiftcnts[i]); + vec.quick_push (build_int_cst (TREE_TYPE (type), shiftcnts[i])); return gimplify_build2 (gsi, RSHIFT_EXPR, type, op0, build_vector (type, vec)); } @@ -429,7 +429,6 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, unsigned int i; signop sign_p = TYPE_SIGN (TREE_TYPE (type)); unsigned HOST_WIDE_INT mask = GET_MODE_MASK (TYPE_MODE (TREE_TYPE (type))); - tree *vec; tree cur_op, mulcst, tem; optab op; @@ -593,8 +592,6 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, mode = -2; } - vec = XALLOCAVEC (tree, nunits); - if (use_pow2) { tree addend = NULL_TREE; @@ -638,10 +635,11 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, mask_type = build_same_sized_truth_vector_type (type); zero = build_zero_cst (type); cond = build2 (LT_EXPR, mask_type, op0, zero); + auto_vec<tree, 32> vec (nunits); for (i = 0; i < nunits; i++) - vec[i] = build_int_cst (TREE_TYPE (type), - (HOST_WIDE_INT_1U - << shifts[i]) - 1); + vec.quick_push (build_int_cst (TREE_TYPE (type), + (HOST_WIDE_INT_1U + << shifts[i]) - 1)); cst = build_vector (type, vec); addend = make_ssa_name (type); stmt = gimple_build_assign (addend, VEC_COND_EXPR, cond, @@ -676,10 +674,11 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, else { tree mask; + auto_vec<tree, 32> vec (nunits); for (i = 0; i < nunits; i++) - vec[i] = build_int_cst (TREE_TYPE (type), - (HOST_WIDE_INT_1U - << shifts[i]) - 1); + vec.quick_push (build_int_cst (TREE_TYPE (type), + (HOST_WIDE_INT_1U + << shifts[i]) - 1)); mask = build_vector (type, vec); op = optab_for_tree_code (BIT_AND_EXPR, type, optab_default); if (op != unknown_optab @@ -754,8 +753,9 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, return NULL_TREE; } + auto_vec<tree, 32> vec (nunits); for (i = 0; i < nunits; i++) - vec[i] = build_int_cst (TREE_TYPE (type), mulc[i]); + vec.quick_push (build_int_cst (TREE_TYPE (type), mulc[i])); mulcst = build_vector (type, vec); cur_op = gimplify_build2 (gsi, MULT_HIGHPART_EXPR, type, cur_op, mulcst); @@ -1066,7 +1066,6 @@ optimize_vector_constructor (gimple_stmt_iterator *gsi) unsigned int i, j, nelts = TYPE_VECTOR_SUBPARTS (type); bool all_same = true; constructor_elt *elt; - tree *cst; gimple *g; tree base = NULL_TREE; optab op; @@ -1105,22 +1104,23 @@ optimize_vector_constructor (gimple_stmt_iterator *gsi) } if (all_same) return; - cst = XALLOCAVEC (tree, nelts); + auto_vec<tree, 32> cst (nelts); for (i = 0; i < nelts; i++) { - tree this_base = CONSTRUCTOR_ELT (rhs, i)->value;; - cst[i] = build_zero_cst (TREE_TYPE (base)); + tree this_base = CONSTRUCTOR_ELT (rhs, i)->value; + tree elt = build_zero_cst (TREE_TYPE (base)); while (this_base != base) { g = SSA_NAME_DEF_STMT (this_base); - cst[i] = fold_binary (PLUS_EXPR, TREE_TYPE (base), - cst[i], gimple_assign_rhs2 (g)); - if (cst[i] == NULL_TREE - || TREE_CODE (cst[i]) != INTEGER_CST - || TREE_OVERFLOW (cst[i])) + elt = fold_binary (PLUS_EXPR, TREE_TYPE (base), + elt, gimple_assign_rhs2 (g)); + if (elt == NULL_TREE + || TREE_CODE (elt) != INTEGER_CST + || TREE_OVERFLOW (elt)) return; this_base = gimple_assign_rhs1 (g); } + cst.quick_push (elt); } for (i = 0; i < nelts; i++) CONSTRUCTOR_ELT (rhs, i)->value = base; |