diff options
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index 48279ebc181..4de73ee4d2c 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1366,6 +1366,29 @@ build_vector_from_ctor (tree type, VEC(constructor_elt,gc) *v) return build_vector (type, nreverse (list)); } +/* Build a vector of type VECTYPE where all the elements are SCs. */ +tree +build_vector_from_val (tree vectype, tree sc) +{ + int i, nunits = TYPE_VECTOR_SUBPARTS (vectype); + VEC(constructor_elt, gc) *v = NULL; + + if (sc == error_mark_node) + return sc; + + gcc_assert (lang_hooks.types_compatible_p (TREE_TYPE (sc), + TREE_TYPE (vectype))); + + v = VEC_alloc (constructor_elt, gc, nunits); + for (i = 0; i < nunits; ++i) + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, sc); + + if (CONSTANT_CLASS_P (sc)) + return build_vector_from_ctor (vectype, v); + else + return build_constructor (vectype, v); +} + /* Return a new CONSTRUCTOR node whose type is TYPE and whose values are in the VEC pointed to by VALS. */ tree @@ -1568,17 +1591,9 @@ build_one_cst (tree type) case VECTOR_TYPE: { - tree scalar, cst; - int i; - - scalar = build_one_cst (TREE_TYPE (type)); - - /* Create 'vect_cst_ = {cst,cst,...,cst}' */ - cst = NULL_TREE; - for (i = TYPE_VECTOR_SUBPARTS (type); --i >= 0; ) - cst = tree_cons (NULL_TREE, scalar, cst); + tree scalar = build_one_cst (TREE_TYPE (type)); - return build_vector (type, cst); + return build_vector_from_val (type, scalar); } case COMPLEX_TYPE: |