From patchwork Wed Sep 4 14:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Rakic X-Patchwork-Id: 97083 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84439385DDE1 for ; Wed, 4 Sep 2024 14:01:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20708.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::708]) by sourceware.org (Postfix) with ESMTPS id 771BF3858C41 for ; Wed, 4 Sep 2024 14:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 771BF3858C41 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 771BF3858C41 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f400:7e1a::708 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1725458461; cv=pass; b=RO7qgYuh95O+DewKC/81H1Z/gql8J40KLM3jn7cEEbvzzJPa8Is/HZzgFmfEbKj+opld+kpr1fnjFfEavZWn5h3G9L24O8886FPgHOGTMLsEhumCrudroPYm/tTdH33Nn8eTi2PVjNyPe6utUwtt6u9ua1EBCPPQd+2fZRpNsK4= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1725458461; c=relaxed/simple; bh=6MONL6vXJ/D3eCFr9UCnnOrMbGWLCKjOh4lLWz9rk+0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xsztG84fAOHBm0/P1ZIfR08GPc3KCdOXM24JMdHcA0Ef4rN1NfP0EUDtYkiYeDweqy1uloVCelN4KxT3TQPvRSGHmbMYWyw7ulYAzZcx6zGHhh072ze/+f5PISruE5TlyKGUM2NPPvTH8qhybcedQ5Hb3Lhw86rqQ4frQEqJSUg= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lCXufkaCgBuj50sazzu6lkmeBhDnHgkddEs1TItu29D1EPkKyOkKEwzUFk/CBmvlWKDCOb3nRw1htiQLzHKa2RTHP5X41WUJaTKr8t3Hr5YUkmhfNY8LdS+Coa1g8lQCVmtqURzKJ0h+RoP72V6jX4sTg/X986WsDSxVAyPT3AFkQaR354T5zBIHfcSJ8wUmNVe5RCNUrJKWKmUeWj0gvBlItZonWJtbNqySOgX+7DyPC7Xtg1iHoH2oRTS/L9Ff7i7UZ0By/zmzqo5j8ukQOglXGIUxA3CaNoHfVXcY2JautAXOQ3Q+IMC5GusezccdYuYP8WkwiV2mR5918gL4dw== 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=0h0MjFi1Xif6FUrQz6XZB2oqSlHbQ966HzR7U5QLhdw=; b=QlR7sQAUAQKkJez5UrTjDobIYJ09EpjzCigIWhE+x223/cq4kwW/a6eVnPrDr+yTitMKlRJ5PudRzHGUn5wAgyqPA9UqL8cmkvhlnTj0loFQg6u5gsfftQKZBRpfvLmxMEbC2Es28QS8EhT10Br46WHKCLNy1kHfEPhHtruV7SAOgg9vsxCdWdrO03F7ID1TSzfLKIBtEtmTFYAXBs7yNoIrsqw5vWE+kt2iGfW2fAZvTKdiiGjdchNmkIv/3aeNws8ESh7JbiIcBGeKGpzNL6COEx5oIJHBcM/Jc3fqXMHEob34bsO5peXzoB+giIMpy4RJHB6LYnsGSoppR/lxEQ== 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=0h0MjFi1Xif6FUrQz6XZB2oqSlHbQ966HzR7U5QLhdw=; b=azAM9EMVjoNHG6WonHeGbScND/17tBpUSyIBpALeucKXJvYJmlPYbwhsiEaR8yOu5NTOTViJo5MKgAQhazx+XRyHLissr4MV7n55/sasGgXJS0KdhTSSqMV3jL7hkkQvyFPnzXaM8mfBeo1kDR3NMOF1GZn/sY3ucgG3PnI3T/APGFEQNxl9XFdZz162E1aQMdeomzS9gQFUdlHzxVXY+OmZ7xO7MpOC7LI38+LTpXxpQle/SH3lU6o3jFmgNL4zdoKoVLoJsrw4YEoGIQOGQNQa3pVHX+gwuJlruMeP+VKByKF7GhrH7Yp+M2Y8olClRul8o4X/Ao9wRh/5k/oKcQ== Received: from AM6PR09MB3492.eurprd09.prod.outlook.com (2603:10a6:20b:d1::18) by VI0PR09MB6994.eurprd09.prod.outlook.com (2603:10a6:800:242::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.25; Wed, 4 Sep 2024 14:00:53 +0000 Received: from AM6PR09MB3492.eurprd09.prod.outlook.com ([fe80::7ccc:d766:7f7c:3370]) by AM6PR09MB3492.eurprd09.prod.outlook.com ([fe80::7ccc:d766:7f7c:3370%7]) with mapi id 15.20.7918.024; Wed, 4 Sep 2024 14:00:52 +0000 From: Aleksandar Rakic To: "gcc-patches@gcc.gnu.org" CC: Djordje Todorovic , Jovan Dmitrovic Subject: [Bug tree-optimization/109429] [PATCH] ivopts: fixed complexities Thread-Topic: [Bug tree-optimization/109429] [PATCH] ivopts: fixed complexities Thread-Index: AQHa/saPGyNV0/w4kUuCqHiFUZ3umg== Date: Wed, 4 Sep 2024 14:00:52 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: 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: AM6PR09MB3492:EE_|VI0PR09MB6994:EE_ x-ms-office365-filtering-correlation-id: 59b076fa-2ab1-42b7-a04b-08dccce9fd10 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?q?jkC22Ojn1HzVvSknrmzH2Ph8AE?= =?iso-8859-1?q?Hy6E0aJ9aL/3wCeuJFkSX18BESTnoJHQxSt1NuMYHqj6YJi1KU+q/B4GPnZX?= =?iso-8859-1?q?FQ9T7MmPWZ2kWwKaKwd+5fi/YVWsJG3visTt9D/SgWsIdnbHEbPGsRmKGRHV?= =?iso-8859-1?q?LxnWR8w7UF8spNZy9O5j8gD6QtxWN9Zf2X13QecdlPF8Ai1UjS9dCNuXNKlw?= =?iso-8859-1?q?t2geLZkzhHvQqf5u6Zg6cEy6VDrdaTAhNRRFgX1Af6GxrXXmQG3WIIqfmNut?= =?iso-8859-1?q?u+pklt5ZdQuAr0TlM+KFfY3B5hXxfiCbZ99CxncFeMjFbhl3VPFRuzjd6kcP?= =?iso-8859-1?q?jVVqa46qL1aT/hEl9E6etpmRARTWVnArEaCyFPghb4wV2/E8rNMDrvBPtNBt?= =?iso-8859-1?q?AY9iznDND556P61BmUR8vOpHFtsn2tXOphnfZphM0QINu76gsyKrt5cSpfJo?= =?iso-8859-1?q?c2qjfITbFtIbxBLNVsOFjDrvydWfioDyoFn3ldKiOyf4QJtJI5w3XqQ6CKvl?= =?iso-8859-1?q?b8khPBV5/ApcSz1d+sQU8+nawezWG8KsRN6a8fhmKdRwbxKsC9xBl69F/a9E?= =?iso-8859-1?q?1Y2/ZUK2BXW11T0N+ZFKQBWO6fHU4Z6VhfkYSvzWJADaf/C8Q+z5lGXn9F//?= =?iso-8859-1?q?cTDOcykWMlbNLWjtPrHf8JkbQcRaV4P8iDNYWx7TSOpeJv56/2NFVyvUMZqM?= =?iso-8859-1?q?Le9JzKTyhuWEvIvTeop2bCzoxOfLxgijazsUUTyjzgKfLVZYR6gGD4O4PDd5?= =?iso-8859-1?q?GDKK+cy/GjCrvK2K4QhxtNwY0Uv+o1Bl/9VDQkJ9DHqM/MYxvyQ56uqqz3aD?= =?iso-8859-1?q?eWY+KJ2esvT3Gof+biszKl5otvN6NEX0ryd83Mbu97P9BgOgcNsQ0MBcRYgG?= =?iso-8859-1?q?+AgKwu3maGweQpN1IpkVMRhKymgsJazr0bfBNsBRSFShRNY6oIEqOMwt5370?= =?iso-8859-1?q?MMPaBKSZJFxU9oH+BvoPmbR2rEzqPAvaqViqSU48DJWxwSJmM30HNkG3jGYd?= =?iso-8859-1?q?/5GdtYLc9WH5Hrck7outByy2SHI0uicnH45aLl2ns7J66e1AA0tCdQW5pEOd?= =?iso-8859-1?q?wFFg1FCL3NIb6PuU/6WIrLxqGRi/LkduiMNyhQL9OV8Ev6/awr5iWQ+VDb6O?= =?iso-8859-1?q?teY3pSK1IE57qcIf+/c3hoOC1MM9g6rQhNVJl4yJTZacov8dBx2BI/0bWWEM?= =?iso-8859-1?q?m5mM7BDdGaQtr5FijfYtGqQoBgzpKksWIuzhs5lIAU5w5ho00MSyvjREEstf?= =?iso-8859-1?q?d2zJOd84f5fNcQtDI4x3SCnw/5XxbtyTN7vWxvhbtY1qaHEzR2IKbY9d1EFb?= =?iso-8859-1?q?ylSWu1sHPxrPz8X9+pawIZ5lwLrCDXWYl+rZGgfAJ9jesI2ztaSl7rMlOsko?= =?iso-8859-1?q?hrHhTdOymTUq1oQVD6aB9jTMxvR4SPLfU+LOPWR0k=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR09MB3492.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?WRIVTMEJUElXI8z/DBTGZed?= =?iso-8859-1?q?tRCxxs85/n3qlgFzF1nbiWHQtS5NsEKO+6NT4/HykZ73Ubm5fI9gMeLp0pQ5?= =?iso-8859-1?q?HzHBFQburdvzxESn6zRklQJAIJqjQkKnesTG1vNhBTSrQJNg8UOBFixJmaKb?= =?iso-8859-1?q?UESnUIXD/AHi1Qvfk4SFgW/rBRPE7gLNNFb5Fe6Ypa4LD94WXM/nvzbYBwEf?= =?iso-8859-1?q?XKWABVf0kg2MYVzqZp0JElvSTNMHTDtqgb6+UspUmdZAJ6MVL3uA/1pO7NxA?= =?iso-8859-1?q?O60sJ0s9ZTZcLoMgL/mlIg46Wm1csQhPRATi2hxUXri1jKn6TgznTB7l6ZNl?= =?iso-8859-1?q?jbS7Qy347rPdkZwNW28KO7eBUYrVVNBu8BOgVB5DL1MqmjlE8XCWTv01L6Qx?= =?iso-8859-1?q?Q6ep51r1x03ZiLaR2QknFim5ji85tQiQEWgTzSHOwW5TswM/f5Bw/MbKopyY?= =?iso-8859-1?q?lvKFhvZttScDcQNBfqv14msuOrv8t8kxUmX+Ruz8TSX/uD3iC0Fu76VnDz5N?= =?iso-8859-1?q?OF6+UXW7ovr+0KPXJokMaw5YUbZGTydEUoEtzopqIemAK1LhYNP0gyusYqP/?= =?iso-8859-1?q?yNZ5XHuxaAvAnGv92L41mZf7EhwYoZAg9oBrQp5HIUNv/EtaaoWKTnRvj94C?= =?iso-8859-1?q?OEyYmoxVoqUebUpCv7trFW/iZjteNAVvduGpBeME20ztIoL1MRaQUejwAaGu?= =?iso-8859-1?q?9JKmzYkqX1dKkV8VO27Mh9Hp8feWJ9fUpInsfXwWPU12B1eVbsjZB2E1T1td?= =?iso-8859-1?q?7+lE76woli7XdmwaKUkUs8bC4cDi2LaaOUMxtzJ/4vivYmXjvO+6kt7G48gC?= =?iso-8859-1?q?vkZleMuNd7Kl/IdeNp9LDYVR5fqBW8wKQL0ZpcnlVLgLT+I2LYvyw9LwnmP3?= =?iso-8859-1?q?Y99jB90zRv8qFqAwbALLvK9lEvGajNftqFQowlxX9DvMM9kG1xdayqjDCak0?= =?iso-8859-1?q?SxR8hXJcRPu83aJQ8sDLesOiV0BMmNiTfDVbWOxORKTYcbKnWhHtuME/bqlB?= =?iso-8859-1?q?kChb47Svz7Ji+5vjbgdeGc5avJc2+3D0Cscn53lw/3LkKUimYD/0B14zyXGN?= =?iso-8859-1?q?AUkc+P1+RUtwlEV65pgELDqgh5g2t9rE79gJzxWrCO4kMFv6tn4NZTwmTU8d?= =?iso-8859-1?q?ScjdJbrC391Hfe5mY4g07jc4OyUAHN7N7VLUYZprs/vI2r62FETGsrPk1Wpj?= =?iso-8859-1?q?FlAL5aQlk5h/VVO3/UtTeJXTGCYfZ9uqr0RICPRaJHVJGCyw+iox6yDKr0eD?= =?iso-8859-1?q?du7QBU8j9u//OlrB+oIDVg3ExoJ5IjdUr/+DIeDTkkWshIO0QH+6+72erOsM?= =?iso-8859-1?q?daYEdQtUXkMJVoH5/Ru/aDZ6EBi5pX5GSNFkGoGQuufMeyoiao/xDpvIM71i?= =?iso-8859-1?q?qn/EsoOlIKPlhhuA1fqacyVvtwJaE1UUZzTpb88wqhLRw0OckDQ+au8NmZxX?= =?iso-8859-1?q?aI3PB2anc/fh3KGvRgBbH3mlX0ZxRvzX9qB6qgY3ZHyUT5h0vJXrgaPDHevi?= =?iso-8859-1?q?dS9jp19oecrZAivA6A54UMqki9YKBILUT67N/gvLB4ekSisLnmCq1d4i7dRe?= =?iso-8859-1?q?oUOdJJfpGXN3ogqIZJ9s13Avc2o0SGcPmW83tx1aDZNEx677lGWY8UlYyKzX?= =?iso-8859-1?q?3uLw+H0C8hwTMcdoOUexlvKoZSwkGjx0l+GmdBQ=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM6PR09MB3492.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59b076fa-2ab1-42b7-a04b-08dccce9fd10 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Sep 2024 14:00:52.4652 (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: LRvY8WnbyAFaYLsxiuPDEfzU3aBa0FlAf/mH81pRRwJC6hGNFohvvezOg7Y23NkM11FbsM6PEt9EC1nAGR5ZhD3R8o1HMzc9XOgesDQfZqI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR09MB6994 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, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, T_SCC_BODY_TEXT_LINE 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~patchwork=sourceware.org@gcc.gnu.org From 0130d3cb01fd9d5c1c997003245ed57bbdeb00a2 Mon Sep 17 00:00:00 2001 From: Aleksandar Date: Fri, 23 Aug 2024 11:36:50 +0200 Subject: [PATCH] [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 | 25 +++++++++++++++++++ gcc/tree-ssa-loop-ivopts.cc | 15 +++++++---- 2 files changed, 35 insertions(+), 5 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..516ce39d486 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bug_tree-optimization_109429.c @@ -0,0 +1,25 @@ +/* { 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..84c33103938 100644 --- a/gcc/tree-ssa-loop-ivopts.cc +++ b/gcc/tree-ssa-loop-ivopts.cc @@ -4733,6 +4733,7 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, /* Only true if ratio != 1. */ bool ok_with_ratio_p = false; bool ok_without_ratio_p = false; + bool inv_present = false; code_helper code = ERROR_MARK; if (use->type == USE_PTR_ADDRESS) @@ -4744,6 +4745,7 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, if (!aff_combination_const_p (aff_inv)) { + inv_present = true; parts.index = integer_one_node; /* Addressing mode "base + index". */ ok_without_ratio_p = valid_mem_ref_p (mem_mode, as, &parts, code); @@ -4755,8 +4757,8 @@ 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)) { parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); @@ -4770,7 +4772,10 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, 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; + inv_present = false; + } /* Addressing mode "symbol + base + index [<< scale] [+ offset]". */ if (parts.symbol != NULL_TREE @@ -4783,10 +4788,8 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, simple_inv = false; /* Symbol part is moved back to base part, it can't be NULL. */ parts.base = integer_one_node; + inv_present = true; } - } - else - parts.index = NULL_TREE; } else { @@ -4856,6 +4859,8 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, if (parts.symbol != NULL_TREE) cost.complexity += 1; + if (inv_present) + 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)