From patchwork Thu Jan 6 14:47:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1576142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=C8ssIs5a; dkim-atps=neutral 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV8QR1gPLz9sPC for ; Fri, 7 Jan 2022 01:49:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B4DA385841C for ; Thu, 6 Jan 2022 14:49:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B4DA385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641480589; bh=QkVMMVCPiJBG+UuSxsZ8lRWiRsZt/xx3m9i6lSbYaAw=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=C8ssIs5a7u6ke6v9Fzc7zoB9E/a5KqdbVnnUNvwxGPPZ7ukPJ6OVvgX7+j3abqPxU s6TX8rAVjiUqHqXIJN9eI/uzKSRSqsECs53LfqihiuaUDSGa2oqvgCW0/HPm1Cqx0l ijHLvsovH9JHkOqttYcGoUuBYzsa48GW8G9d1+Y4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id A68C83858012 for ; Thu, 6 Jan 2022 14:47:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A68C83858012 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 55E26142F; Thu, 6 Jan 2022 06:47:06 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D4AA13F5A1; Thu, 6 Jan 2022 06:47:05 -0800 (PST) To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, vmakarov@redhat.com, richard.sandiford@arm.com Subject: [PATCH 3/6] ira: Add ira_subloop_allocnos_can_differ_p References: Date: Thu, 06 Jan 2022 14:47:04 +0000 In-Reply-To: (Richard Sandiford's message of "Thu, 06 Jan 2022 14:45:45 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" color_pass has two instances of the same code for propagating non-cap assignments from parent loops to subloops. This patch adds a helper function for testing when such propagations are required for correctness and uses it to remove the duplicated code. A later patch will use this in ira-build.c too, which is why the function is exported to ira-int.h. No functional change intended. gcc/ PR rtl-optimization/98782 * ira-int.h (ira_subloop_allocnos_can_differ_p): New function, extracted from... * ira-color.c (color_pass): ...here. --- gcc/ira-color.c | 21 +-------------------- gcc/ira-int.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/gcc/ira-color.c b/gcc/ira-color.c index e7433312675..ae0f08af4b3 100644 --- a/gcc/ira-color.c +++ b/gcc/ira-color.c @@ -3446,26 +3446,7 @@ color_pass (ira_loop_tree_node_t loop_tree_node) if ((flag_ira_region == IRA_REGION_MIXED && (loop_tree_node->reg_pressure[pclass] <= ira_class_hard_regs_num[pclass])) - || (pic_offset_table_rtx != NULL - && regno == (int) REGNO (pic_offset_table_rtx)) - /* Avoid overlapped multi-registers. Moves between them - might result in wrong code generation. */ - || (hard_regno >= 0 - && ira_reg_class_max_nregs[pclass][mode] > 1)) - { - if (! ALLOCNO_ASSIGNED_P (subloop_allocno)) - { - ALLOCNO_HARD_REGNO (subloop_allocno) = hard_regno; - ALLOCNO_ASSIGNED_P (subloop_allocno) = true; - if (hard_regno >= 0) - update_costs_from_copies (subloop_allocno, true, true); - /* We don't need updated costs anymore. */ - ira_free_allocno_updated_costs (subloop_allocno); - } - continue; - } - ira_assert (regno < ira_reg_equiv_len); - if (ira_equiv_no_lvalue_p (regno)) + || !ira_subloop_allocnos_can_differ_p (a, hard_regno >= 0)) { if (! ALLOCNO_ASSIGNED_P (subloop_allocno)) { diff --git a/gcc/ira-int.h b/gcc/ira-int.h index b32c80d4c9e..c5b1a131abd 100644 --- a/gcc/ira-int.h +++ b/gcc/ira-int.h @@ -1595,4 +1595,32 @@ ira_loop_border_costs::move_between_loops_cost () const return move_cost * (m_entry_freq + m_exit_freq); } +/* Return true if subloops that contain allocnos for A's register can + use a different assignment from A. ALLOCATED_P is true for the case + in which allocation succeeded for A. */ +inline bool +ira_subloop_allocnos_can_differ_p (ira_allocno_t a, bool allocated_p = true) +{ + auto regno = ALLOCNO_REGNO (a); + + if (pic_offset_table_rtx != NULL + && regno == (int) REGNO (pic_offset_table_rtx)) + return false; + + ira_assert (regno < ira_reg_equiv_len); + if (ira_equiv_no_lvalue_p (regno)) + return false; + + /* Avoid overlapping multi-registers. Moves between them might result + in wrong code generation. */ + if (allocated_p) + { + auto pclass = ira_pressure_class_translate[ALLOCNO_CLASS (a)]; + if (ira_reg_class_max_nregs[pclass][ALLOCNO_MODE (a)] > 1) + return false; + } + + return true; +} + #endif /* GCC_IRA_INT_H */