From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id C7E163857C48 for ; Thu, 7 Jan 2021 13:18:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C7E163857C48 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A81BAAD12; Thu, 7 Jan 2021 13:18:38 +0000 (UTC) Date: Thu, 7 Jan 2021 14:18:38 +0100 (CET) From: Richard Biener To: Tamar Christina cc: gcc-patches@gcc.gnu.org, nd@arm.com, ook@ucw.cz Subject: Re: [PATCH 4/8 v9]middle-end slp: upgrade complex add to new format and fix memory leaks In-Reply-To: <20201228133701.GA25150@arm.com> Message-ID: References: <20201228133701.GA25150@arm.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2021 13:18:41 -0000 On Mon, 28 Dec 2020, Tamar Christina wrote: > 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? OK. Thanks, Richard. > 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 *); > }; > > @@ -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 *); > > static vect_pattern* > recognize (slp_tree_to_load_perm_map_t *, slp_tree *); > + > + static vect_pattern* > + mkInstance (slp_tree *node, vec *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 *ops) > + slp_tree *node, vec *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 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); > > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)