aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vector-builder.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-07-29 08:40:21 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-07-29 08:40:21 +0000
commit4ce6ab6889446984fd7017e2150962eb4550a7ee (patch)
tree703d424c2a70fdb6d25fec4f41ba93f2545d277b /gcc/tree-vector-builder.c
parent66fafc3bf683405e6fedb4fe18dc09035b0073c2 (diff)
downloadgcc-4ce6ab6889446984fd7017e2150962eb4550a7ee.zip
gcc-4ce6ab6889446984fd7017e2150962eb4550a7ee.tar.gz
gcc-4ce6ab6889446984fd7017e2150962eb4550a7ee.tar.bz2
Implement more rtx vector folds on variable-length vectors
This patch extends the tree-level folding of variable-length vectors so that it can also be used on rtxes. The first step is to move the tree_vector_builder new_unary/binary_operator routines to the parent vector_builder class (which in turn means adding a new template parameter). The second step is to make simplify-rtx.c use a direct rtx analogue of the VECTOR_CST handling in fold-const.c. 2019-07-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * vector-builder.h (vector_builder): Add a shape template parameter. (vector_builder::new_unary_operation): New function, generalizing the old tree_vector_builder function. (vector_builder::new_binary_operation): Likewise. (vector_builder::binary_encoded_nelts): Likewise. * int-vector-builder.h (int_vector_builder): Update template parameters to vector_builder. (int_vector_builder::shape_nelts): New function. * rtx-vector-builder.h (rtx_vector_builder): Update template parameters to vector_builder. (rtx_vector_builder::shape_nelts): New function. (rtx_vector_builder::nelts_of): Likewise. (rtx_vector_builder::npatterns_of): Likewise. (rtx_vector_builder::nelts_per_pattern_of): Likewise. * tree-vector-builder.h (tree_vector_builder): Update template parameters to vector_builder. (tree_vector_builder::shape_nelts): New function. (tree_vector_builder::nelts_of): Likewise. (tree_vector_builder::npatterns_of): Likewise. (tree_vector_builder::nelts_per_pattern_of): Likewise. * tree-vector-builder.c (tree_vector_builder::new_unary_operation) (tree_vector_builder::new_binary_operation): Delete. (tree_vector_builder::binary_encoded_nelts): Likewise. * simplify-rtx.c: Include rtx-vector-builder.h. (distributes_over_addition_p): New function. (simplify_const_unary_operation) (simplify_const_binary_operation): Generalize handling of vector constants to include variable-length vectors. (test_vector_ops_series): Add more tests. From-SVN: r273867
Diffstat (limited to 'gcc/tree-vector-builder.c')
-rw-r--r--gcc/tree-vector-builder.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/gcc/tree-vector-builder.c b/gcc/tree-vector-builder.c
index f31dc13..d02fb95 100644
--- a/gcc/tree-vector-builder.c
+++ b/gcc/tree-vector-builder.c
@@ -24,103 +24,6 @@ along with GCC; see the file COPYING3. If not see
#include "fold-const.h"
#include "tree-vector-builder.h"
-/* Try to start building a new vector of type TYPE that holds the result of
- a unary operation on VECTOR_CST T. ALLOW_STEPPED_P is true if the
- operation can handle stepped encodings directly, without having to
- expand the full sequence.
-
- Return true if the operation is possible, which it always is when
- ALLOW_STEPPED_P is true. Leave the builder unchanged otherwise. */
-
-bool
-tree_vector_builder::new_unary_operation (tree type, tree t,
- bool allow_stepped_p)
-{
- poly_uint64 full_nelts = TYPE_VECTOR_SUBPARTS (type);
- gcc_assert (known_eq (full_nelts, TYPE_VECTOR_SUBPARTS (TREE_TYPE (t))));
- unsigned int npatterns = VECTOR_CST_NPATTERNS (t);
- unsigned int nelts_per_pattern = VECTOR_CST_NELTS_PER_PATTERN (t);
- if (!allow_stepped_p && nelts_per_pattern > 2)
- {
- if (!full_nelts.is_constant ())
- return false;
- npatterns = full_nelts.to_constant ();
- nelts_per_pattern = 1;
- }
- new_vector (type, npatterns, nelts_per_pattern);
- return true;
-}
-
-/* Try to start building a new vector of type TYPE that holds the result of
- a binary operation on VECTOR_CSTs T1 and T2. ALLOW_STEPPED_P is true if
- the operation can handle stepped encodings directly, without having to
- expand the full sequence.
-
- Return true if the operation is possible. Leave the builder unchanged
- otherwise. */
-
-bool
-tree_vector_builder::new_binary_operation (tree type, tree t1, tree t2,
- bool allow_stepped_p)
-{
- poly_uint64 full_nelts = TYPE_VECTOR_SUBPARTS (type);
- gcc_assert (known_eq (full_nelts, TYPE_VECTOR_SUBPARTS (TREE_TYPE (t1)))
- && known_eq (full_nelts, TYPE_VECTOR_SUBPARTS (TREE_TYPE (t2))));
- /* Conceptually we split the patterns in T1 and T2 until we have
- an equal number for both. Each split pattern requires the same
- number of elements per pattern as the original. E.g. splitting:
-
- { 1, 2, 3, ... }
-
- into two gives:
-
- { 1, 3, 5, ... }
- { 2, 4, 6, ... }
-
- while splitting:
-
- { 1, 0, ... }
-
- into two gives:
-
- { 1, 0, ... }
- { 0, 0, ... }. */
- unsigned int npatterns = least_common_multiple (VECTOR_CST_NPATTERNS (t1),
- VECTOR_CST_NPATTERNS (t2));
- unsigned int nelts_per_pattern = MAX (VECTOR_CST_NELTS_PER_PATTERN (t1),
- VECTOR_CST_NELTS_PER_PATTERN (t2));
- if (!allow_stepped_p && nelts_per_pattern > 2)
- {
- if (!full_nelts.is_constant ())
- return false;
- npatterns = full_nelts.to_constant ();
- nelts_per_pattern = 1;
- }
- new_vector (type, npatterns, nelts_per_pattern);
- return true;
-}
-
-/* Return the number of elements that the caller needs to operate on in
- order to handle a binary operation on VECTOR_CSTs T1 and T2. This static
- function is used instead of new_binary_operation if the result of the
- operation is not a VECTOR_CST. */
-
-unsigned int
-tree_vector_builder::binary_encoded_nelts (tree t1, tree t2)
-{
- poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (t1));
- gcc_assert (known_eq (nelts, TYPE_VECTOR_SUBPARTS (TREE_TYPE (t2))));
- /* See new_binary_operation for details. */
- unsigned int npatterns = least_common_multiple (VECTOR_CST_NPATTERNS (t1),
- VECTOR_CST_NPATTERNS (t2));
- unsigned int nelts_per_pattern = MAX (VECTOR_CST_NELTS_PER_PATTERN (t1),
- VECTOR_CST_NELTS_PER_PATTERN (t2));
- unsigned HOST_WIDE_INT const_nelts;
- if (nelts.is_constant (&const_nelts))
- return MIN (npatterns * nelts_per_pattern, const_nelts);
- return npatterns * nelts_per_pattern;
-}
-
/* Return a vector element with the value BASE + FACTOR * STEP. */
tree