aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index c9ca760..d263129 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1851,16 +1851,21 @@ make_vector (unsigned log2_npatterns,
tree
build_vector_from_ctor (tree type, vec<constructor_elt, va_gc> *v)
{
- unsigned int nelts = TYPE_VECTOR_SUBPARTS (type);
- unsigned HOST_WIDE_INT idx;
+ unsigned HOST_WIDE_INT idx, nelts;
tree value;
+ /* We can't construct a VECTOR_CST for a variable number of elements. */
+ nelts = TYPE_VECTOR_SUBPARTS (type).to_constant ();
tree_vector_builder vec (type, nelts, 1);
FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
{
if (TREE_CODE (value) == VECTOR_CST)
- for (unsigned i = 0; i < VECTOR_CST_NELTS (value); ++i)
- vec.quick_push (VECTOR_CST_ELT (value, i));
+ {
+ /* If NELTS is constant then this must be too. */
+ unsigned int sub_nelts = VECTOR_CST_NELTS (value).to_constant ();
+ for (unsigned i = 0; i < sub_nelts; ++i)
+ vec.quick_push (VECTOR_CST_ELT (value, i));
+ }
else
vec.quick_push (value);
}
@@ -1872,9 +1877,9 @@ build_vector_from_ctor (tree type, vec<constructor_elt, va_gc> *v)
/* Build a vector of type VECTYPE where all the elements are SCs. */
tree
-build_vector_from_val (tree vectype, tree sc)
+build_vector_from_val (tree vectype, tree sc)
{
- int i, nunits = TYPE_VECTOR_SUBPARTS (vectype);
+ unsigned HOST_WIDE_INT i, nunits;
if (sc == error_mark_node)
return sc;
@@ -1894,7 +1899,7 @@ build_vector_from_val (tree vectype, tree sc)
v.quick_push (sc);
return v.build ();
}
- else if (0)
+ else if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits))
return fold_build1 (VEC_DUPLICATE_EXPR, vectype, sc);
else
{
@@ -6497,11 +6502,8 @@ type_hash_canon_hash (tree type)
}
case VECTOR_TYPE:
- {
- unsigned nunits = TYPE_VECTOR_SUBPARTS (type);
- hstate.add_object (nunits);
- break;
- }
+ hstate.add_poly_int (TYPE_VECTOR_SUBPARTS (type));
+ break;
default:
break;
@@ -6545,7 +6547,8 @@ type_cache_hasher::equal (type_hash *a, type_hash *b)
return 1;
case VECTOR_TYPE:
- return TYPE_VECTOR_SUBPARTS (a->type) == TYPE_VECTOR_SUBPARTS (b->type);
+ return known_eq (TYPE_VECTOR_SUBPARTS (a->type),
+ TYPE_VECTOR_SUBPARTS (b->type));
case ENUMERAL_TYPE:
if (TYPE_VALUES (a->type) != TYPE_VALUES (b->type)
@@ -9610,7 +9613,7 @@ make_vector_type (tree innertype, poly_int64 nunits, machine_mode mode)
t = make_node (VECTOR_TYPE);
TREE_TYPE (t) = mv_innertype;
- SET_TYPE_VECTOR_SUBPARTS (t, nunits.to_constant ()); /* Temporary */
+ SET_TYPE_VECTOR_SUBPARTS (t, nunits);
SET_TYPE_MODE (t, mode);
if (TYPE_STRUCTURAL_EQUALITY_P (mv_innertype) || in_lto_p)
@@ -10533,7 +10536,7 @@ build_vector_type_for_mode (tree innertype, machine_mode mode)
a power of two. */
tree
-build_vector_type (tree innertype, int nunits)
+build_vector_type (tree innertype, poly_int64 nunits)
{
return make_vector_type (innertype, nunits, VOIDmode);
}
@@ -10578,7 +10581,7 @@ build_same_sized_truth_vector_type (tree vectype)
/* Similarly, but builds a variant type with TYPE_VECTOR_OPAQUE set. */
tree
-build_opaque_vector_type (tree innertype, int nunits)
+build_opaque_vector_type (tree innertype, poly_int64 nunits)
{
tree t = make_vector_type (innertype, nunits, VOIDmode);
tree cand;
@@ -10727,7 +10730,7 @@ tree
uniform_vector_p (const_tree vec)
{
tree first, t;
- unsigned i;
+ unsigned HOST_WIDE_INT i, nelts;
if (vec == NULL_TREE)
return NULL_TREE;
@@ -10744,7 +10747,8 @@ uniform_vector_p (const_tree vec)
return NULL_TREE;
}
- else if (TREE_CODE (vec) == CONSTRUCTOR)
+ else if (TREE_CODE (vec) == CONSTRUCTOR
+ && TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec)).is_constant (&nelts))
{
first = error_mark_node;
@@ -10758,7 +10762,7 @@ uniform_vector_p (const_tree vec)
if (!operand_equal_p (first, t, 0))
return NULL_TREE;
}
- if (i != TYPE_VECTOR_SUBPARTS (TREE_TYPE (vec)))
+ if (i != nelts)
return NULL_TREE;
return first;
@@ -13034,8 +13038,8 @@ vector_type_mode (const_tree t)
/* For integers, try mapping it to a same-sized scalar mode. */
if (is_int_mode (TREE_TYPE (t)->type_common.mode, &innermode))
{
- unsigned int size = (TYPE_VECTOR_SUBPARTS (t)
- * GET_MODE_BITSIZE (innermode));
+ poly_int64 size = (TYPE_VECTOR_SUBPARTS (t)
+ * GET_MODE_BITSIZE (innermode));
scalar_int_mode mode;
if (int_mode_for_size (size, 0).exists (&mode)
&& have_regs_of_mode[mode])
@@ -14319,7 +14323,7 @@ test_labels ()
static tree
build_vector (tree type, vec<tree> vals MEM_STAT_DECL)
{
- gcc_assert (vals.length () == TYPE_VECTOR_SUBPARTS (type));
+ gcc_assert (known_eq (vals.length (), TYPE_VECTOR_SUBPARTS (type)));
tree_vector_builder builder (type, vals.length (), 1);
builder.splice (vals);
return builder.build ();
@@ -14330,7 +14334,8 @@ build_vector (tree type, vec<tree> vals MEM_STAT_DECL)
static void
check_vector_cst (vec<tree> expected, tree actual)
{
- ASSERT_EQ (expected.length (), TYPE_VECTOR_SUBPARTS (TREE_TYPE (actual)));
+ ASSERT_KNOWN_EQ (expected.length (),
+ TYPE_VECTOR_SUBPARTS (TREE_TYPE (actual)));
for (unsigned int i = 0; i < expected.length (); ++i)
ASSERT_EQ (wi::to_wide (expected[i]),
wi::to_wide (vector_cst_elt (actual, i)));