#include "cfganal.h"
#include "tree-eh.h"
#include "tree-cfg.h"
+#include "alloc-pool.h"
static bool vectorizable_slp_permutation (vec_info *, gimple_stmt_iterator *,
slp_tree, stmt_vector_for_cost *);
-object_allocator<_slp_tree> *slp_tree_pool;
+static object_allocator<_slp_tree> *slp_tree_pool;
+static slp_tree slp_first_node;
+
+void
+vect_slp_init (void)
+{
+ slp_tree_pool = new object_allocator<_slp_tree> ("SLP nodes");
+}
+
+void
+vect_slp_fini (void)
+{
+ while (slp_first_node)
+ delete slp_first_node;
+ delete slp_tree_pool;
+ slp_tree_pool = NULL;
+}
void *
_slp_tree::operator new (size_t n)
_slp_tree::_slp_tree ()
{
+ this->prev_node = NULL;
+ if (slp_first_node)
+ slp_first_node->prev_node = this;
+ this->next_node = slp_first_node;
+ slp_first_node = this;
SLP_TREE_SCALAR_STMTS (this) = vNULL;
SLP_TREE_SCALAR_OPS (this) = vNULL;
SLP_TREE_VEC_STMTS (this) = vNULL;
_slp_tree::~_slp_tree ()
{
+ if (this->prev_node)
+ this->prev_node->next_node = this->next_node;
+ else
+ slp_first_node = this->next_node;
+ if (this->next_node)
+ this->next_node->prev_node = this->prev_node;
SLP_TREE_CHILDREN (this).release ();
SLP_TREE_SCALAR_STMTS (this).release ();
SLP_TREE_SCALAR_OPS (this).release ();
if (vect_loops_num <= 1)
return 0;
- slp_tree_pool = new object_allocator<_slp_tree> ("SLP nodes for vect");
+ vect_slp_init ();
if (cfun->has_simduid_loops)
note_simd_array_uses (&simd_array_to_simduid_htab);
shrink_simd_arrays (simd_array_to_simduid_htab, simduid_to_vf_htab);
delete simduid_to_vf_htab;
cfun->has_simduid_loops = false;
- delete slp_tree_pool;
- slp_tree_pool = NULL;
+ vect_slp_fini ();
if (num_vectorized_loops > 0)
{
}
}
- slp_tree_pool = new object_allocator<_slp_tree> ("SLP nodes for slp");
+ vect_slp_init ();
vect_slp_function (fun);
- delete slp_tree_pool;
- slp_tree_pool = NULL;
+ vect_slp_fini ();
if (!in_loop_pipeline)
{
#include "tree-data-ref.h"
#include "tree-hash-traits.h"
#include "target.h"
-#include "alloc-pool.h"
/* Used for naming of new temporaries. */
************************************************************************/
typedef struct _slp_tree *slp_tree;
-extern object_allocator<_slp_tree> *slp_tree_pool;
-
/* 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 {
/* Return memory to slp_tree_pool. */
static void operator delete (void *, size_t);
+
+ /* Linked list of nodes to release when we free the slp_tree_pool. */
+ slp_tree next_node;
+ slp_tree prev_node;
};
/* The enum describes the type of operations that an SLP instance
extern tree cse_and_gimplify_to_preheader (loop_vec_info, tree);
/* In tree-vect-slp.c. */
+extern void vect_slp_init (void);
+extern void vect_slp_fini (void);
extern void vect_free_slp_instance (slp_instance);
extern bool vect_transform_slp_perm_load (vec_info *, slp_tree, vec<tree>,
gimple_stmt_iterator *, poly_uint64,