From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 3AF6C3858D28 for ; Sun, 17 Sep 2023 01:42:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AF6C3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8BxuOidWQZl7SspAA--.43198S3; Sun, 17 Sep 2023 09:42:54 +0800 (CST) Received: from [10.20.4.107] (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxfNycWQZl1A0JAA--.17982S3; Sun, 17 Sep 2023 09:42:52 +0800 (CST) Subject: Re: [PATCH] LoongArch: Fix lo_sum rtx cost To: WANG Xuerui , mengqinggang , gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, xuchenghua@loongson.cn References: <20230916091643.3160525-1-mengqinggang@loongson.cn> From: chenglulu Message-ID: <47f50fea-d70a-74cf-8d8b-21302b72e93c@loongson.cn> Date: Sun, 17 Sep 2023 09:42:52 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8CxfNycWQZl1A0JAA--.17982S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7ZF15AF13AryfKFWxCw43CFX_yoW8Zw1rpF Z2k3W3GrW8Jrn3WF1DA345XryrJ3yfK3W7X3WSq3WrCrs8ZF1jvF4Fqr90gFnrWw48JrW2 qr15GFnxZFn8AagCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUvYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v2 6F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4 CEbIxvr21l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UNvtZU UUUU= X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,BODY_8BITS,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,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: 在 2023/9/16 下午10:52, WANG Xuerui 写道: > Hi, > > On 9/16/23 17:16, mengqinggang wrote: >> The cost of lo_sum rtx for addi.d instruction my be a very big number if >> computed by common function. It may cause some symbols saving to >> stack and >> loading from stack if there no enough registers during loop >> optimization. > > Thanks for the patch! It seems though this change is done in order to > optimize some previously pathetic codegen, am I right? If so, it's > appreciated to have a minimal test case attached, in order to ensure > that codegen never regresses. (You can have your teammates help you if > you're not familiar with that.) This is a performance optimization problem discovered by Meng Qinggang when he was debugging the spec. The specific test cases are not easy to extract. We will try to extract simple test cases to reproduce this optimization. If not, we will mark the description information. Thanks! > >> >> gcc/ChangeLog: >> >>     * config/loongarch/loongarch.cc (loongarch_rtx_costs): Add lo_sum >> cost. >> --- >>   gcc/config/loongarch/loongarch.cc | 4 ++++ >>   1 file changed, 4 insertions(+) >> >> diff --git a/gcc/config/loongarch/loongarch.cc >> b/gcc/config/loongarch/loongarch.cc >> index 845fad5a8e8..0e57f09379c 100644 >> --- a/gcc/config/loongarch/loongarch.cc >> +++ b/gcc/config/loongarch/loongarch.cc >> @@ -3648,6 +3648,10 @@ loongarch_rtx_costs (rtx x, machine_mode mode, >> int outer_code, >>       *total = COSTS_N_INSNS (4); >>         return false; >>   +    case LO_SUM: >> +      *total = set_src_cost (XEXP (x, 0), mode, speed); >> +      return true; >> + > In order for the code to be more maintainable, it may be better to > duplicate some of the change reasons here, just in case someone in the > future questions this piece of code that's without any explanation, > and regresses things (because there's no test case). >>       case LT: >>       case LTU: >>       case LE: