diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-09-14 15:25:57 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-09-14 15:25:57 +0000 |
commit | 9e822269364f5268b2bdc82530fd6c871f47b1bc (patch) | |
tree | c7de33f186c199c790259d0bdb8d0d743b5309da /gcc/expr.c | |
parent | 2a94be35291a8564154cd213f73b7e302e3f3b80 (diff) | |
download | gcc-9e822269364f5268b2bdc82530fd6c871f47b1bc.zip gcc-9e822269364f5268b2bdc82530fd6c871f47b1bc.tar.gz gcc-9e822269364f5268b2bdc82530fd6c871f47b1bc.tar.bz2 |
Store VECTOR_CST_NELTS directly in tree_node
Previously VECTOR_CST_NELTS (t) read the number of elements from
TYPE_VECTOR_SUBPARTS (TREE_TYPE (t)). There were two ways of handling
this with variable TYPE_VECTOR_SUBPARTS: either forcibly convert the
number to a constant (which is doable) or store the number directly
in the VECTOR_CST. The latter seemed better, since it involves less
pointer chasing and since the tree_node u field is otherwise unused
for VECTOR_CST. It would still be easy to switch to the former in
future if we need to free up the field for someting else.
The patch also changes various bits of VECTOR_CST code to use
VECTOR_CST_NELTS instead of TYPE_VECTOR_SUBPARTS when iterating
over VECTOR_CST_ELTs. Also, when the two are checked for equality,
the patch prefers to read VECTOR_CST_NELTS (which must be constant)
and check against TYPE_VECTOR_SUBPARTS, instead of the other way
around.
2017-09-14 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* tree-core.h (tree_base::u): Add an "nelts" field.
(tree_vector): Use VECTOR_CST_NELTS as the length.
* tree.c (tree_size): Likewise.
(make_vector): Initialize VECTOR_CST_NELTS.
* tree.h (VECTOR_CST_NELTS): Use the u.nelts field.
* cfgexpand.c (expand_debug_expr): Use VECTOR_CST_NELTS instead of
TYPE_VECTOR_SUBPARTS.
* expr.c (const_vector_mask_from_tree): Consistently use "units"
as the number of units, setting it from VECTOR_CST_NELTS.
(const_vector_from_tree): Likewise.
* fold-const.c (negate_expr_p): Use VECTOR_CST_NELTS instead of
TYPE_VECTOR_SUBPARTS for the number of elements in a VECTOR_CST.
(fold_negate_expr_1): Likewise.
(fold_convert_const): Likewise.
(const_binop): Likewise. Differentiate the number of output and
input elements.
(const_unop): Likewise.
(fold_ternary_loc): Use VECTOR_CST_NELTS for the number of elements
in a VECTOR_CST, asserting that it is the same as TYPE_VECTOR_SUBPARTS
in cases that did the opposite.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r252758
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -11700,18 +11700,17 @@ static rtx const_vector_mask_from_tree (tree exp) { rtvec v; - unsigned i; - int units; + unsigned i, units; tree elt; machine_mode inner, mode; mode = TYPE_MODE (TREE_TYPE (exp)); - units = GET_MODE_NUNITS (mode); + units = VECTOR_CST_NELTS (exp); inner = GET_MODE_INNER (mode); v = rtvec_alloc (units); - for (i = 0; i < VECTOR_CST_NELTS (exp); ++i) + for (i = 0; i < units; ++i) { elt = VECTOR_CST_ELT (exp, i); @@ -11756,8 +11755,7 @@ static rtx const_vector_from_tree (tree exp) { rtvec v; - unsigned i; - int units; + unsigned i, units; tree elt; machine_mode inner, mode; @@ -11769,12 +11767,12 @@ const_vector_from_tree (tree exp) if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))) return const_vector_mask_from_tree (exp); - units = GET_MODE_NUNITS (mode); + units = VECTOR_CST_NELTS (exp); inner = GET_MODE_INNER (mode); v = rtvec_alloc (units); - for (i = 0; i < VECTOR_CST_NELTS (exp); ++i) + for (i = 0; i < units; ++i) { elt = VECTOR_CST_ELT (exp, i); |