From: Tamar Christina <tamar.christina@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: nd@arm.com, rguenther@suse.de, ook@ucw.cz
Subject: [PATCH 4/8 v9]middle-end slp: upgrade complex add to new format and fix memory leaks
Date: Mon, 28 Dec 2020 13:37:03 +0000 [thread overview]
Message-ID: <20201228133701.GA25150@arm.com> (raw)
In-Reply-To: <patch-13956-tamar@arm.com>
[-- Attachment #1: Type: text/plain, Size: 3360 bytes --]
Hi All,
This fixes a memory leak in complex_add_pattern because I was not calling
vect_free_slp_tree when dissolving one side of the TWO_OPERANDS nodes.
Secondly it also upgrades the class to the new inteface required by the other
patterns.
Bootstrapped Regtested on aarch64-none-linux-gnu, x86_64-pc-linux-gnu
and no issues.
Ok for master?
Thanks,
Tamar
gcc/ChangeLog:
* tree-vect-slp-patterns.c (class complex_pattern,
class complex_add_pattern): Add parameters to matches.
(complex_add_pattern::build): Free memory.
(complex_add_pattern::matches): Move validation end of match.
(complex_add_pattern::recognize): Likewise.
--- inline copy of patch --
diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 235c0741c78b04f14725751ec399c0fdb32a0823..dbc58f7c53868ed431fc67de1f0162eb0d3b2c24 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -503,7 +503,7 @@ class complex_pattern : public vect_pattern
void build (vec_info *);
static internal_fn
- matches (complex_operation_t op, slp_tree_to_load_perm_map_t *,
+ matches (complex_operation_t op, slp_tree_to_load_perm_map_t *, slp_tree *,
vec<slp_tree> *);
};
@@ -608,11 +608,17 @@ class complex_add_pattern : public complex_pattern
public:
void build (vec_info *);
static internal_fn
- matches (complex_operation_t op, slp_tree_to_load_perm_map_t *,
+ matches (complex_operation_t op, slp_tree_to_load_perm_map_t *, slp_tree *,
vec<slp_tree> *);
static vect_pattern*
recognize (slp_tree_to_load_perm_map_t *, slp_tree *);
+
+ static vect_pattern*
+ mkInstance (slp_tree *node, vec<slp_tree> *m_ops, internal_fn ifn)
+ {
+ return new complex_add_pattern (node, m_ops, ifn);
+ }
};
/* Perform a replacement of the detected complex add pattern with the new
@@ -630,6 +636,11 @@ complex_add_pattern::build (vec_info *vinfo)
nodes.quick_push (children[0]);
nodes.quick_push (vect_build_swap_evenodd_node (children[1]));
+ SLP_TREE_REF_COUNT (nodes[0])++;
+ SLP_TREE_REF_COUNT (nodes[1])++;
+ vect_free_slp_tree (this->m_ops[0]);
+ vect_free_slp_tree (this->m_ops[1]);
+
SLP_TREE_CHILDREN (*this->m_node).truncate (0);
SLP_TREE_CHILDREN (*this->m_node).safe_splice (nodes);
@@ -650,7 +661,7 @@ complex_add_pattern::build (vec_info *vinfo)
internal_fn
complex_add_pattern::matches (complex_operation_t op,
slp_tree_to_load_perm_map_t *perm_cache,
- vec<slp_tree> *ops)
+ slp_tree *node, vec<slp_tree> *ops)
{
internal_fn ifn = IFN_LAST;
@@ -685,6 +696,9 @@ complex_add_pattern::matches (complex_operation_t op,
if (linear_loads_p (perm_cache, children[1]).first != PERM_ODDEVEN)
return IFN_LAST;
+ if (!vect_pattern_validate_optab (ifn, *node))
+ return IFN_LAST;
+
return ifn;
}
@@ -697,8 +711,9 @@ complex_add_pattern::recognize (slp_tree_to_load_perm_map_t *perm_cache,
auto_vec<slp_tree> ops;
complex_operation_t op
= vect_detect_pair_op (*node, true, &ops);
- internal_fn ifn = complex_add_pattern::matches (op, perm_cache, &ops);
- if (!vect_pattern_validate_optab (ifn, *node))
+ internal_fn ifn
+ = complex_add_pattern::matches (op, perm_cache, node, &ops);
+ if (ifn == IFN_LAST)
return NULL;
return new complex_add_pattern (node, &ops, ifn);
--
[-- Attachment #2: rb13959.patch --]
[-- Type: text/x-diff, Size: 2688 bytes --]
diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c
index 235c0741c78b04f14725751ec399c0fdb32a0823..dbc58f7c53868ed431fc67de1f0162eb0d3b2c24 100644
--- a/gcc/tree-vect-slp-patterns.c
+++ b/gcc/tree-vect-slp-patterns.c
@@ -503,7 +503,7 @@ class complex_pattern : public vect_pattern
void build (vec_info *);
static internal_fn
- matches (complex_operation_t op, slp_tree_to_load_perm_map_t *,
+ matches (complex_operation_t op, slp_tree_to_load_perm_map_t *, slp_tree *,
vec<slp_tree> *);
};
@@ -608,11 +608,17 @@ class complex_add_pattern : public complex_pattern
public:
void build (vec_info *);
static internal_fn
- matches (complex_operation_t op, slp_tree_to_load_perm_map_t *,
+ matches (complex_operation_t op, slp_tree_to_load_perm_map_t *, slp_tree *,
vec<slp_tree> *);
static vect_pattern*
recognize (slp_tree_to_load_perm_map_t *, slp_tree *);
+
+ static vect_pattern*
+ mkInstance (slp_tree *node, vec<slp_tree> *m_ops, internal_fn ifn)
+ {
+ return new complex_add_pattern (node, m_ops, ifn);
+ }
};
/* Perform a replacement of the detected complex add pattern with the new
@@ -630,6 +636,11 @@ complex_add_pattern::build (vec_info *vinfo)
nodes.quick_push (children[0]);
nodes.quick_push (vect_build_swap_evenodd_node (children[1]));
+ SLP_TREE_REF_COUNT (nodes[0])++;
+ SLP_TREE_REF_COUNT (nodes[1])++;
+ vect_free_slp_tree (this->m_ops[0]);
+ vect_free_slp_tree (this->m_ops[1]);
+
SLP_TREE_CHILDREN (*this->m_node).truncate (0);
SLP_TREE_CHILDREN (*this->m_node).safe_splice (nodes);
@@ -650,7 +661,7 @@ complex_add_pattern::build (vec_info *vinfo)
internal_fn
complex_add_pattern::matches (complex_operation_t op,
slp_tree_to_load_perm_map_t *perm_cache,
- vec<slp_tree> *ops)
+ slp_tree *node, vec<slp_tree> *ops)
{
internal_fn ifn = IFN_LAST;
@@ -685,6 +696,9 @@ complex_add_pattern::matches (complex_operation_t op,
if (linear_loads_p (perm_cache, children[1]).first != PERM_ODDEVEN)
return IFN_LAST;
+ if (!vect_pattern_validate_optab (ifn, *node))
+ return IFN_LAST;
+
return ifn;
}
@@ -697,8 +711,9 @@ complex_add_pattern::recognize (slp_tree_to_load_perm_map_t *perm_cache,
auto_vec<slp_tree> ops;
complex_operation_t op
= vect_detect_pair_op (*node, true, &ops);
- internal_fn ifn = complex_add_pattern::matches (op, perm_cache, &ops);
- if (!vect_pattern_validate_optab (ifn, *node))
+ internal_fn ifn
+ = complex_add_pattern::matches (op, perm_cache, node, &ops);
+ if (ifn == IFN_LAST)
return NULL;
return new complex_add_pattern (node, &ops, ifn);
next prev parent reply other threads:[~2020-12-28 13:37 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-28 13:35 [PATCH 1/8 v9]middle-end slp: Support optimizing load distribution Tamar Christina
2020-12-28 13:36 ` [PATCH 2/8 v9]middle-end slp: fix is_linear_load_p to prevent multiple answers Tamar Christina
2021-01-07 13:17 ` Richard Biener
2020-12-28 13:36 ` [PATCH 3/8 v9]middle-end slp: handle externals correctly in linear_loads_p Tamar Christina
2021-01-07 13:17 ` Richard Biener
2020-12-28 13:37 ` Tamar Christina [this message]
2021-01-07 13:18 ` [PATCH 4/8 v9]middle-end slp: upgrade complex add to new format and fix memory leaks Richard Biener
2020-12-28 13:37 ` [PATCH 5/8 v9]middle-end slp: support complex multiply and complex multiply conjugate Tamar Christina
2021-01-08 9:37 ` Richard Biener
2021-01-11 11:01 ` Tamar Christina
2021-01-11 12:04 ` Richard Biener
2020-12-28 13:37 ` [PATCH 6/8 v9]middle-end slp: support complex FMA and complex FMA conjugate Tamar Christina
2021-01-08 9:45 ` Richard Biener
2021-01-08 9:59 ` Tamar Christina
2021-01-08 10:17 ` Richard Biener
2021-01-08 10:21 ` Tamar Christina
2021-01-11 10:24 ` Tamar Christina
2020-12-28 13:38 ` [PATCH 7/8 v9]middle-end slp: support complex FMS and complex FMS conjugate Tamar Christina
2021-01-08 9:49 ` Richard Biener
2021-01-08 10:02 ` Tamar Christina
2020-12-28 13:38 ` [PATCH 8/8 v9]middle-end slp: Add complex operations class to share first match among all matchers Tamar Christina
2021-01-08 9:50 ` Richard Biener
2021-01-07 13:20 ` [PATCH 1/8 v9]middle-end slp: Support optimizing load distribution Richard Biener
2021-01-07 13:25 ` Tamar Christina
2021-01-07 13:36 ` Richard Biener
2021-01-11 11:01 ` Tamar Christina
2021-01-11 13:54 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201228133701.GA25150@arm.com \
--to=tamar.christina@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.com \
--cc=ook@ucw.cz \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).