The following turns the union into a class hierarchy. One completed
SLP_TREE_TYPE could move into the base class.
* tree-vect-slp.cc (_slp_tree::_slp_tree): Adjust.
(_slp_tree::~_slp_tree): Likewise.
* tree-vectorizer.h (vect_data): New base class.
(_slp_tree::u): Remove.
(_slp_tree::data): Add pointer to vect_data.
---
gcc/tree-vect-slp.cc | 4 +++-
gcc/tree-vectorizer.h | 12 +++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 4b8c8e802cd..949243bcc10 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -131,7 +131,7 @@ _slp_tree::_slp_tree ()
this->max_nunits = 1;
this->lanes = 0;
SLP_TREE_TYPE (this) = undef_vec_info_type;
- this->u.undef = NULL;
+ this->data = NULL;
}
/* Tear down a SLP node. */
@@ -153,6 +153,8 @@ _slp_tree::~_slp_tree ()
SLP_TREE_SIMD_CLONE_INFO (this).release ();
if (this->failed)
free (failed);
+ if (this->data)
+ delete this->data;
}
/* Push the single SSA definition in DEF to the vector of vector defs. */
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 2d618f4c221..f6fe9a28f34 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -239,6 +239,10 @@ typedef auto_vec<std::pair<unsigned, unsigned>, 16>
auto_lane_permutation_t;
typedef vec<unsigned> load_permutation_t;
typedef auto_vec<unsigned, 16> auto_load_permutation_t;
+struct vect_data {
+ virtual ~vect_data () = default;
+};
+
/* A computation tree of an SLP instance. Each node corresponds to a group of
stmts to be packed in a SIMD stmt. */
struct _slp_tree {
@@ -305,12 +309,10 @@ struct _slp_tree {
for loop vectorization. */
vect_memory_access_type memory_access_type;
- /* The kind of operation as determined by analysis and a tagged
- union with kind specific data. */
+ /* The kind of operation as determined by analysis and optional
+ kind specific data. */
enum stmt_vec_info_type type;
- union {
- void *undef;
- } u;
+ vect_data *data;
/* If not NULL this is a cached failed SLP discovery attempt with
the lanes that failed during SLP discovery as 'false'. This is
--
2.43.0