From: Lulu Cheng <chenglulu@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, gcc-patches@gcc.gnu.org
Cc: WANG Xuerui <i@xen0n.name>, Chenghua Xu <xuchenghua@loongson.cn>
Subject: Re: [GCC14 PATCH] LoongArch: Optimize additions with immediates
Date: Tue, 4 Apr 2023 11:01:52 +0800 [thread overview]
Message-ID: <39b42972-9a0f-3ada-b9b9-2c53da946217@loongson.cn> (raw)
In-Reply-To: <20230402140044.23073-1-xry111@xry111.site>
[-- Attachment #1: Type: text/plain, Size: 2851 bytes --]
/* 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!
next prev parent reply other threads:[~2023-04-04 3:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-02 14:00 Xi Ruoyao
2023-04-04 3:01 ` Lulu Cheng [this message]
2023-04-04 8:00 ` Xi Ruoyao
2023-04-04 8:40 ` Xi Ruoyao
2023-04-04 9:15 ` Lulu Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39b42972-9a0f-3ada-b9b9-2c53da946217@loongson.cn \
--to=chenglulu@loongson.cn \
--cc=gcc-patches@gcc.gnu.org \
--cc=i@xen0n.name \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).