From patchwork Wed Sep 25 15:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rakic X-Patchwork-Id: 1989457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=htecgroup.com header.i=@htecgroup.com header.a=rsa-sha256 header.s=selector1 header.b=PNnGlLR3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XDLMh38T0z1xst for ; Thu, 26 Sep 2024 01:32:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F886385840B for ; Wed, 25 Sep 2024 15:32:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20730.outbound.protection.outlook.com [IPv6:2a01:111:f403:2612::730]) by sourceware.org (Postfix) with ESMTPS id F13C13858D39 for ; Wed, 25 Sep 2024 15:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F13C13858D39 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=htecgroup.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=htecgroup.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F13C13858D39 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2612::730 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1727278344; cv=pass; b=wHjNMs+dfVRXPpfJG6kV8f3C46xPrPIXLzIJfsKtz/i5vpXeD6tVn3BNEag8hBnIkwZgcLwSQMXrvG2SOnIt6hQPfSeV7J+dpW/fdToyMdppW97drf/dWJwzHxAQ5ovy8cRMuQ8/OIiltPR6pPwE8fkCcxmWAF/uIcOLpn7kX7E= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1727278344; c=relaxed/simple; bh=aYpolQrvVKaPa+vYscjxc6u1zefHoShX9/iGbnVUSIg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uZX7fH56odAJ74w/x9uVyUhwv3iSoozZoSW8QsG0iim9z/o15BkEQpUHlK9IfFSenizqptTgDnmk7JJQBnVPbLA13DMxdYbUQhfr43c9oQvvyOIQzEeyePUVTgoZdnctSJmNNPoMJ54wagZT7d6K8UVHI84nf0lJWBX+rZfSDm0= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KXns+AUTs4RkouVCsCJ4etlzpNRvdV173Y8Ub50qw18oYldbH4duUs24O3ND/DGwStf5e7KskIGDqVBR7m1XXsOCWR911+4EdvH7KGK7gZjGyq4gB2gNriSf1ybwpH6kqKKsUnql0FkL60H7dxDCX5McRKDVTO9lMFrnTaTlVk0/xMcSC2n1CUbdpA8O9S/HAw7eXXki8r34DlWg0i+aCXzvGqnDTfhNaxFCrLnY/jzw0580Qt9Jsdw4rYXmZCqvSRei7JQfmtVzFTMNq1ekGVBcJzKNTt7GmczB5XnTNUwQf3m6O9XEhEVHBWQIT7wKbYRaZSoRUqgzNvEPeu1XEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sObYZ0yP04DQgtnaVqpB8YbTt3d8OrvNuaXDwSeL+qE=; b=M+HDsGuf8f+mEvnhfqOJBwlUKQoZlY3RxaVDJd7YIoeuy9Zl3F4/FHRzE6QgVsaIG19qRu9suk7zgeeNN1h3oW++VMvjLbIKGhSbd9HTVjFcF2i0j4VkOddfQwv5onyPsJSwiPu/nWelo9M6+TthiXNj7vbg9PuQ8plf81W/ecNaUuBwXD4r9kAdDCNI3szMW6crA/o7bhA1xRyGDvdOzsEM1PVH7tLqyPLeoxCy5eBwU8GCAk7ON5OyvMNxbDZ2o1afQYuD4zpIF3sVzq84AhdqqJmqBlC47X/FJ0HWPpBXCaruRLur+x4IrArafIM2mfdxVbV9OMMaj5A8nnPtQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=htecgroup.com; dmarc=pass action=none header.from=htecgroup.com; dkim=pass header.d=htecgroup.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=htecgroup.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sObYZ0yP04DQgtnaVqpB8YbTt3d8OrvNuaXDwSeL+qE=; b=PNnGlLR3gtW29H8HZynl9DhqHhnO25E54+WxE5R895yGv2dWzd/m+KGeopU7Ofn3/38wHkRlKPmTiN5gMOg4y6rxi0zjYAwOQqXtPn2Oj+diXS0uCSu0nBt+pGCju8nBf8s2uay3rtN43g1PCgcuiN/WqshuswI5hto7j8O6XXvM2b7eZuye5UpONexQ+X6OLQSADL36ippfm5rBj0T4I9/vmBlFPAIH9OnrnvQcmqKxuWZbdBa06Yw0nCz9xgahIUJBNqrwC+4PjYNibjsKRAt/vcySHk8rJ8RrFqmqyINjtmAjQzqJ4gUV4VUEncZUYZ5KWeEfiXfKwZL/xCaGYQ== Received: from PA4PR09MB4864.eurprd09.prod.outlook.com (2603:10a6:102:ed::17) by DU0PR09MB5741.eurprd09.prod.outlook.com (2603:10a6:10:31c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.25; Wed, 25 Sep 2024 15:32:13 +0000 Received: from PA4PR09MB4864.eurprd09.prod.outlook.com ([fe80::a02b:9d5c:eca5:e024]) by PA4PR09MB4864.eurprd09.prod.outlook.com ([fe80::a02b:9d5c:eca5:e024%7]) with mapi id 15.20.7982.022; Wed, 25 Sep 2024 15:32:13 +0000 From: Aleksandar Rakic To: "richard.guenther@gmail.com" CC: "gcc-patches@gcc.gnu.org" , Djordje Todorovic , Jovan Dmitrovic Subject: [Bug tree-optimization/109429] [PATCH v2] ivopts: fixed complexities Thread-Topic: [Bug tree-optimization/109429] [PATCH v2] ivopts: fixed complexities Thread-Index: AQHbD1kzYzQI38+UqEWTVNHADCeHjA== Date: Wed, 25 Sep 2024 15:32:13 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=htecgroup.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR09MB4864:EE_|DU0PR09MB5741:EE_ x-ms-office365-filtering-correlation-id: 434d56d0-da96-42e1-06d1-08dcdd773a6b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?7Mzr5jGtiWIh/E5Ax8LHrsVwMy?= =?iso-8859-1?q?4eoRzwLAwfwHyrHoG7mKOSoMs6dA/231SMjCrjWStFSzFTVCa0N+W+t1b28B?= =?iso-8859-1?q?zAXkWu1tCC32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ar0faDnFnO33vX?= =?iso-8859-1?q?WeLa1jjzxbw00SA+Bg3UrsWahD/mcgPZUwih+vwd+4620g6bKJD+Agwm6duN?= =?iso-8859-1?q?dU2gJ8x2L0VC/Vxhu/GM6H/0rEM0OV0tWkDin+sunmW7JvNJ+nnj6gryHDVf?= =?iso-8859-1?q?trcgFNy7OH/WE6nVIJsMsrOKSvcyDTucs0wbJMu0P0VFs6UBhKICzp0NwrLX?= =?iso-8859-1?q?+EA3FTLArThY31/NYxA+Sxc5ETmRjHhpk3oe5sTgRU8TGQWHPE7nppCj1jX4?= =?iso-8859-1?q?Ku9NGvHDINnCv8knpAsAucKc+GkiWotA+izQavP6zFYhetPSkiHEPMG3cIUw?= =?iso-8859-1?q?viiSX6yDagmlkkJ6z2aqg0A9XnbokY9wGUWqmV6zc4E38R71I3hh01pnDx3J?= =?iso-8859-1?q?llMgUpFR/0L6IB0VY4ylxg5ys/Y9JyKN4G1UvPZL4mjzYguEDmeb3VB6et8B?= =?iso-8859-1?q?IFitHhG+YnszA3CR7tgfhlww=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR09MB4864.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?lCy5b0IUEkdNIBBLfgdhr0C?= =?iso-8859-1?q?KpAroplFhs0bcX7kUpxlTO2nIf1+uujuzW3lHk6/rASy4EM1HG5qtQ2+plga?= =?iso-8859-1?q?QS/7XI/ZyyaljVzDBdOq0563UQ0Xfp0xPmbApgzMuIwojC19Jzj6UQ3qMt+D?= =?iso-8859-1?q?O35o/lxvcL5obhd11GDyacoOk70xgRQz/o0/PGgcjERtBz18IsN/TNCv31Rf?= =?iso-8859-1?q?QFOs2Ezf+aM2grlyMIuGVda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yDKJ9nM0f?= =?iso-8859-1?q?4rH/wkWQ450LpC3q3yh1Lde/EnbzrQ1ZCipV39FmZAC8gY6jf6a5RomSxEbF?= =?iso-8859-1?q?b8uD+ejuTONbqYyEG/gslfQ1j5HWMjyUC62zHtirpbobrtF4IjnfrEs4DRE9?= =?iso-8859-1?q?sx7Xz+S55miVCZuUW93SFD/ZsOdgT1B757269Itw0V0inIj2W+OUeX6EPxGE?= =?iso-8859-1?q?RZw2bbdeIuDMMPf8YGrAnQHHHFdqSLbe2hdi2NPmELTSqn24Nm78Ykh/NYmi?= =?iso-8859-1?q?+dYfbeQMsngIla0egQghkdK0e9eA4H/v1Tl5wEq3a90cV4/H9D0dfQ6pPBJg?= =?iso-8859-1?q?TCe4+gGzpXE3A6oIg19YxCNN0h6bxc777DMDGLXOi4c6uunRY4G6BIMex8Ai?= =?iso-8859-1?q?/G0K4MKNPXs3J6RKwOaxvxiYTkakwuPJuoj45AXvob+kabJNCgskfTH46Rd4?= =?iso-8859-1?q?/1xBzdkkPH16ztExmTgqSYgojp+cqV3C0HpFXvAa6oks3+eQvooM3eoQAnd6?= =?iso-8859-1?q?AdBIFLimK+c5vEXNCldj9oSwoYLph+faEhkaPBQ=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR09MB4864.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 434d56d0-da96-42e1-06d1-08dcdd773a6b X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Sep 2024 15:32:13.0314 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f85665b-7efd-4776-9dfe-b6bfda2565ee X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jOu/icBEp9V0o97nFkQ2uNDkIL0yTHUaxWWbohMVMEat4b9DtRqhXCmETERMkKtm/5T+w5vW3esLRX0IKvmNy4A5WRCz53qAFzE/zAZpBQI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR09MB5741 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, I think I managed to fix indentation from the previous version. When comparing the tables showing the candidates for the group 1 before and after applying this patch, it can be observed that complexities for the candidates where the computation depends on the invariant expressions or the invariant variables should be at least one, which aligns with the approach used in the commit c2b64ce. ===== Before this patch ===== Group 1: cand cost compl. inv.expr. inv.vars 1 11 0 5; NIL; 2 11 0 6; NIL; 4 8 0 7; NIL; 5 9 0 8; NIL; 6 1 0 NIL; NIL; 7 1 1 NIL; NIL; 9 7 0 5; NIL; ===== Before this patch ===== ===== After this patch ===== Group 1: cand cost compl. inv.expr. inv.vars 1 11 2 4; NIL; 2 11 1 4; NIL; 4 8 1 5; NIL; 5 8 2 6; NIL; 6 1 0 NIL; NIL; 7 1 1 NIL; NIL; 9 7 2 4; NIL; ===== After this patch ===== Hence, if the invariant expressions or the invariant variables are used when representing use with candidate, the complexity should be larger for more complex expressions, so it is incremented by one. I am not sure whether inv_present could be expressed as parts. Regards, Aleksandar From a459b8fd04608de7f6ead52f373f59a8bc5f3199 Mon Sep 17 00:00:00 2001 From: Aleksandar Date: Tue, 24 Sep 2024 13:14:37 +0200 Subject: [PATCH v2] [Bug tree-optimization/109429] ivopts: fixed complexities This patch addresses a bug introduced in commit f9f69dd by correcting the complexity calculation in ivopts. The fix involves complexity computation reordering and proper invariant variables handling in address expressions. These changes align with the approach used in parent commit c2b64ce. The improved complexity calculations ensure better candidate selection and reduced code size, particularly for RISC CPUs. Signed-off-by: Aleksandar Rakic Signed-off-by: Jovan Dmitrovic gcc/ChangeLog: * tree-ssa-loop-ivopts.cc (get_address_cost): Fixed complexity calculation. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/bug_tree-optimization_109429.c: New test. --- .../tree-ssa/bug_tree-optimization_109429.c | 32 +++++++++++ gcc/tree-ssa-loop-ivopts.cc | 56 +++++++++---------- 2 files changed, 60 insertions(+), 28 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/bug_tree-optimization_109429.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bug_tree-optimization_109429.c b/gcc/testsuite/gcc.dg/tree-ssa/bug_tree-optimization_109429.c new file mode 100644 index 00000000000..945693bd27f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bug_tree-optimization_109429.c @@ -0,0 +1,32 @@ +/* { dg-do compile { target mips64-r6-linux-gnu } } */ +/* { dg-options "-O2 -fdump-tree-ivopts-details" } */ +/* This test ensures that complexity must be greater than zero if there is + an invariant variable or an invariant expression in the address + expression. */ + +void daxpy (float *vector1, float *vector2, int n, float fp_const) +{ + for (int i = 0; i < n; ++i) + vector1[i] += fp_const * vector2[i]; +} + +void dgefa (float *vector, int m, int n, int l) +{ + for (int i = 0; i < n - 1; ++i) + { + for (int j = i + 1; j < n; ++j) + { + float t = vector[m * j + l]; + daxpy (&vector[m * i + i + 1], + &vector[m * j + i + 1], n - (i + 1), t); + } + } +} + + +/* { dg-final { scan-tree-dump-not "Processing loop 3(.*\n)*:(.*\n)*Group 1:\n Type:.*ADDRESS(.*\n)*Group 1:\n cand\tcost\tcompl\.\tinv\.expr\.\tinv\.vars\n(.*\n)*(.+\t.+\t0\t\\d+(, \\d+)*;\t.+\n)(.*\n)*Group 2:\n cand\tcost\tcompl\.\tinv\.expr\.\tinv\.vars\n(.*\n)*Selected IV set for loop 3" "ivopts" { target { mips64-r6-linux-gnu } } } } */ + + +/* { dg-final { scan-tree-dump-not "Processing loop 3(.*\n)*:(.*\n)*Group 1:\n Type:.*ADDRESS(.*\n)*Group 1:\n cand\tcost\tcompl\.\tinv\.expr\.\tinv\.vars\n(.*\n)*(.+\t.+\t0\t.+\t\\d+(, \\d+)*\n)(.*\n)*Group 2:\n cand\tcost\tcompl\.\tinv\.expr\.\tinv\.vars\n(.*\n)*Selected IV set for loop 3" "ivopts" { target { mips64-r6-linux-gnu } } } } */ + + diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc index 7cae5bdefea..960dd8be782 100644 --- a/gcc/tree-ssa-loop-ivopts.cc +++ b/gcc/tree-ssa-loop-ivopts.cc @@ -4755,38 +4755,35 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, if (!ok_with_ratio_p) parts.step = NULL_TREE; } - if (ok_with_ratio_p || ok_without_ratio_p) + if (!(ok_with_ratio_p || ok_without_ratio_p)) + parts.index = NULL_TREE; + if (maybe_ne (aff_inv->offset, 0)) { - if (maybe_ne (aff_inv->offset, 0)) - { - parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); - /* Addressing mode "base + index [<< scale] + offset". */ - if (!valid_mem_ref_p (mem_mode, as, &parts, code)) - parts.offset = NULL_TREE; - else - aff_inv->offset = 0; - } + parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); + /* Addressing mode "base[+ index[<< scale]] + offset". */ + if (!valid_mem_ref_p (mem_mode, as, &parts, code)) + parts.offset = NULL_TREE; + else + aff_inv->offset = 0; + } - move_fixed_address_to_symbol (&parts, aff_inv); - /* Base is fixed address and is moved to symbol part. */ - if (parts.symbol != NULL_TREE && aff_combination_zero_p (aff_inv)) - parts.base = NULL_TREE; + move_fixed_address_to_symbol (&parts, aff_inv); + /* Base is fixed address and is moved to symbol part. */ + if (parts.symbol != NULL_TREE && aff_combination_zero_p (aff_inv)) + parts.base = NULL_TREE; - /* Addressing mode "symbol + base + index [<< scale] [+ offset]". */ - if (parts.symbol != NULL_TREE - && !valid_mem_ref_p (mem_mode, as, &parts, code)) - { - aff_combination_add_elt (aff_inv, parts.symbol, 1); - parts.symbol = NULL_TREE; - /* Reset SIMPLE_INV since symbol address needs to be computed - outside of address expression in this case. */ - simple_inv = false; - /* Symbol part is moved back to base part, it can't be NULL. */ - parts.base = integer_one_node; - } + /* Addressing mode "symbol + base[+ index[<< scale]] [+ offset]". */ + if (parts.symbol != NULL_TREE + && !valid_mem_ref_p (mem_mode, as, &parts, code)) + { + aff_combination_add_elt (aff_inv, parts.symbol, 1); + parts.symbol = NULL_TREE; + /* Reset SIMPLE_INV since symbol address needs to be computed + outside of address expression in this case. */ + simple_inv = false; + /* Symbol part is moved back to base part, it can't be NULL. */ + parts.base = integer_one_node; } - else - parts.index = NULL_TREE; } else { @@ -4856,6 +4853,9 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, if (parts.symbol != NULL_TREE) cost.complexity += 1; + if ((inv_vars && *inv_vars && !bitmap_empty_p (*inv_vars)) + || (inv_expr && *inv_expr != NULL)) + cost.complexity += 1; /* Don't increase the complexity of adding a scaled index if it's the only kind of index that the target allows. */ if (parts.step != NULL_TREE && ok_without_ratio_p) -- 2.34.1