From: Tamar Christina Date: Mon, 11 Jan 2021 09:58:36 +0000 (+0000) Subject: slp: upgrade complex add to new format and fix memory leaks X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c18faac3fb407d182dfa82426d1be7cce587926;p=gcc.git slp: upgrade complex add to new format and fix memory leaks 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. 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. --- diff --git a/gcc/tree-vect-slp-patterns.c b/gcc/tree-vect-slp-patterns.c index 4bead9a0b47..3903cdb1169 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);