From patchwork Tue Jan 11 17:42:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 49880 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 5ECD6385801C for ; Tue, 11 Jan 2022 17:43:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5ECD6385801C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641923011; bh=uC8Le41aL2oaamJVZs+c79v2nG1H0/Sg++SP41Pir10=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QWOihFhcUE/aQlq7fwcgxoPpIYPdOtjPhx26z3p76isDDohe38bEZq5tMVJrE8bFV z71H8LvoAgOYHfqXzl10KnOEwTqUc236i1kn13KdSdYzkqKoL1A4pcoYjwYM6jSGo0 gEW5QdRPtZYq2+QNAst4UDf24Gz9c1Uufvg0ggwc= 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 702B43858D39 for ; Tue, 11 Jan 2022 17:43:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 702B43858D39 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 E7186D6E; Tue, 11 Jan 2022 09:43:00 -0800 (PST) Received: from localhost (unknown [10.32.98.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 70B8C3F766; Tue, 11 Jan 2022 09:43:00 -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] ira: Fix old-reload targets [PR103974] Date: Tue, 11 Jan 2022 17:42:59 +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.4 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The new IRA heuristics would need more work on old-reload targets, since flattening needs to be able to undo the cost propagation. It's doable, but hardly seems worth it. This patch therefore makes all the new calls to ira_subloop_allocnos_can_differ_p return false if !ira_use_lra_p. The color_pass code that predated the new function (and that was the source of ira_subloop_allocnos_can_differ_p) continues to behave as before. It's a hack, but at least it has the advantage that the new parameter would become obviously unused if reload and (!)ira_use_lra_p were removed. The hack should therefore disappear alongside reload. Tested on aarch64-linux-gnu and cris-elf. OK to install? Richard gcc/ PR rtl-optimization/103974 * ira-int.h (ira_subloop_allocnos_can_differ_p): Take an extra argument, default true, that says whether old-reload targets should be excluded. * ira-color.c (color_pass): Pass false. --- gcc/ira-color.c | 3 ++- gcc/ira-int.h | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/ira-color.c b/gcc/ira-color.c index 36f3f4d70f3..59d978fe9b3 100644 --- a/gcc/ira-color.c +++ b/gcc/ira-color.c @@ -3664,7 +3664,8 @@ color_pass (ira_loop_tree_node_t loop_tree_node) ira_assert (bitmap_bit_p (subloop_node->all_allocnos, ALLOCNO_NUM (subloop_allocno))); if (ira_single_region_allocno_p (a, subloop_allocno) - || !ira_subloop_allocnos_can_differ_p (a, hard_regno >= 0)) + || !ira_subloop_allocnos_can_differ_p (a, hard_regno >= 0, + false)) { gcc_assert (!ALLOCNO_MIGHT_CONFLICT_WITH_PARENT_P (subloop_allocno)); diff --git a/gcc/ira-int.h b/gcc/ira-int.h index e1e68025211..e80fdeb0328 100644 --- a/gcc/ira-int.h +++ b/gcc/ira-int.h @@ -1607,10 +1607,16 @@ ira_loop_border_costs::move_between_loops_cost () const /* 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. */ + in which allocation succeeded for A. EXCLUDE_OLD_RELOAD is true if + we should always return false for non-LRA targets. (This is a hack + and should be removed along with old reload.) */ inline bool -ira_subloop_allocnos_can_differ_p (ira_allocno_t a, bool allocated_p = true) +ira_subloop_allocnos_can_differ_p (ira_allocno_t a, bool allocated_p = true, + bool exclude_old_reload = true) { + if (exclude_old_reload && !ira_use_lra_p) + return false; + auto regno = ALLOCNO_REGNO (a); if (pic_offset_table_rtx != NULL