diff options
author | Richard Biener <rguenther@suse.de> | 2025-07-30 11:19:03 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2025-08-01 09:28:05 +0200 |
commit | 7a08afbc784ad41263e3cc3d039be631254183bc (patch) | |
tree | 55f197b89bcff62c62aabd7643287129271c841b /gcc | |
parent | d8fc7bce9cf722aa73782ba66a74646c8ae545cc (diff) | |
download | gcc-7a08afbc784ad41263e3cc3d039be631254183bc.zip gcc-7a08afbc784ad41263e3cc3d039be631254183bc.tar.gz gcc-7a08afbc784ad41263e3cc3d039be631254183bc.tar.bz2 |
Use a class hierarchy for vect specific data
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.
(_slp_tree::get_data): New helper template.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/tree-vect-slp.cc | 4 | ||||
-rw-r--r-- | gcc/tree-vectorizer.h | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index a9c7105..2335432 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 095db66..6081ca4 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,13 @@ 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; + + template <class T> + T& get_data (T& else_) { return data ? *static_cast <T *> (data) : else_; } /* If not NULL this is a cached failed SLP discovery attempt with the lanes that failed during SLP discovery as 'false'. This is |