From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonicconh6002-vm1.mail.ssk.yahoo.co.jp (sonicconh6002-vm1.mail.ssk.yahoo.co.jp [182.22.37.26]) by sourceware.org (Postfix) with ESMTPS id A5AB43858D39 for ; Fri, 6 Jan 2023 03:35:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5AB43858D39 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: 8tYPMiYVM1kaMhd8.kXxodSt6wTYi7xxUPUfqPTqW14ZBXkYDMDQUAbR_0jKmx4 DhWqcDcCcok2bYftMatAcEJwnD_D88E4R_ah4j9IAPqERuN19W24CfPdCMdO7lbnFw4YG7lnnnS2 SxS28x8zgSz_ySbhSawaCU8cqpH_Nmmrht7A.CvuRGbSrxZ23Xkxj620ib1qtN4Q0RAP6phmHpIy iJszu2QA2kGjd9XvMllUT4wGMp3RvekFLHDfCHooagh.lItOXdH6o4UaCYY1Qkqj7_RZbgaIMv25 o9g5iPndFXbw8nTmKop4LqfYuxkmIRKmOUzJJA4aV4ZDB4qXA5f92DeUy_RLxBcWprl06bBsAKrT bi.pclz.8Mc33u77j1BQ0kLXO1KeHAzwAnF1bHw_GOsUC26cqLmFhx7WBVKTVurdaUhxnqgI_kTd O4KpuWQB4LdeEIFtjeYwDTiGA3NRGeN9AuXxhcFId6Y1y4WeTCdk_VV_gLp51.etF6oucxpNXbDF E_6WqFnEwiSOPjxEytgD5_ADH66C26iGmDHJUMnQuuVVxAp5IFF1Wxnk.9BDEAPAKnxxUIoec5.j k0YWx5kTPs4KHIptY5y33UpQZEXnoxDFHXR.clA.wsDehkll4OhfZ0a7tBlwgbuWwAyFe0x2MRic C_GDn2NyKt5DjWa3lL0AQPINDbdT.iubCWqMkjLUqMaGMc7PuFdz2zjdgv5Y6rrg9bO5FvN7KGeH do8rh5nhqXtCisyKwLNyPcgyATyDoma.xAWi8f4t.CI..3ujY0jYwzG7swNDqP0QRGLHM6ru4RT4 I4jxkUJq16BEnA7UxILr1qeS44aRow.uLkuf2mMZbVNWImq_PgZ0hwukZTTJiOUnBGvJbU.kuNHl h9_7deiKo4JwyUBX34N7avGqCR5oZEZt08toKOi7FqPRw4qDQWsqzjOCm6HtIN2cz7_oJlxRPjNm xi1bUYfc- Received: from sonicgw.mail.yahoo.co.jp by sonicconh6002.mail.ssk.yahoo.co.jp with HTTP; Fri, 6 Jan 2023 03:35:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1672976102; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:Subject:To:References:Cc:From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=NPhSrGjxJ0e03oIpy1VZYdo5Iy81Sxc7axllXcDM2hs=; b=Azp0k74cGX6qPjjyaSv15jDqvsfLH4KKqX/1WTEsoIkc+KDXTb9ycax6d8+zv1eb S/+4T/JkyyK2OIB5BQv2P0pOXukHFQB3yKZiIRxGuGDsr7XT+FIi/nwfWRj0Y6nxLtA DNyQfnoVmKWKEERDZJh0PCuOvgHyFVF9eDawOld4= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:Date:MIME-Version:References:Cc:From:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=U768c4DaBW7vFafcb4MkYoeiPy8O2O87RNrHzamcpsJK3hxzG4ja1xtFoGoub/YQ jJ8vIn8zNmMQ7B/JHzEYwsUHnPQHlobAd5mTiswAmHrWZLT+XgzYTe/M09TxjWJbpID LQYAY06QKpb/WEv3iISPSeoDO1NL0ZDvbmkpX+Cw=; Received: by smtphe6010.mail.ssk.ynwp.yahoo.co.jp (YJ Hermes SMTP Server) with ESMTPA ID 4a679d59cee9cbf1244335db6b7a171d; Fri, 06 Jan 2023 12:35:00 +0900 (JST) Message-ID: Date: Fri, 6 Jan 2023 12:34:59 +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 Subject: Re: [PATCH] xtensa: Optimize stack frame adjustment more To: Max Filippov References: <04a89dbf-c2a3-5dcb-8949-77569a1ad169.ref@yahoo.co.jp> <04a89dbf-c2a3-5dcb-8949-77569a1ad169@yahoo.co.jp> Cc: GCC Patches From: Takayuki 'January June' Suwa In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A,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 List-Id: On 2023/01/06 6:32, Max Filippov wrote: > Hi Suwa-san, Hi! > > On Thu, Jan 5, 2023 at 3:57 AM Takayuki 'January June' Suwa > wrote: >> >> This patch introduces a convenient helper function for integer immediate >> addition with scratch register as needed, that splits and emits either >> up to two ADDI/ADDMI machine instructions or an addition by register >> following an immediate integer load (which may later be transformed by >> constantsynth). >> >> By using the helper function, it makes stack frame adjustment logic >> simplified and instruction count less in some cases. >> >> gcc/ChangeLog: >> >> * config/xtensa/xtensa.cc >> (xtensa_split_imm_two_addends, xtensa_emit_add_imm): >> New helper functions. >> (xtensa_emit_adjust_stack_ptr, xtensa_set_return_address, >> xtensa_output_mi_thunk): Change to use the helper function. >> --- >> gcc/config/xtensa/xtensa.cc | 139 +++++++++++++++++++++++------------- >> 1 file changed, 88 insertions(+), 51 deletions(-) > > This change introduces a bunch of failures in the g++ testsuite, > but the culprit is apparently somewhere in the libstdc++.so, I'm > still looking for it. > > I see the following pattern change in the generated epilogue code: > > - 4aaf: b0a192 movi a9, 0x1b0 > - 4ab2: 1f9a add.n a1, a15, a9 > ... > - 4abe: 20c112 addi a1, a1, 32 > - 4ac1: f00d ret.n > + 4aaf: 02df12 addmi a1, a15, 0x200 > + 4ab2: b0c112 addi a1, a1, -80 > ... > + 4abf: 20c112 addi a1, a1, 32 > + 4ac2: f00d ret.n > > I.e. a1 is first moved into the parent stack frame, then back to the right > spot. This does not look correct, especially for bare-metal targets. > On second thought, it cannot be a good idea to split addition/subtraction to the stack pointer. > - 4aaf: b0a192 movi a9, 0x1b0 > - 4ab2: 1f9a add.n a1, a15, a9 > + 4aaf: 02df12 addmi a1, a15, 0x200 > + 4ab2: b0c112 addi a1, a1, -80 Because the former is atomic, but the latter is not. (may be interrupted between the two add instructions) I'll wait for the results of your investigation, but it may be better to withdraw the patch.