From patchwork Sun Jul 14 11:02:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 93906 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 CB7E8386182F for ; Sun, 14 Jul 2024 11:06:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omggw7020-vm0.mail.djm.yahoo.co.jp (omggw7020-vm0.mail.djm.yahoo.co.jp [183.79.55.45]) by sourceware.org (Postfix) with ESMTPS id 15754385843B for ; Sun, 14 Jul 2024 11:05:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15754385843B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=yahoo.co.jp Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yahoo.co.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 15754385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=183.79.55.45 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720955137; cv=none; b=uEvoLrmcrby+lIoQhp+wX26VidHBnO/FO2r+bNwYfUtiTlbtXlBcXMeC2qNgpx4WUNPHahaBrQamkYg7EdonYyxrkjpDXofr0DuPDXHjRyi5sQOZIPbzROIswuO9kadrMHARSn4DSw+akRhRIJrdP6CLPhD0+q3hWe4a8x8mcNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720955137; c=relaxed/simple; bh=pZAjd/nJbqt3MlbhgLdwn4Cri3XtcOqj54izynYg99Y=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=qCM8DBpeqt8n4lMMFw17xIEy0+diKANGTKZix3UlcppnSJryQz3GK6c6r45KnSnwt1NTtAvsNK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Fh2mXV8nED_BOjbDVb8quRGz1NveV04ebjkfkYnPVJ6J9dtYjYyb2 c7IJ.uDxm8jFTBuJTIA02yMCgspr__ZnAV2V5g5Ni42biMXLh6sJJDLWr54rgfzQK104fQ5V2dzA Hop6qrh3fYME6Tf.Q1yfFxDUPSUY8Fwz7xn9hCt0D0TacI0QLjP6sHVb45r29gFUrLvb.EqSxrAN fZwYC2.pPoweIwiMohMlV0ICeUnkPvz.M7KqPm6bJVTv29ujPI_1Tb2y4rxWGmY3bmz6IJ1huKt8 3PvNE8hhQnIf3W98qN.r5 Received: from sonicgw.mail.yahoo.co.jp by sonicconh5001.mail.kks.yahoo.co.jp with HTTP; Sun, 14 Jul 2024 11:05:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1720954934; s=yj20110701; d=yahoo.co.jp; h=References:Content-Transfer-Encoding:Content-Type:Subject:From:Cc:To:MIME-Version:Date:Message-ID; bh=7qzXeQVV/mXw3RxFO+8YIApCTLtiyU3Qdez2DdaUE1s=; b=N2NaWDYL0mk/wfxA7FeLxZN3/NRiPcQLjRxOqng46Sfd+LonZdhwbZLDrFPDlxIb EnRrGo7qRp5SDTzMCexQRdkCKoHJ0Ra2u+7JMwa+M76ip/t2AzJkjwIvXvSjZRw8Sh2 CzugfCkL/6b2IpIZNrmWJvncPcLUSwVW9ErzGnvA= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:Cc:From:Content-Type:Content-Transfer-Encoding:References; b=bvLHXxiQkg8pNvQ4AiVBeFHL03q9bTFb1mgraTgbMloQfvBLocQekpCYkL7ABzcI FEAVl+4gzIjfUIGrhpL/zSmktUF7PB4cwm0DudQwjLVcIHQVzHeVHhRE3d6SuY5nmD4 ZH9Y06zjFFDEeDkUMWwRNk5lPE6aAwbXcSDTLMpI=; Received: by smtphe5006.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID a4f833217a8b1d6937e26585f0e18643; Sun, 14 Jul 2024 20:05:30 +0900 (JST) Message-ID: <37683bf9-4056-443b-9255-8a4168fa92c7@yahoo.co.jp> Date: Sun, 14 Jul 2024 20:02:14 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches@gcc.gnu.org Cc: Max Filippov From: Takayuki 'January June' Suwa Subject: [PATCH v2 1/3] xtensa: Resurrect LEAF_REGISTERS and LEAF_REG_REMAP References: <37683bf9-4056-443b-9255-8a4168fa92c7.ref@yahoo.co.jp> X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, SPF_HELO_NONE, 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~patchwork=sourceware.org@gcc.gnu.org They were once mistakenly removed with "xtensa: Remove old broken tweak for leaf function", but caused unwanted register spills. gcc/ChangeLog: * config/xtensa/xtensa.h (LEAF_REGISTERS, LEAF_REG_REMAP): Withdraw the removal. * config/xtensa/xtensa.cc (xtensa_leaf_regs): Ditto. --- gcc/config/xtensa/xtensa.cc | 11 +++++++++++ gcc/config/xtensa/xtensa.h | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index d49d224466a..099213f0994 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -113,6 +113,17 @@ struct GTY(()) machine_function hash_map *litpool_usage; }; +/* Vector, indexed by hard register number, which contains 1 for a + register that is allowable in a candidate for leaf function + treatment. */ +const char xtensa_leaf_regs[FIRST_PSEUDO_REGISTER] = +{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1 +}; + static void xtensa_option_override (void); static enum internal_test map_test_to_internal_test (enum rtx_code); static rtx gen_int_relational (enum rtx_code, rtx, rtx); diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index 86802343152..3bff973fd88 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -253,6 +253,18 @@ along with GCC; see the file COPYING3. If not see } #define ADJUST_REG_ALLOC_ORDER xtensa_adjust_reg_alloc_order () +/* For Xtensa, the only point of this is to prevent GCC from otherwise + giving preference to call-used registers. To minimize window + overflows for the AR registers, we want to give preference to the + lower-numbered AR registers. For other register files, which are + not windowed, we still prefer call-used registers, if there are any. */ +extern const char xtensa_leaf_regs[FIRST_PSEUDO_REGISTER]; +#define LEAF_REGISTERS xtensa_leaf_regs + +/* For Xtensa, no remapping is necessary, but this macro must be + defined if LEAF_REGISTERS is defined. */ +#define LEAF_REG_REMAP(REGNO) ((int) (REGNO)) + /* Internal macros to classify a register number. */ /* 16 address registers + fake registers */ From patchwork Sun Jul 14 11:03:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takayuki 'January June' Suwa X-Patchwork-Id: 93907 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 DB5C8384DD25 for ; Sun, 14 Jul 2024 11:06:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omggw7018-vm0.mail.djm.yahoo.co.jp (omggw7018-vm0.mail.djm.yahoo.co.jp [183.79.55.19]) by sourceware.org (Postfix) with ESMTPS id 595FB385C6D1 for ; Sun, 14 Jul 2024 11:05:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 595FB385C6D1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=yahoo.co.jp Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yahoo.co.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 595FB385C6D1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=183.79.55.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720955142; cv=none; b=Y1+VyAWitsYridxJ6EVQemJxK428LSRDl7MYOUMSnSC8k+E7RnK0DJDH9BD7iJ134AM0z7rxhe443LXV/ShTm7pOxgOHCEhcLfCy6FEA1BhDPjG6YNHXVRtKbgcYtKUQFZuMAR7X0SH92J6llqnBwKCkgUr/QhCPhLOS6ap9mZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720955142; c=relaxed/simple; bh=1UerAIun11YPPhL9/ieUHADn5/jDUFoQqmyjs4ckl/w=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=YfvqQKPazf1S1kd88wxp6hblZIDX86j+o0jsf6EUQ6UKfAiPwsi9j9VNT4xseaZYLsiQIealo4nfDmLr4UBCtvMFxYXIvhuI71GYI8Efe/u0KVwckzjKZ3mqbNaqkxWSpCPUmekKmWS6++Ry+V9ZJFhWNuin07Mg/RRjm2KM6CA= ARC-Authentication-Results: i=1; server2.sourceware.org X-YMail-OSG: xNJzfjAVM1mMp9OAxygvkfL.XdboPlAib8uFjg01tm2UBrDO3a2sIHAppl_Ykhl _NGm.K6z8b7LvXoBTRlmbr7mOT1eD2a.TPAwv3JagFDCCVyMRDMn7QEVhXh66DzAfvbj.nYfrmcZ yRD_io4LwPOeP1U4s4f6dUU.MmfO2vF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.co.jp by sonicconh5003.mail.kks.yahoo.co.jp with HTTP; Sun, 14 Jul 2024 11:05:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1720954993; s=yj20110701; d=yahoo.co.jp; h=References:Content-Transfer-Encoding:Content-Type:Subject:From:Cc:To:MIME-Version:Date:Message-ID; bh=cd2SdfY3/jFaEbvAQJBaQ4Spebm2wjxpcEw2cfRbUm0=; b=cYcwmGwI6jvpOXpNEA06bvcMPY12T2nr9yfYRyoJK2DSaVZIEqGRmhDYC59vq/Xg FgP8bV7sLK+yP9J9JUFSxER2UemV/QnCCrcgYtVtic9xs1KYe1oIBAim+qWwBrfe/Kq uKf5lWOqLl/HxaZHZKwwqvC4tF3MZfb2Zzg6P5c8= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:Cc:From:Content-Type:Content-Transfer-Encoding:References; b=OmA8i9OJLeKX7qs8E3ozHswBL/EqJPUis5n2qKsryurPHS+KMxmB4//Fe3I8jZBm GUgpXnaJj6xs/UVZhqwNfRABbzxs+HN0c8xhJ+r6Md3kOYarg5HVtuReRCFeKnAxcPr FTjKmSHGmfqAIfcoGsRWJOnF7E4p9Ku5sUv5YIGU=; Received: by smtphe5006.mail.kks.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID a4f833217a8b1d6937e26585f0e18643; Sun, 14 Jul 2024 20:05:31 +0900 (JST) Message-ID: <02092015-c705-434f-9ebf-e2008b4e5afc@yahoo.co.jp> Date: Sun, 14 Jul 2024 20:03:13 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches@gcc.gnu.org Cc: Max Filippov From: Takayuki 'January June' Suwa Subject: [PATCH v2 2/3] xtensa: Make use of std::swap where appropriate References: <02092015-c705-434f-9ebf-e2008b4e5afc.ref@yahoo.co.jp> X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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~patchwork=sourceware.org@gcc.gnu.org No functional changes. gcc/ChangeLog: * config/xtensa/xtensa.cc (gen_int_relational, gen_float_relational): Replace tempvar-based value-swapping codes with std::swap. * config/xtensa/xtensa.md (movdi_internal, movdf_internal): Ditto. --- gcc/config/xtensa/xtensa.cc | 12 ++---------- gcc/config/xtensa/xtensa.md | 10 ++++------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 099213f0994..f0a91763feb 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -801,11 +801,7 @@ gen_int_relational (enum rtx_code test_code, /* relational test (EQ, etc) */ } else if (p_info->reverse_regs) - { - rtx temp = cmp0; - cmp0 = cmp1; - cmp1 = temp; - } + std::swap (cmp0, cmp1); return gen_rtx_fmt_ee (invert ? reverse_condition (p_info->test_code) : p_info->test_code, @@ -849,11 +845,7 @@ gen_float_relational (enum rtx_code test_code, /* relational test (EQ, etc) */ } if (reverse_regs) - { - rtx temp = cmp0; - cmp0 = cmp1; - cmp1 = temp; - } + std::swap (cmp0, cmp1); brtmp = gen_rtx_REG (CCmode, FPCC_REGNUM); emit_insn (gen_fn (brtmp, cmp0, cmp1)); diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 8709ef6d7a7..0fcbb0b7bc3 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -1215,9 +1215,8 @@ xtensa_split_operand_pair (operands, SImode); if (reg_overlap_mentioned_p (operands[0], operands[3])) { - rtx tmp; - tmp = operands[0], operands[0] = operands[1], operands[1] = tmp; - tmp = operands[2], operands[2] = operands[3], operands[3] = tmp; + std::swap (operands[0], operands[1]); + std::swap (operands[2], operands[3]); } }) @@ -1562,9 +1561,8 @@ xtensa_split_operand_pair (operands, SFmode); if (reg_overlap_mentioned_p (operands[0], operands[3])) { - rtx tmp; - tmp = operands[0], operands[0] = operands[1], operands[1] = tmp; - tmp = operands[2], operands[2] = operands[3], operands[3] = tmp; + std::swap (operands[0], operands[1]); + std::swap (operands[2], operands[3]); } })