aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-02 18:28:06 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-02 18:28:06 +0000
commit3d8ca53dd9b4c42b07ef974f92c3c4553cce3a79 (patch)
treea24895a3e9e27d5d1711474f8246f92559d37b64 /gcc
parent3877c560656f4961cc50952c3bba3c40812c36c3 (diff)
downloadgcc-3d8ca53dd9b4c42b07ef974f92c3c4553cce3a79.zip
gcc-3d8ca53dd9b4c42b07ef974f92c3c4553cce3a79.tar.gz
gcc-3d8ca53dd9b4c42b07ef974f92c3c4553cce3a79.tar.bz2
Make more use of rtx_vector_builder
This patch makes various bits of CONST_VECTOR-building code use rtx_vector_builder, operating directly on a specific encoding. 2018-01-02 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * expr.c: Include rtx-vector-builder.h. (const_vector_mask_from_tree): Use rtx_vector_builder and operate directly on the tree encoding. (const_vector_from_tree): Likewise. * optabs.c: Include rtx-vector-builder.h. (expand_vec_perm_var): Use rtx_vector_builder and create a repeating sequence of "u" values. * vec-perm-indices.c: Include rtx-vector-builder.h. (vec_perm_indices_to_rtx): Use rtx_vector_builder and operate directly on the vec_perm_indices encoding. From-SVN: r256103
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/expr.c63
-rw-r--r--gcc/optabs.c10
-rw-r--r--gcc/vec-perm-indices.c12
4 files changed, 50 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bff9ff5..32396b9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,18 @@
2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
+ * expr.c: Include rtx-vector-builder.h.
+ (const_vector_mask_from_tree): Use rtx_vector_builder and operate
+ directly on the tree encoding.
+ (const_vector_from_tree): Likewise.
+ * optabs.c: Include rtx-vector-builder.h.
+ (expand_vec_perm_var): Use rtx_vector_builder and create a repeating
+ sequence of "u" values.
+ * vec-perm-indices.c: Include rtx-vector-builder.h.
+ (vec_perm_indices_to_rtx): Use rtx_vector_builder and operate
+ directly on the vec_perm_indices encoding.
+
+2018-01-02 Richard Sandiford <richard.sandiford@linaro.org>
+
* doc/rtl.texi (const_vector): Describe new encoding scheme.
* Makefile.in (OBJS): Add rtx-vector-builder.o.
* rtx-vector-builder.h: New file.
diff --git a/gcc/expr.c b/gcc/expr.c
index 74a3280..a84c02f 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-chkp.h"
#include "rtl-chkp.h"
#include "ccmp.h"
+#include "rtx-vector-builder.h"
/* If this is nonzero, we do not bother generating VOLATILE
@@ -11797,32 +11798,25 @@ try_tablejump (tree index_type, tree index_expr, tree minval, tree range,
static rtx
const_vector_mask_from_tree (tree exp)
{
- rtvec v;
- unsigned i, units;
- tree elt;
- machine_mode inner, mode;
-
- mode = TYPE_MODE (TREE_TYPE (exp));
- units = VECTOR_CST_NELTS (exp);
- inner = GET_MODE_INNER (mode);
-
- v = rtvec_alloc (units);
+ machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
+ machine_mode inner = GET_MODE_INNER (mode);
- for (i = 0; i < units; ++i)
+ rtx_vector_builder builder (mode, VECTOR_CST_NPATTERNS (exp),
+ VECTOR_CST_NELTS_PER_PATTERN (exp));
+ unsigned int count = builder.encoded_nelts ();
+ for (unsigned int i = 0; i < count; ++i)
{
- elt = VECTOR_CST_ELT (exp, i);
-
+ tree elt = VECTOR_CST_ELT (exp, i);
gcc_assert (TREE_CODE (elt) == INTEGER_CST);
if (integer_zerop (elt))
- RTVEC_ELT (v, i) = CONST0_RTX (inner);
+ builder.quick_push (CONST0_RTX (inner));
else if (integer_onep (elt)
|| integer_minus_onep (elt))
- RTVEC_ELT (v, i) = CONSTM1_RTX (inner);
+ builder.quick_push (CONSTM1_RTX (inner));
else
gcc_unreachable ();
}
-
- return gen_rtx_CONST_VECTOR (mode, v);
+ return builder.build ();
}
/* EXP is a VECTOR_CST in which each element is either all-zeros or all-ones.
@@ -11852,12 +11846,7 @@ const_scalar_mask_from_tree (scalar_int_mode mode, tree exp)
static rtx
const_vector_from_tree (tree exp)
{
- rtvec v;
- unsigned i, units;
- tree elt;
- machine_mode inner, mode;
-
- mode = TYPE_MODE (TREE_TYPE (exp));
+ machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
if (initializer_zerop (exp))
return CONST0_RTX (mode);
@@ -11865,27 +11854,25 @@ const_vector_from_tree (tree exp)
if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp)))
return const_vector_mask_from_tree (exp);
- units = VECTOR_CST_NELTS (exp);
- inner = GET_MODE_INNER (mode);
-
- v = rtvec_alloc (units);
+ machine_mode inner = GET_MODE_INNER (mode);
- for (i = 0; i < units; ++i)
+ rtx_vector_builder builder (mode, VECTOR_CST_NPATTERNS (exp),
+ VECTOR_CST_NELTS_PER_PATTERN (exp));
+ unsigned int count = builder.encoded_nelts ();
+ for (unsigned int i = 0; i < count; ++i)
{
- elt = VECTOR_CST_ELT (exp, i);
-
+ tree elt = VECTOR_CST_ELT (exp, i);
if (TREE_CODE (elt) == REAL_CST)
- RTVEC_ELT (v, i) = const_double_from_real_value (TREE_REAL_CST (elt),
- inner);
+ builder.quick_push (const_double_from_real_value (TREE_REAL_CST (elt),
+ inner));
else if (TREE_CODE (elt) == FIXED_CST)
- RTVEC_ELT (v, i) = CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt),
- inner);
+ builder.quick_push (CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt),
+ inner));
else
- RTVEC_ELT (v, i) = immed_wide_int_const (wi::to_poly_wide (elt),
- inner);
+ builder.quick_push (immed_wide_int_const (wi::to_poly_wide (elt),
+ inner));
}
-
- return gen_rtx_CONST_VECTOR (mode, v);
+ return builder.build ();
}
/* Build a decl for a personality function given a language prefix. */
diff --git a/gcc/optabs.c b/gcc/optabs.c
index dcd94cd..c3ee454 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "emit-rtl.h"
#include "recog.h"
#include "diagnostic-core.h"
+#include "rtx-vector-builder.h"
/* Include insn-config.h before expr.h so that HAVE_conditional_move
is properly defined. */
@@ -5609,7 +5610,6 @@ expand_vec_perm_var (machine_mode mode, rtx v0, rtx v1, rtx sel, rtx target)
enum insn_code icode;
unsigned int i, w, u;
rtx tmp, sel_qi;
- rtvec vec;
w = GET_MODE_SIZE (mode);
u = GET_MODE_UNIT_SIZE (mode);
@@ -5661,10 +5661,10 @@ expand_vec_perm_var (machine_mode mode, rtx v0, rtx v1, rtx sel, rtx target)
/* Add the byte offset to each byte element. */
/* Note that the definition of the indicies here is memory ordering,
so there should be no difference between big and little endian. */
- vec = rtvec_alloc (w);
- for (i = 0; i < w; ++i)
- RTVEC_ELT (vec, i) = GEN_INT (i % u);
- tmp = gen_rtx_CONST_VECTOR (qimode, vec);
+ rtx_vector_builder byte_indices (qimode, u, 1);
+ for (i = 0; i < u; ++i)
+ byte_indices.quick_push (GEN_INT (i));
+ tmp = byte_indices.build ();
sel_qi = expand_simple_binop (qimode, PLUS, sel, tmp,
sel, 0, OPTAB_DIRECT);
gcc_assert (sel_qi != NULL);
diff --git a/gcc/vec-perm-indices.c b/gcc/vec-perm-indices.c
index 3eb9c41..8b6f412 100644
--- a/gcc/vec-perm-indices.c
+++ b/gcc/vec-perm-indices.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see
#include "memmodel.h"
#include "emit-rtl.h"
#include "selftest.h"
+#include "rtx-vector-builder.h"
/* Switch to a new permutation vector that selects between NINPUTS vector
inputs that have NELTS_PER_INPUT elements each. Take the elements of the
@@ -223,11 +224,12 @@ vec_perm_indices_to_rtx (machine_mode mode, const vec_perm_indices &indices)
{
gcc_assert (GET_MODE_CLASS (mode) == MODE_VECTOR_INT
&& GET_MODE_NUNITS (mode) == indices.length ());
- unsigned int nelts = indices.length ();
- rtvec v = rtvec_alloc (nelts);
- for (unsigned int i = 0; i < nelts; ++i)
- RTVEC_ELT (v, i) = gen_int_mode (indices[i], GET_MODE_INNER (mode));
- return gen_rtx_CONST_VECTOR (mode, v);
+ rtx_vector_builder sel (mode, indices.encoding ().npatterns (),
+ indices.encoding ().nelts_per_pattern ());
+ unsigned int encoded_nelts = sel.encoded_nelts ();
+ for (unsigned int i = 0; i < encoded_nelts; i++)
+ sel.quick_push (gen_int_mode (indices[i], GET_MODE_INNER (mode)));
+ return sel.build ();
}
#if CHECKING_P