Implement more rtx vector folds on variable-length vectors

Programming / Compilers / GCC - rsandifo [138bc75d-0d04-0410-961f-82ee72b054a4] - 29 July 2019 08:40 EDT

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

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.

f3ff423503d Implement more rtx vector folds on variable-length vectors
gcc/ChangeLog | 32 +++++++
gcc/int-vector-builder.h | 9 +-
gcc/rtx-vector-builder.h | 16 +++-
gcc/simplify-rtx.c | 139 ++++++++++++++++++++++++------
gcc/tree-vector-builder.c | 97 ---------------------
gcc/tree-vector-builder.h | 20 +++--
gcc/vector-builder.h | 209 ++++++++++++++++++++++++++++++++++++++--------
7 files changed, 350 insertions(+), 172 deletions(-)

Upstream: gcc.gnu.org


  • Share