From patchwork Mon May 27 17:54:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 1940067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axis.com header.i=@axis.com header.a=rsa-sha256 header.s=selector1 header.b=XgEmAXFZ; 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 4Vp3F96gzWz20Pb for ; Tue, 28 May 2024 03:54:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 341CA384979B for ; Mon, 27 May 2024 17:54:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2049.outbound.protection.outlook.com [40.107.15.49]) by sourceware.org (Postfix) with ESMTPS id C1610384770C for ; Mon, 27 May 2024 17:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1610384770C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C1610384770C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.15.49 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1716832454; cv=pass; b=Rj3MmhmubtKBDmaFA/1OGXhip+3/l+Z9SriIdcjtfKgVVAnCF9MoD6b2F/L+jyAFv+MAhmyj7cxWXsafM2bcscCMHWatfeqV3XUQDHso4vljwzmlXEbsWtIENkGRqcG1G86RJfNzk8VZYtVH8e+A0ARYvEV1y9nnMK0HCeaXNgE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1716832454; c=relaxed/simple; bh=Q2To83q79f+SbKWcSRNHXQOGOYVvJg4F6gfK55YD3JY=; h=DKIM-Signature:From:To:Subject:MIME-Version:Message-ID:Date; b=lEzlEE621Fu9UfskQElI4gcneXKwXtAtqyWEqIdeRDojN4MSxPr3KaXn0WIwdJXtQCmBx1+eSiFczc+ejCQNt1G+QaZtNyQyMaZK8fjtYYlhwxplgJPjVXxkA3b5svapFIIgZWcgNZtE1NrNXA/k4qrYC1c+N8iNy0g+If6G00Y= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JOM/q6EpPAKhl4wVj+iY5xbseNTRD+aAEdL4nPppIY4OTAtdaN0KWwM0nCiODpZgp7GunDEI2OId/X9JNDgAFrFLCDspmi3XySPMFT87/UF6YfU4I2+3uxD7Q5WnMT1Ci/FlQCE5uEQ5gZSDM/awzRiXQh3BzHXwlyDJME9I6KANHxD71Mck32bHexASghX+4r3xEQIM3D4mZaOIoorxfJ1cMrBN5UgYvDg3/hbbzrYkY4v6arjpT1C+swUy4Fd2iKGYh2FaqfOEg1VgOyCycnSMg/vni69Vh+BfcrAqqbNGutWXKKg4vO3u9mHgW0atafxCOo4UKmvfPSiYNS44EQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Yzbc8+GclI/kEHjHerKtRoIaxxS1n2pQ4KXGq7o8q8M=; b=MqkgJibDC5UUWljpP82eu6UuxL8VnR5ZheeFISnd417CSduHPJ7aoY9QmSnXiQoff3XOyLUVIXptMRkzwlefJZhvOZ2UexKmsaX6Y3LsQWaEdjKRebDLvcIbTT5MdET8K3Vt+1CTEKahzsykTzDpP1c8TUHpzL8f5MGW88BArAokCEEUXLzxKuJglJ0oLzKisL47EYuxLq7d83fmHZU5WaL/cHH8UmUq3WNUVE/XsxEIjkwWAePj/hpTY63+t7N1M8w82ZSpa7ePMskhs2dkf3ec5iePsiLVGCEmLOHPZewx3PteASnFa1pG7RXxKHfJqNseSwQmOSQCniNFIrfRuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Yzbc8+GclI/kEHjHerKtRoIaxxS1n2pQ4KXGq7o8q8M=; b=XgEmAXFZPxa8HY6mjClJSdhLFeCt6O/cOV+KMbublM5GhC5PgvS9hlkZLR711XgPHT/0DQtd9FrFFde/xibz1/uRUhqui04lBHqnr2hcKJjVw6Ks7MnQfQCmAxW8iCKDpUKirL8V9Ii1cdQlBXIldPWtwGKB5TYzBVkSAPf2JdQ= Received: from AM0PR06CA0139.eurprd06.prod.outlook.com (2603:10a6:208:ab::44) by DB9PR02MB6940.eurprd02.prod.outlook.com (2603:10a6:10:221::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Mon, 27 May 2024 17:54:10 +0000 Received: from AMS0EPF000001A4.eurprd05.prod.outlook.com (2603:10a6:208:ab:cafe::bb) by AM0PR06CA0139.outlook.office365.com (2603:10a6:208:ab::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.29 via Frontend Transport; Mon, 27 May 2024 17:54:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AMS0EPF000001A4.mail.protection.outlook.com (10.167.16.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Mon, 27 May 2024 17:54:10 +0000 Received: from SE-MAIL21W.axis.com (10.20.40.16) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 27 May 2024 19:54:10 +0200 Received: from se-mail02w.axis.com (10.20.40.8) by SE-MAIL21W.axis.com (10.20.40.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 27 May 2024 19:54:10 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 27 May 2024 19:54:10 +0200 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 0BF649C9; Mon, 27 May 2024 19:54:10 +0200 (CEST) Received: by pchp3.se.axis.com (Postfix, from userid 171) id EFF8920433; Mon, 27 May 2024 19:54:06 +0200 (CEST) From: Hans-Peter Nilsson To: Subject: [PATCH 4/4] resource.cc: Remove redundant conditionals MIME-Version: 1.0 Message-ID: <20240527175406.EFF8920433@pchp3.se.axis.com> Date: Mon, 27 May 2024 19:54:06 +0200 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A4:EE_|DB9PR02MB6940:EE_ X-MS-Office365-Filtering-Correlation-Id: 98845038-fc4d-43a1-0d70-08dc7e760334 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?q?yf+e0GxAfWC7fK3dNA0lNu7K5Q?= =?iso-8859-1?q?gjXAPrh5X8usDRDyXkta0uIVroAJJOd2QVGrpG4YAm3X8sTvJMQ8w1bKppLk?= =?iso-8859-1?q?8KcO/14nAnjIYUQtgnUOVoM7r5BjgoK7vMA45DxKEsxISVm4/nHKOeGrhkPI?= =?iso-8859-1?q?Vin9Sy1uPx7AZ2nfpSZ148EfKSeH8RxYhfM5okT6EGBZdLw0VVDSK2CYIDeT?= =?iso-8859-1?q?8vpYRlchen154GWqhX/00GCU045r7gFMcVJWnQYwlkgjLPK5U8KsM+6dYSYU?= =?iso-8859-1?q?IRUclxgOX5NJlYZhBl5ddjXRwtq77xuCgzwbHMlT0g29a/rrlwwAXMEDhDTV?= =?iso-8859-1?q?uppk+WDUzm7TfrIkrlZ/xQl88mwcfS+Nu3y9xpGHavIfsU1urPxOy3KduBdv?= =?iso-8859-1?q?ArmzpQHAXZy/CA3EgJExrmmLWtf+GqtrV/Zsnw1CslMxoPnm1YRMUJp/Ng3W?= =?iso-8859-1?q?iHpuF0TgLn0/Te0hytOex2nSxFBhUu2tZiYytfQe5e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1?q?RDYArWwvYqU61vigSB1TdlwBA4mxLKs0z0kuf+QiEyejUo71/3NMSzH/NoeT?= =?iso-8859-1?q?vM?= X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(82310400017)(1800799015)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2024 17:54:10.4282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98845038-fc4d-43a1-0d70-08dc7e760334 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A4.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR02MB6940 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Regtested cris-elf. Ok to commit? -- >8 -- No functional change. - We always have a target_hash_table and bb_ticks because init_resource_info is always called. These conditionals are an ancient artifact: it's been quite a while since resource.cc was used elsewhere than exclusively from reorg.cc - In mark_target_live_regs, get rid of a now-redundant "if (tinfo != NULL)" conditional and replace an "if (bb)" with a gcc_assert. A "git diff -wb" (ignore whitespace diff) is better at showing the actual changes. * resource.cc (free_resource_info, clear_hashed_info_for_insn): Don't check for non-null target_hash_table and bb_ticks. (mark_target_live_regs): Ditto. Replace check for non-NULL result from BLOCK_FOR_INSN with a call to gcc_assert. Fold code conditioned on tinfo != NULL. --- gcc/resource.cc | 123 ++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 71 deletions(-) diff --git a/gcc/resource.cc b/gcc/resource.cc index 62bd46f786eb..7c1de8864327 100644 --- a/gcc/resource.cc +++ b/gcc/resource.cc @@ -658,49 +658,42 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource res->cc = 0; /* See if we have computed this value already. */ - if (target_hash_table != NULL) - { - for (tinfo = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; - tinfo; tinfo = tinfo->next) - if (tinfo->uid == INSN_UID (target)) - break; - - /* Start by getting the basic block number. If we have saved - information, we can get it from there unless the insn at the - start of the basic block has been deleted. */ - if (tinfo && tinfo->block != -1 - && ! BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, tinfo->block))->deleted ()) - b = tinfo->block; - } + for (tinfo = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; + tinfo; tinfo = tinfo->next) + if (tinfo->uid == INSN_UID (target)) + break; + + /* Start by getting the basic block number. If we have saved + information, we can get it from there unless the insn at the + start of the basic block has been deleted. */ + if (tinfo && tinfo->block != -1 + && ! BB_HEAD (BASIC_BLOCK_FOR_FN (cfun, tinfo->block))->deleted ()) + b = tinfo->block; if (b == -1) b = BLOCK_FOR_INSN (target)->index; gcc_assert (b != -1); - if (target_hash_table != NULL) + if (tinfo) { - if (tinfo) + /* If the information is up-to-date, use it. Otherwise, we will + update it below. */ + if (b == tinfo->block && tinfo->bb_tick == bb_ticks[b]) { - /* If the information is up-to-date, use it. Otherwise, we will - update it below. */ - if (b == tinfo->block && tinfo->bb_tick == bb_ticks[b]) - { - res->regs = tinfo->live_regs; - return; - } - } - else - { - /* Allocate a place to put our results and chain it into the - hash table. */ - tinfo = XNEW (struct target_info); - tinfo->uid = INSN_UID (target); - tinfo->block = b; - tinfo->next - = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; - target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME] = tinfo; + res->regs = tinfo->live_regs; + return; } } + else + { + /* Allocate a place to put our results and chain it into the hash + table. */ + tinfo = XNEW (struct target_info); + tinfo->uid = INSN_UID (target); + tinfo->block = b; + tinfo->next = target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME]; + target_hash_table[INSN_UID (target) % TARGET_HASH_PRIME] = tinfo; + } CLEAR_HARD_REG_SET (pending_dead_regs); @@ -825,13 +818,12 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource to be live here still are. The fallthrough edge may have left a live register uninitialized. */ bb = BLOCK_FOR_INSN (real_insn); - if (bb) - { - HARD_REG_SET extra_live; + gcc_assert (bb); - REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb)); - current_live_regs |= extra_live; - } + HARD_REG_SET extra_live; + + REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb)); + current_live_regs |= extra_live; } /* The beginning of the epilogue corresponds to the end of the @@ -847,10 +839,8 @@ mark_target_live_regs (rtx_insn *insns, rtx target_maybe_return, struct resource { tinfo->block = b; tinfo->bb_tick = bb_ticks[b]; + tinfo->live_regs = res->regs; } - - if (tinfo != NULL) - tinfo->live_regs = res->regs; } /* Initialize the resources required by mark_target_live_regs (). @@ -939,31 +929,25 @@ init_resource_info (rtx_insn *epilogue_insn) void free_resource_info (void) { - if (target_hash_table != NULL) + int i; + + for (i = 0; i < TARGET_HASH_PRIME; ++i) { - int i; + struct target_info *ti = target_hash_table[i]; - for (i = 0; i < TARGET_HASH_PRIME; ++i) + while (ti) { - struct target_info *ti = target_hash_table[i]; - - while (ti) - { - struct target_info *next = ti->next; - free (ti); - ti = next; - } + struct target_info *next = ti->next; + free (ti); + ti = next; } - - free (target_hash_table); - target_hash_table = NULL; } - if (bb_ticks != NULL) - { - free (bb_ticks); - bb_ticks = NULL; - } + free (target_hash_table); + target_hash_table = NULL; + + free (bb_ticks); + bb_ticks = NULL; free_bb_for_insn (); } @@ -975,16 +959,13 @@ clear_hashed_info_for_insn (rtx_insn *insn) { struct target_info *tinfo; - if (target_hash_table != NULL) - { - for (tinfo = target_hash_table[INSN_UID (insn) % TARGET_HASH_PRIME]; - tinfo; tinfo = tinfo->next) - if (tinfo->uid == INSN_UID (insn)) - break; + for (tinfo = target_hash_table[INSN_UID (insn) % TARGET_HASH_PRIME]; + tinfo; tinfo = tinfo->next) + if (tinfo->uid == INSN_UID (insn)) + break; - if (tinfo) - tinfo->block = -1; - } + if (tinfo) + tinfo->block = -1; } /* Clear any hashed information that we have stored for instructions