aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-12-07 18:41:59 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-12-07 18:41:59 +0000
commitabe73c3d32b68809628eaa3266bf98cb7352851c (patch)
treef651282f43b411a678d09f3e8beca08fb288a564 /gcc/gimple-fold.c
parentb3def403fa7ae89679468b8f986cab7361c1034d (diff)
downloadgcc-abe73c3d32b68809628eaa3266bf98cb7352851c.zip
gcc-abe73c3d32b68809628eaa3266bf98cb7352851c.tar.gz
gcc-abe73c3d32b68809628eaa3266bf98cb7352851c.tar.bz2
Make gimple_build_vector take a tree_vector_builder
This patch changes gimple_build_vector so that it takes a tree_vector_builder instead of a size and a vector of trees. 2017-12-07 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * vector-builder.h (vector_builder::derived): New const overload. (vector_builder::elt): New function. * tree-vector-builder.h (tree_vector_builder::type): New function. (tree_vector_builder::apply_step): Declare. * tree-vector-builder.c (tree_vector_builder::apply_step): New function. * gimple-fold.h (tree_vector_builder): Declare. (gimple_build_vector): Take a tree_vector_builder instead of a type and vector of elements. * gimple-fold.c (gimple_build_vector): Likewise. * tree-vect-loop.c (get_initial_def_for_reduction): Update call accordingly. (get_initial_defs_for_reduction): Likewise. (vectorizable_induction): Likewise. From-SVN: r255478
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 6044092..24f7e76 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -7178,23 +7178,30 @@ gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
return res;
}
-/* Build a vector of type TYPE in which the elements have the values
- given by ELTS. Return a gimple value for the result, appending any
- new instructions to SEQ. */
+/* Build a vector from BUILDER, handling the case in which some elements
+ are non-constant. Return a gimple value for the result, appending any
+ new instructions to SEQ.
+
+ BUILDER must not have a stepped encoding on entry. This is because
+ the function is not geared up to handle the arithmetic that would
+ be needed in the variable case, and any code building a vector that
+ is known to be constant should use BUILDER->build () directly. */
tree
-gimple_build_vector (gimple_seq *seq, location_t loc, tree type,
- vec<tree> elts)
+gimple_build_vector (gimple_seq *seq, location_t loc,
+ tree_vector_builder *builder)
{
- unsigned int nelts = elts.length ();
- gcc_assert (nelts == TYPE_VECTOR_SUBPARTS (type));
- for (unsigned int i = 0; i < nelts; ++i)
- if (!TREE_CONSTANT (elts[i]))
+ gcc_assert (builder->nelts_per_pattern () <= 2);
+ unsigned int encoded_nelts = builder->encoded_nelts ();
+ for (unsigned int i = 0; i < encoded_nelts; ++i)
+ if (!TREE_CONSTANT ((*builder)[i]))
{
+ tree type = builder->type ();
+ unsigned int nelts = TYPE_VECTOR_SUBPARTS (type);
vec<constructor_elt, va_gc> *v;
vec_alloc (v, nelts);
for (i = 0; i < nelts; ++i)
- CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, elts[i]);
+ CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, builder->elt (i));
tree res;
if (gimple_in_ssa_p (cfun))
@@ -7206,7 +7213,7 @@ gimple_build_vector (gimple_seq *seq, location_t loc, tree type,
gimple_seq_add_stmt_without_update (seq, stmt);
return res;
}
- return build_vector (type, elts);
+ return builder->build ();
}
/* Return true if the result of assignment STMT is known to be non-negative.