From patchwork Mon Dec 28 13:37:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamar Christina X-Patchwork-Id: 1420867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Q9wehMOv; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D4JWn4qcxz9sjH for ; Tue, 29 Dec 2020 00:37:41 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3169D3840C22; Mon, 28 Dec 2020 13:37:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3169D3840C22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1609162658; bh=hVJARo7VQyuFGaHPDwSJLOs5HqlQtUdDWP/01QRZv2M=; h=Date:To:Subject:In-Reply-To:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Q9wehMOvV+ai+PnWFOntd8ngKetX49gmg+pVqTnV6qmi6xDVfwFufQi3WDsH1akTQ oh9/SIosqC19BKozEBrGVgDVa5mFP/3dXMkm/qp32ibTw1DmAGZ1dY9hCeNlAj4jQ2 NFVg45zNWiUBMyRuh3E60pspsLhOxLMuUjFW60H0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10075.outbound.protection.outlook.com [40.107.1.75]) by sourceware.org (Postfix) with ESMTPS id 345DF3840C17 for ; Mon, 28 Dec 2020 13:37:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 345DF3840C17 Received: from DB8PR06CA0046.eurprd06.prod.outlook.com (2603:10a6:10:120::20) by AM9PR08MB6146.eurprd08.prod.outlook.com (2603:10a6:20b:2db::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.29; Mon, 28 Dec 2020 13:37:32 +0000 Received: from DB5EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::d2) by DB8PR06CA0046.outlook.office365.com (2603:10a6:10:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Mon, 28 Dec 2020 13:37:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT013.mail.protection.outlook.com (10.152.20.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Mon, 28 Dec 2020 13:37:32 +0000 Received: ("Tessian outbound 8b6e0bb22f1c:v71"); Mon, 28 Dec 2020 13:37:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 048968f5f299d9d3 X-CR-MTA-TID: 64aa7808 Received: from 9465da4d6fa0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D84154FC-9C8A-417D-AFFA-68863427B496.1; Mon, 28 Dec 2020 13:37:13 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9465da4d6fa0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 28 Dec 2020 13:37:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=klIhdqqv31AeZUF4KzDufeSZszdL8TeLhYvQtu/f+YOaVLOu3aOh5yzhvXQbPwLJmcI8hmSVFT/5TLvrs0x7E4d3ZLAL5HmOedQkqmDj91++Gykg25mlMeax7/N3yb3FpLeQtyewaxntQTdGfHokFKthYGA8M2/BaE145czNPgUNjNfg70KiY+ZBnL6wTMsCH/hsNsyca4cdq+mbTk43yWY7c4klMK7cmAS4pwhzXcEAHYnj9X061Qixol/WMiIZQ0oUXlkvRe/S1mvVCTrn6ubTdL2CXYr9X4udwWDt0a52sSnq7Oi/SBLMrjbuw6hqbh3OM/ET1VaAL19eDdb/CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hVJARo7VQyuFGaHPDwSJLOs5HqlQtUdDWP/01QRZv2M=; b=Hs3tqOrzSGVbjZuoRA8eOShphGiP4dMmJJELuj3J8TJVb/usJs87rrgTCCtgFWOlCP+onZVffZpN7HiqCmwOVbkLec/WHz3xjs04sDzuskGdDc9QI6qwLPDpQ1obTkaR7CAPrPOiT78jI6QEW5Cv8yRu1uj7nOGVD4Jiv7knjLf+J037iORluSKMaWdvj6QKDD5xhvaap0RiSfULQ1yIK6RlEOJjm2rDXZY/yzRB7Sp/SvAy945pfdO6pZn5RIUHPDl1agY/L+qkuaVE7nIP3j8oxh1w7vvQ5wa1AIN7mt8qkwd4yUz/BvWbMOCjU7Jz8+gwZFAvtCgkNAhJRC6APw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by VE1PR08MB5135.eurprd08.prod.outlook.com (2603:10a6:803:108::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27; Mon, 28 Dec 2020 13:37:11 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::f937:5b3:12e1:8297]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::f937:5b3:12e1:8297%7]) with mapi id 15.20.3700.031; Mon, 28 Dec 2020 13:37:11 +0000 Date: Mon, 28 Dec 2020 13:37:03 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/8 v9]middle-end slp: upgrade complex add to new format and fix memory leaks Message-ID: <20201228133701.GA25150@arm.com> Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [217.140.106.53] X-ClientProxiedBy: SN6PR04CA0098.namprd04.prod.outlook.com (2603:10b6:805:f2::39) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.53) by SN6PR04CA0098.namprd04.prod.outlook.com (2603:10b6:805:f2::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.27 via Frontend Transport; Mon, 28 Dec 2020 13:37:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 69a8557e-0718-4983-7e94-08d8ab35bab0 X-MS-TrafficTypeDiagnostic: VE1PR08MB5135:|AM9PR08MB6146: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: xBSDFtOd2rXlaYjeDr/b78pIy+00yeMIJnpVv++X2mQKT4iEQ27A7IN7+LcS4VGcDlp/qOjAue6wrPd1I9D/pjZ8vAaXmcWulxIFQfQDREQ1kPDgK79JBegE0RCSAWkhz+I6v/ZA7pwfb16PPhM9D5IW3C48lYvGzgQYu8LD1XmJqcc8w3A0HhQx3LE/onf6+NIAJ3jzgbYnyI4NBylw2NW0zmUoOUTDxtELrTRWhfvWnm7a3Cii+MPkUgg9BbUNgEJaord1hHdbTJ0EFWyqfKSca4+iIxLDTC313dPzNanZP+GrGpTr28M3THMOFjZ7RfZ9FeOYHqojLGhyF+NrZ9x8i61hlEG6uKKlK4RdEFpMtJO9dADDc7nO6LwAW9ADvUO/+LUzMKLwt7Eexg7mcaOYfsZZu3zYpk9OrY/f6ikvKuBfuOI6OS8rhggXK6cB X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB5325.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(39860400002)(366004)(346002)(376002)(478600001)(44144004)(956004)(16526019)(186003)(5660300002)(8936002)(6666004)(6916009)(66476007)(66556008)(55016002)(33964004)(66946007)(66616009)(83380400001)(33656002)(2616005)(36756003)(8676002)(4743002)(52116002)(7696005)(235185007)(2906002)(86362001)(26005)(4326008)(316002)(44832011)(8886007)(1076003)(2700100001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?lfKzn7SNMgwWtzCcPOdgzea2o17UEj?= =?utf-8?q?xGP81gsHYo2OO3f4nNlA6yHcRq0NjVefiiahE/8CMKoramhR4HkPR05e2Byy9aLVV?= =?utf-8?q?1Bxea2/bYDM4Yp9VwyKUaqlyNmASnApdByo8ET+pwCmw+j4TXnjeYva+XcAeZ1ZJ+?= =?utf-8?q?7fSirv+CMmpuh6EBZDaFkx7bMHIl1qFO18+5U8DbmK4IVknykleJ/nRgUhruJhz/+?= =?utf-8?q?Vf9KtIorCO1581qI16Au5EHpfMvIbKf0ZUPgE9PLmAIGy/yEY8C3S7ai3hjcx3STD?= =?utf-8?q?11d9BjVRP116FdEvHVhLOCjfGdCpx8d9vxgRiMODLtcJRqNvDChG5+SsC3RZFUxhR?= =?utf-8?q?er0pXzCVtJu0OQJbKWpLMzgvHAaC2MnM4UKWsez9L8ZdnsMjO/67h0Fge0haeqH7G?= =?utf-8?q?ONj+a9s8xOZ5Z6a3ZUdNwQigQExP21ehuAgobpXRQkJ1aHRftmDBzz2cBvxtQAB9r?= =?utf-8?q?CmKtLH0ELNz8BYbbu7i62XwHJAfDGKCaL1AA3lYVsKW+3DNI3H8NYC92cXnwZ/AjN?= =?utf-8?q?X8yVLiJdKIR+P3Td0iMroqf91oxLNhzShJEOs0UznZlLRIQYMY+FTxDttuNJZo1Rf?= =?utf-8?q?oL7cox5nU8iSyuuScmaxPh6N+CDllY8mpiIcOc6WnBfsi7PDAkI6N4LHiMaywRppl?= =?utf-8?q?2KYqDHWaJpkXsLtaWk4TnlCAVFDYmN/rbM8TLKkci4HBG3eubwZmZ0C3Dy0SrwDB1?= =?utf-8?q?nrcG7vPBrJVMEy7pNW9TKCgTE0XkDPqfj7VXJ230+g0iYZElTwJB51QTKWrn4td+f?= =?utf-8?q?UCX8Eylf5c1Zsje0cyYV1ulj+CY4t3Rz1/WzC1Sh3NHU/AN3KaAjAYJxBt2KYRRu3?= =?utf-8?q?Y6KXbh5zmFN/Sr+sV52cD04ED4dRCUeFVDHMXnomcZ1WpQ9jotIwK7YD48lkjJIk8?= =?utf-8?q?EdwwiRXmncxwGi4fX2KbDpTCAk2YVxrAyJkfhQFBqLyTG3Uigmfd0EkGV5x5ZO2/m?= =?utf-8?q?pUO17hsKgtSsGIFhnVZ?= X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5135 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 51574dc0-664c-40c0-e634-08d8ab35ae2e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ifUdK8s8FIYiJ4tuZa8Y8NgRQu4cwznjvLiXiRDnW2eyxRjbUnE2uO6JIVqvhwdJ1wzo+NoQ1TwGvIkku4gImikpXVP3nM0Nat3EwbN+qLg1zq58ocaVzT3keKB0SbZhnajC3UmHbdKu1W7r6aTpR2gLf9T4DZbSWdiEkewUnJZJgUe7q/genvwR/Xi9e5zJSE+fSdACgJ+67XUIMCnZxwjg718QexzzomQ33Znphq4I65yJ0zYxq+RUOXVz1hWFwvZLBwFcTdEHmYqFMFbv6T2NA1zjV1FXu6X+dLTPyw4rPIzY7ehWbZmDZFqDBEKyaASECU8UFJoiXsSc+fh33nJFIEVIojQYPum/7bnBQLyvvDNkc0fFhEU+kvtkFPRW7x1X1YUj063gA+2xJRZjIXgO3nwsowJCbustw+pL+c8kSKGZTlIqCE7lxV4f5n27WF+ovC7e6QAH8wz6XX/T9Zvql9dnPZIbS8gP0OK+L6M= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(39860400002)(376002)(346002)(136003)(396003)(46966006)(356005)(1076003)(26005)(4743002)(7696005)(36756003)(44144004)(6666004)(6916009)(55016002)(82310400003)(5660300002)(8936002)(33656002)(82740400003)(8886007)(44832011)(478600001)(16526019)(956004)(336012)(4326008)(70586007)(66616009)(70206006)(86362001)(235185007)(316002)(47076005)(186003)(83380400001)(33964004)(2906002)(2616005)(81166007)(8676002)(2700100001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2020 13:37:32.6610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69a8557e-0718-4983-7e94-08d8ab35bab0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6146 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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-Patchwork-Original-From: Tamar Christina via Gcc-patches From: Tamar Christina Reply-To: Tamar Christina Cc: nd@arm.com, rguenther@suse.de, ook@ucw.cz Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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 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);