diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2018-01-03 09:01:52 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-01-03 09:01:52 +0000 |
commit | 0ecc2b7db7480fa33d31d95a114b024809cb6883 (patch) | |
tree | 9003f8b5836a2167c157e9007befcc84ae24a173 /gcc/vector-builder.h | |
parent | 6b0630fbe8c34255f2739f63a8d3e5b636020bf4 (diff) | |
download | gcc-0ecc2b7db7480fa33d31d95a114b024809cb6883.zip gcc-0ecc2b7db7480fa33d31d95a114b024809cb6883.tar.gz gcc-0ecc2b7db7480fa33d31d95a114b024809cb6883.tar.bz2 |
poly_int: vector_builder element count
This patch changes the number of elements in a vector being built
by a vector_builder from unsigned int to poly_uint64. The case
in which it isn't a constant is the one that motivated adding
the vector encoding in the first place.
2018-01-03 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* vector-builder.h (vector_builder::m_full_nelts): Change from
unsigned int to poly_uint64.
(vector_builder::full_nelts): Update prototype accordingly.
(vector_builder::new_vector): Likewise.
(vector_builder::encoded_full_vector_p): Handle polynomial full_nelts.
(vector_builder::operator ==): Likewise.
(vector_builder::finalize): Likewise.
* int-vector-builder.h (int_vector_builder::int_vector_builder):
Take the number of elements as a poly_uint64 rather than an
unsigned int.
* vec-perm-indices.h (vec_perm_indices::m_nelts_per_input): Change
from unsigned int to poly_uint64.
(vec_perm_indices::vec_perm_indices): Update prototype accordingly.
(vec_perm_indices::new_vector): Likewise.
(vec_perm_indices::length): Likewise.
(vec_perm_indices::nelts_per_input): Likewise.
(vec_perm_indices::input_nelts): Likewise.
* vec-perm-indices.c (vec_perm_indices::new_vector): Take the
number of elements per input as a poly_uint64 rather than an
unsigned int. Use the original encoding for variable-length
vectors, rather than clamping each individual element.
For the second and subsequent elements in each pattern,
clamp the step and base before clamping their sum.
(vec_perm_indices::series_p): Handle polynomial element counts.
(vec_perm_indices::all_in_range_p): Likewise.
(vec_perm_indices_to_tree): Likewise.
(vec_perm_indices_to_rtx): Likewise.
* tree-vect-stmts.c (vect_gen_perm_mask_any): Likewise.
* tree-vector-builder.c (tree_vector_builder::new_unary_operation)
(tree_vector_builder::new_binary_operation): Handle polynomial
element counts. Return false if we need to know the number
of elements at compile time.
* fold-const.c (fold_vec_perm): Punt if the number of elements
isn't known at compile time.
From-SVN: r256165
Diffstat (limited to 'gcc/vector-builder.h')
-rw-r--r-- | gcc/vector-builder.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gcc/vector-builder.h b/gcc/vector-builder.h index 939709c..f8b6146 100644 --- a/gcc/vector-builder.h +++ b/gcc/vector-builder.h @@ -90,7 +90,7 @@ class vector_builder : public auto_vec<T, 32> public: vector_builder (); - unsigned int full_nelts () const { return m_full_nelts; } + poly_uint64 full_nelts () const { return m_full_nelts; } unsigned int npatterns () const { return m_npatterns; } unsigned int nelts_per_pattern () const { return m_nelts_per_pattern; } unsigned int encoded_nelts () const; @@ -103,7 +103,7 @@ public: void finalize (); protected: - void new_vector (unsigned int, unsigned int, unsigned int); + void new_vector (poly_uint64, unsigned int, unsigned int); void reshape (unsigned int, unsigned int); bool repeating_sequence_p (unsigned int, unsigned int, unsigned int); bool stepped_sequence_p (unsigned int, unsigned int, unsigned int); @@ -115,7 +115,7 @@ private: Derived *derived () { return static_cast<Derived *> (this); } const Derived *derived () const; - unsigned int m_full_nelts; + poly_uint64 m_full_nelts; unsigned int m_npatterns; unsigned int m_nelts_per_pattern; }; @@ -152,7 +152,7 @@ template<typename T, typename Derived> inline bool vector_builder<T, Derived>::encoded_full_vector_p () const { - return m_npatterns * m_nelts_per_pattern == m_full_nelts; + return known_eq (m_npatterns * m_nelts_per_pattern, m_full_nelts); } /* Start building a vector that has FULL_NELTS elements. Initially @@ -160,7 +160,7 @@ vector_builder<T, Derived>::encoded_full_vector_p () const template<typename T, typename Derived> void -vector_builder<T, Derived>::new_vector (unsigned int full_nelts, +vector_builder<T, Derived>::new_vector (poly_uint64 full_nelts, unsigned int npatterns, unsigned int nelts_per_pattern) { @@ -178,7 +178,7 @@ template<typename T, typename Derived> bool vector_builder<T, Derived>::operator == (const Derived &other) const { - if (m_full_nelts != other.m_full_nelts + if (maybe_ne (m_full_nelts, other.m_full_nelts) || m_npatterns != other.m_npatterns || m_nelts_per_pattern != other.m_nelts_per_pattern) return false; @@ -356,14 +356,16 @@ vector_builder<T, Derived>::finalize () { /* The encoding requires the same number of elements to come from each pattern. */ - gcc_assert (m_full_nelts % m_npatterns == 0); + gcc_assert (multiple_p (m_full_nelts, m_npatterns)); /* Allow the caller to build more elements than necessary. For example, it's often convenient to build a stepped vector from the natural encoding of three elements even if the vector itself only has two. */ - if (m_full_nelts <= encoded_nelts ()) + unsigned HOST_WIDE_INT const_full_nelts; + if (m_full_nelts.is_constant (&const_full_nelts) + && const_full_nelts <= encoded_nelts ()) { - m_npatterns = m_full_nelts; + m_npatterns = const_full_nelts; m_nelts_per_pattern = 1; } @@ -435,9 +437,10 @@ vector_builder<T, Derived>::finalize () would be for 2-bit elements. We'll have treated them as duplicates in the loop above. */ if (m_nelts_per_pattern == 1 - && this->length () >= m_full_nelts + && m_full_nelts.is_constant (&const_full_nelts) + && this->length () >= const_full_nelts && (m_npatterns & 3) == 0 - && stepped_sequence_p (m_npatterns / 4, m_full_nelts, + && stepped_sequence_p (m_npatterns / 4, const_full_nelts, m_npatterns / 4)) { reshape (m_npatterns / 4, 3); |