From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 635E03858D1E for ; Tue, 4 Apr 2023 03:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 635E03858D1E 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.52]) by gateway (Coremail) with SMTP id _____8BxPNohkytkPU0WAA--.23111S3; Tue, 04 Apr 2023 11:01:53 +0800 (CST) Received: from [10.20.4.52] (unknown [10.20.4.52]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxab0hkytk4uYUAA--.17135S2; Tue, 04 Apr 2023 11:01:53 +0800 (CST) Subject: Re: [GCC14 PATCH] LoongArch: Optimize additions with immediates To: Xi Ruoyao , gcc-patches@gcc.gnu.org Cc: WANG Xuerui , Chenghua Xu References: <20230402140044.23073-1-xry111@xry111.site> From: Lulu Cheng Message-ID: <39b42972-9a0f-3ada-b9b9-2c53da946217@loongson.cn> Date: Tue, 4 Apr 2023 11:01:52 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20230402140044.23073-1-xry111@xry111.site> Content-Type: multipart/alternative; boundary="------------E9D70817CB185C6A3E794FBC" Content-Language: en-US X-CM-TRANSID:AQAAf8Bxab0hkytk4uYUAA--.17135S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAFW8GryUur4DCw15Jw4xWFg_yoW5XF18p3 Wftwn8KrWIqasrKryIvryYqr1rJr17Za43tF47tryUC3W8JFn8ZrW3C3sxAr48Jr9Y9F47 A39xJr4qvrWDGaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUUbxxYFVCjjxCrM7AC8VAFwI0_Jr0_ Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jrv_JF1l8cAvFV AK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2 z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr 1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG 8wAqjxCEc2xF0cIa020Ex4CE44I27wAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aV AFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMx8GjcxK6IxK0xII j40E5I8CrwCYjI0SjxkI62AI1cAE67vIY487MxAIw28IcxkI7VAKI48JMxC20s026xCaFV Cjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_JrI_JrWlx2IqxVCjr7xvwVAFwI0_JrI_JrWl x4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r 1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_ JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCT nIWIevJa73UjIFyTuYvjxUFrWrDUUUU X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,HTML_MESSAGE,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,SPF_HELO_PASS,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: This is a multi-part message in MIME format. --------------E9D70817CB185C6A3E794FBC Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit /* snip */ > > diff --git a/gcc/testsuite/gcc.target/loongarch/add-const.c b/gcc/testsuite/gcc.target/loongarch/add-const.c > new file mode 100644 > index 00000000000..3a9f72fe83d > --- /dev/null > +++ b/gcc/testsuite/gcc.target/loongarch/add-const.c > @@ -0,0 +1,47 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O -mabi=lp64d" } */ > + > +/* None of these functions should load the const operand into a temp > + register. */ > + > +/* { dg-final { scan-assembler-not "add\\.[dw]" } } */ > + > +unsigned long f01 (unsigned long x) { return x + 1; } > +unsigned long f02 (unsigned long x) { return x - 1; } > +unsigned long f03 (unsigned long x) { return x + 2047; } > +unsigned long f04 (unsigned long x) { return x + 4094; } > +unsigned long f05 (unsigned long x) { return x - 2048; } > +unsigned long f06 (unsigned long x) { return x - 4096; } > +unsigned long f07 (unsigned long x) { return x + 0x7fff0000; } > +unsigned long f08 (unsigned long x) { return x - 0x80000000l; } > +unsigned long f09 (unsigned long x) { return x + 0x7fff0000l * 2; } > +unsigned long f10 (unsigned long x) { return x - 0x80000000l * 2; } > +unsigned long f11 (unsigned long x) { return x - 0x80000000l * 2; } These two test cases are duplicates. > +unsigned long f12 (unsigned long x) { return x + 0x7fff0000 + 0x1; } > +unsigned long f13 (unsigned long x) { return x + 0x7fff0000 - 0x1; } > +unsigned long f14 (unsigned long x) { return x + 0x7fff0000 + 0x7ff; } > +unsigned long f15 (unsigned long x) { return x + 0x7fff0000 - 0x800; } > +unsigned long f16 (unsigned long x) { return x - 0x80000000l - 1; } > +unsigned long f17 (unsigned long x) { return x - 0x80000000l + 1; } > +unsigned long f18 (unsigned long x) { return x - 0x80000000l - 0x800; } > +unsigned long f19 (unsigned long x) { return x - 0x80000000l + 0x7ff; } > + > +unsigned int g01 (unsigned int x) { return x + 1; } > +unsigned int g02 (unsigned int x) { return x - 1; } > +unsigned int g03 (unsigned int x) { return x + 2047; } > +unsigned int g04 (unsigned int x) { return x + 4094; } > +unsigned int g05 (unsigned int x) { return x - 2048; } > +unsigned int g06 (unsigned int x) { return x - 4096; } > +unsigned int g07 (unsigned int x) { return x + 0x7fff0000; } > +unsigned int g08 (unsigned int x) { return x - 0x80000000l; } > +unsigned int g09 (unsigned int x) { return x + 0x7fff0000l * 2; } > +unsigned int g10 (unsigned int x) { return x - 0x80000000l * 2; } > +unsigned int g11 (unsigned int x) { return x - 0x80000000l * 2; } Ditto. I found that adding this log test case gcc.target/loongarch/stack-check-cfa-1.c and gcc.target/loongarch/stack-check-cfa-2.c test failed. Although the test fails, the generated assembly code is better, and there is no problem with the logic of the assembly code. I haven't checked the reason for this yet. Otherwise LGTM, thanks! --------------E9D70817CB185C6A3E794FBC--