aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 47ed609..7c5b75a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -11968,26 +11968,13 @@ fold (tree expr)
if (TREE_CODE (type) != VECTOR_TYPE)
return t;
- tree *vec = XALLOCAVEC (tree, TYPE_VECTOR_SUBPARTS (type));
- unsigned HOST_WIDE_INT idx, pos = 0;
- tree value;
-
- FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), idx, value)
- {
- if (!CONSTANT_CLASS_P (value))
- return t;
- if (TREE_CODE (value) == VECTOR_CST)
- {
- for (unsigned i = 0; i < VECTOR_CST_NELTS (value); ++i)
- vec[pos++] = VECTOR_CST_ELT (value, i);
- }
- else
- vec[pos++] = value;
- }
- for (; pos < TYPE_VECTOR_SUBPARTS (type); ++pos)
- vec[pos] = build_zero_cst (TREE_TYPE (type));
+ unsigned i;
+ tree val;
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), i, val)
+ if (! CONSTANT_CLASS_P (val))
+ return t;
- return build_vector (type, vec);
+ return build_vector_from_ctor (type, CONSTRUCTOR_ELTS (t));
}
case CONST_DECL: