* [PATCH] Move SLP nodes to an alloc-pool
@ 2020-10-26 15:51 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2020-10-26 15:51 UTC (permalink / raw)
To: gcc-patches
This introduces a global alloc-pool for SLP nodes to reduce overhead
on SLP allocation churn which will get worse and to eventually release
SLP cycles which will retain a refcount of one and thus are never
freed at the moment.
Bootstrap / regtest pending on x86_64-unknown-linux-gnu.
2020-10-26 Richard Biener <rguenther@suse.de>
* tree-vectorizer.h (slp_tree_pool): Declare.
(_slp_tree::operator new): Likewise.
(_slp_tree::operator delete): Likewise.
* tree-vectorizer.c (vectorize_loops): Allocate and free the
slp_tree_pool.
(pass_slp_vectorize::execute): Likewise.
* tree-vect-slp.c (slp_tree_pool): Define.
(_slp_tree::operator new): Likewise.
(_slp_tree::operator delete): Likewise.
---
gcc/tree-vect-slp.c | 17 +++++++++++++++++
gcc/tree-vectorizer.c | 9 +++++++++
gcc/tree-vectorizer.h | 9 +++++++++
3 files changed, 35 insertions(+)
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 014bcba7819..894f045c0fe 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -52,6 +52,23 @@ along with GCC; see the file COPYING3. If not see
static bool vectorizable_slp_permutation (vec_info *, gimple_stmt_iterator *,
slp_tree, stmt_vector_for_cost *);
+object_allocator<_slp_tree> *slp_tree_pool;
+
+void *
+_slp_tree::operator new (size_t n)
+{
+ gcc_assert (n == sizeof (_slp_tree));
+ return slp_tree_pool->allocate_raw ();
+}
+
+void
+_slp_tree::operator delete (void *node, size_t n)
+{
+ gcc_assert (n == sizeof (_slp_tree));
+ slp_tree_pool->remove_raw (node);
+}
+
+
/* Initialize a SLP node. */
_slp_tree::_slp_tree ()
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 778177a583b..0e08652ed10 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -1170,6 +1170,8 @@ vectorize_loops (void)
if (vect_loops_num <= 1)
return 0;
+ slp_tree_pool = new object_allocator<_slp_tree> ("SLP nodes for vect");
+
if (cfun->has_simduid_loops)
note_simd_array_uses (&simd_array_to_simduid_htab);
@@ -1292,6 +1294,8 @@ vectorize_loops (void)
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;
if (num_vectorized_loops > 0)
{
@@ -1427,8 +1431,13 @@ pass_slp_vectorize::execute (function *fun)
}
}
+ slp_tree_pool = new object_allocator<_slp_tree> ("SLP nodes for slp");
+
vect_slp_function (fun);
+ delete slp_tree_pool;
+ slp_tree_pool = NULL;
+
if (!in_loop_pipeline)
{
scev_finalize ();
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index b56073c4ee3..9c55383a3ee 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -26,6 +26,7 @@ typedef class _stmt_vec_info *stmt_vec_info;
#include "tree-data-ref.h"
#include "tree-hash-traits.h"
#include "target.h"
+#include "alloc-pool.h"
/* Used for naming of new temporaries. */
@@ -115,6 +116,8 @@ typedef hash_map<tree_operand_hash,
************************************************************************/
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 {
@@ -163,6 +166,12 @@ struct _slp_tree {
enum tree_code code;
int vertex;
+
+ /* Allocate from slp_tree_pool. */
+ static void *operator new (size_t);
+
+ /* Return memory to slp_tree_pool. */
+ static void operator delete (void *, size_t);
};
--
2.26.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-26 15:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 15:51 [PATCH] Move SLP nodes to an alloc-pool Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).