From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonicconh6002-vm2.mail.ssk.yahoo.co.jp (sonicconh6002-vm2.mail.ssk.yahoo.co.jp [182.22.37.27]) by sourceware.org (Postfix) with ESMTPS id A03873858C50 for ; Sat, 14 Jan 2023 05:04:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A03873858C50 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 X-YMail-OSG: ViafYLMVM1kCeZrolHtvvXOzcXrvk4gNAc3GZCCj3uIsrDnsFD8PejI0DzPYM7V YD9KlmGgVOaWJy0IZOWAQXsLDFrpuEdRFPSYL3Y0Wh9yYN1eysNLp6bX1WN.E0BBV2W8of3qYdnf Lo6hmVdDzvylw7.DdlwujJcqc4Z6pRR0hbvTGvSHW6pQe42w0mQUUQoQ7MNCFj_LvjAGPk6YokSF otGmB1PDhbWi_3p.EOvpF0M1Ar3.UACSMQPxEgNqIYlp_te6itCvRpZymkVPxTEWvm967bjbEmzB QxgjkpIsKWlXKaLYT9ew4gJLxv5zgrZMAzRPEi5NAg_H8Lsjcdwy2R8Pnhtd6hHs1d1FEmZ7.NRX mjXvgS5Viceo.iDxjEstEqK.ELSGLV4YymGZXjjeXADl8tLyWB3N80WroriUDl29TPD6YqV_T7SS 0En6faT2EKaAJPcIAZO0aZC.wP3_YyICoM88X3FjLtDsr192DvVFqGqSrYNmEdWC4mUYuBus6wgp 7xM9sqscNq4dcirK7pnVD6qDTuDsJEzdmNboOO32wR5FYIJM2GeAHJZ6t.b8WCFaLjR0lMs9gZYs 5bXBl_K4cQr0box1Gke2xEK4aqWGXzgkqrUL7wXzhtTiVce0GjYEzKx5f3ALqGVPB.QErLgjSjIi 3N8dggwelK2EVABDWIZbqjVOEcfzbj5iCHbaA4WDI9NT1GfcUAaktPgtPsgEYQOoYyBzWqzABR3K dqE8LLJl1ZIGYIBsoDFW3D4wjwAlOGyphSWWTGDZ7ZTbiB_48R36pAyc8BgFnUa8vdpj0i8int.9 fI8QQk1evYKOGEALq8YCoHbf80BeVvvquHE_ljw8XfnS81Z.ho7gAy3I8xzqdpXE6vrusMsNOcMW Uf3z8Fo2X3Oc5U7XF55Iti45lRIPr6EBQNsOklRs5mxya1qyrl9bPNiLgbeg7tMuQHotTaavfqMy O16XXOQQ- Received: from sonicgw.mail.yahoo.co.jp by sonicconh6002.mail.ssk.yahoo.co.jp with HTTP; Sat, 14 Jan 2023 05:04:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1673672641; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type:Content-Transfer-Encoding:References; bh=5gOwkx2qJ9tAlzv5ZT2YPwL8MQh1zGtgBtkjisYafvw=; b=ftKIU0CQuhuX93YkUDQPtkOejrSUE/zZsoK1T3v7hgAu92Ra7Kj2kn2E/Z8Qe4ot tCBbMlzY3JOD0VkrgmR49PcYIoxDiyrhtfi4OfULNrMzltWcrJuXDC9TPuB262iRxIH 0vSpn7g9vz96OA4cvqAtWoOoZPrW3Pfe7AAvCxaw= 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=QQtlAJmGJZx7QFe1IDzBi6aCUDjpgKAQ32wySgOZnKHqLdxyBddAkmHQ3Hx2tjJy umhNFDSYwQaMmfUG+Bz3z61HfrLoLqpNPRhRGn+4ill5B7ijz47pPmeTE3lWrFwGZTB JUBjEYjoewhB3QYLiWjAaMIf8CgJvljrO2q8gM8g=; Received: by smtphe6002.mail.ssk.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 23f7783139a6305ba8f93cf36492be8a; Sat, 14 Jan 2023 14:03:56 +0900 (JST) Message-ID: <0707a800-d409-2264-d2a5-21f43ebeaf6f@yahoo.co.jp> Date: Sat, 14 Jan 2023 14:03:55 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: GCC Patches Cc: Max Filippov From: Takayuki 'January June' Suwa Subject: [PATCH] xtensa: Remove old broken tweak for leaf function Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit References: <0707a800-d409-2264-d2a5-21f43ebeaf6f.ref@yahoo.co.jp> X-Spam-Status: No, score=-10.9 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,SCC_10_SHORT_WORD_LINES,SCC_5_SHORT_WORD_LINES,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 List-Id: In the before-IRA era, ORDER_REGS_FOR_LOCAL_ALLOC was called for each function in Xtensa, and there was register allocation table reordering for leaf functions to compensate for the poor performance of local-alloc. Today the adjustment hook is still called via its alternative ADJUST_REG_ALLOC_ORDER, but it is only called once at the start of the IRA, and leaf_function_p() erroneously returns true and also gives no argument count. That straightforwardly misleads register allocation that all functions are always leaves with no arguments, which leads to inefficiencies in allocation results. Fortunately, IRA is smart enough than local-alloc to not need such assistance. This patch does away with the antiquated by removing the wreckage that no longer works. gcc/ChangeLog: * config/xtensa/xtensa-protos.h (order_regs_for_local_alloc): Rename to xtensa_adjust_reg_alloc_order. * config/xtensa/xtensa.cc (xtensa_adjust_reg_alloc_order): Ditto. And also remove code to reorder register numbers for leaf functions, rename the tables, and adjust the allocation order for the call0 ABI to use register A0 more. (xtensa_leaf_regs): Remove. * config/xtensa/xtensa.h (REG_ALLOC_ORDER): Cosmetics. (order_regs_for_local_alloc): Rename as the above. (LEAF_REGISTERS, LEAF_REG_REMAP, leaf_function): Remove. --- gcc/config/xtensa/xtensa-protos.h | 2 +- gcc/config/xtensa/xtensa.cc | 77 +++++++------------------------ gcc/config/xtensa/xtensa.h | 51 ++++++-------------- 3 files changed, 31 insertions(+), 99 deletions(-) diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h index 91a215e535d..7b5790c5fc4 100644 --- a/gcc/config/xtensa/xtensa-protos.h +++ b/gcc/config/xtensa/xtensa-protos.h @@ -78,7 +78,7 @@ extern long compute_frame_size (poly_int64); extern bool xtensa_use_return_instruction_p (void); extern void xtensa_expand_prologue (void); extern void xtensa_expand_epilogue (bool); -extern void order_regs_for_local_alloc (void); +extern void xtensa_adjust_reg_alloc_order (void); extern enum reg_class xtensa_regno_to_class (int regno); extern HOST_WIDE_INT xtensa_initial_elimination_offset (int from, int to); extern const char **xtensa_get_config_strings (void); diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc index 6cf6b35399a..df9b53aeced 100644 --- a/gcc/config/xtensa/xtensa.cc +++ b/gcc/config/xtensa/xtensa.cc @@ -107,18 +107,6 @@ struct GTY(()) machine_function rtx last_logues_a9_content; }; -/* 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); @@ -4140,58 +4128,25 @@ xtensa_secondary_reload (bool in_p, rtx x, reg_class_t rclass, return NO_REGS; } +/* Called once at the start of IRA, by ADJUST_REG_ALLOC_ORDER. */ void -order_regs_for_local_alloc (void) +xtensa_adjust_reg_alloc_order (void) { - if (!leaf_function_p ()) - { - static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] = - REG_ALLOC_ORDER; - static const int reg_nonleaf_alloc_order_call0[FIRST_PSEUDO_REGISTER] = - { - 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 12, 13, 14, 15, - 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 0, 1, 16, 17, - 35, - }; - - memcpy (reg_alloc_order, TARGET_WINDOWED_ABI ? - reg_nonleaf_alloc_order : reg_nonleaf_alloc_order_call0, - FIRST_PSEUDO_REGISTER * sizeof (int)); - } - else - { - int i, num_arg_regs; - int nxt = 0; - - /* Use the AR registers in increasing order (skipping a0 and a1) - but save the incoming argument registers for a last resort. */ - num_arg_regs = crtl->args.info.arg_words; - if (num_arg_regs > MAX_ARGS_IN_REGISTERS) - num_arg_regs = MAX_ARGS_IN_REGISTERS; - for (i = GP_ARG_FIRST; i < 16 - num_arg_regs; i++) - reg_alloc_order[nxt++] = i + num_arg_regs; - for (i = 0; i < num_arg_regs; i++) - reg_alloc_order[nxt++] = GP_ARG_FIRST + i; - - /* List the coprocessor registers in order. */ - for (i = 0; i < BR_REG_NUM; i++) - reg_alloc_order[nxt++] = BR_REG_FIRST + i; - - /* List the FP registers in order for now. */ - for (i = 0; i < 16; i++) - reg_alloc_order[nxt++] = FP_REG_FIRST + i; - - /* GCC requires that we list *all* the registers.... */ - reg_alloc_order[nxt++] = 0; /* a0 = return address */ - reg_alloc_order[nxt++] = 1; /* a1 = stack pointer */ - reg_alloc_order[nxt++] = 16; /* pseudo frame pointer */ - reg_alloc_order[nxt++] = 17; /* pseudo arg pointer */ - - reg_alloc_order[nxt++] = ACC_REG_FIRST; /* MAC16 accumulator */ - } + static const int reg_windowed_alloc_order[FIRST_PSEUDO_REGISTER] = + REG_ALLOC_ORDER; + static const int reg_call0_alloc_order[FIRST_PSEUDO_REGISTER] = + { + 9, 10, 11, 7, 6, 5, 4, 3, 2, 8, 0, 12, 13, 14, 15, + 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 1, 16, 17, + 35, + }; + + memcpy (reg_alloc_order, TARGET_WINDOWED_ABI ? + reg_windowed_alloc_order : reg_call0_alloc_order, + FIRST_PSEUDO_REGISTER * sizeof (int)); } diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index a7c112b8753..6fcf45fbdfe 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -238,44 +238,21 @@ along with GCC; see the file COPYING3. If not see 1, \ } -/* For non-leaf procedures on Xtensa processors, the allocation order - is as specified below by REG_ALLOC_ORDER. For leaf procedures, we - want to use the lowest numbered registers first to minimize - register window overflows. However, local-alloc is not smart - enough to consider conflicts with incoming arguments. If an - incoming argument in a2 is live throughout the function and - local-alloc decides to use a2, then the incoming argument must - either be spilled or copied to another register. To get around - this, we define ADJUST_REG_ALLOC_ORDER to redefine - reg_alloc_order for leaf functions such that lowest numbered - registers are used first with the exception that the incoming - argument registers are not used until after other register choices - have been exhausted. */ - -#define REG_ALLOC_ORDER \ -{ 8, 9, 10, 11, 12, 13, 14, 15, 7, 6, 5, 4, 3, 2, \ - 18, \ - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, \ - 0, 1, 16, 17, \ - 35, \ -} - -#define ADJUST_REG_ALLOC_ORDER order_regs_for_local_alloc () - -/* 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 the windowed register ABI on Xtensa processors, the allocation + order is as specified below by REG_ALLOC_ORDER. + For the call0 ABI, on the other hand, ADJUST_REG_ALLOC_ORDER hook + will be called once at the start of IRA, replacing it with the + appropriate one. */ -/* For Xtensa, no remapping is necessary, but this macro must be - defined if LEAF_REGISTERS is defined. */ -#define LEAF_REG_REMAP(REGNO) ((int) (REGNO)) - -/* This must be declared if LEAF_REGISTERS is set. */ -extern int leaf_function; +#define REG_ALLOC_ORDER \ +{ \ + 8, 9, 10, 11, 12, 13, 14, 15, 7, 6, 5, 4, 3, 2, \ + 18, \ + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, \ + 0, 1, 16, 17, \ + 35, \ +} +#define ADJUST_REG_ALLOC_ORDER xtensa_adjust_reg_alloc_order () /* Internal macros to classify a register number. */ -- 2.30.2