From: Guo Jie <guojie@loongson.cn>
To: Lulu Cheng <chenglulu@loongson.cn>,
Xi Ruoyao <xry111@xry111.site>,
gcc-patches@gcc.gnu.org
Cc: WANG Xuerui <i@xen0n.name>, Chenghua Xu <xuchenghua@loongson.cn>
Subject: Re: [PATCH] LoongArch: Enable shrink wrapping
Date: Tue, 25 Apr 2023 17:12:57 +0800 [thread overview]
Message-ID: <afdbf9a0-07ee-1ef6-7e73-f337e5ace3cd@loongson.cn> (raw)
In-Reply-To: <c73e3193-fb24-d665-ff44-03f9f6a98a18@loongson.cn>
/* snip */
>> diff --git a/gcc/testsuite/gcc.target/loongarch/shrink-wrap.c
>> b/gcc/testsuite/gcc.target/loongarch/shrink-wrap.c
>> new file mode 100644
>> index 00000000000..f2c867a2769
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/loongarch/shrink-wrap.c
>> @@ -0,0 +1,22 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O -fshrink-wrap" } */
>> +
>> +/* f(x) should do nothing if x is 0. */
>> +/* { dg-final { scan-assembler "bnez\t\\\$r4,\[^\n\]*\n\tjr\t\\\$r1"
>> } } */
>> +
>> +void g(void);
>> +
>> +void
>> +f(int x)
>> +{
>> + if (x)
>> + {
>> + register int s0 asm("s0") = x;
>> + register int s1 asm("s1") = x;
>> + register int s2 asm("s2") = x;
>> + asm("" : : "r"(s0));
>> + asm("" : : "r"(s1));
>> + asm("" : : "r"(s2));
>> + g();
>> + }
>> +}
I think the test case cannot fully reflect the optimization effect of
the current patch,
because even without the patch, -O -fshrink-wrap will still perform
architecture independent optimization.
This patch considers architecture related registers as finer grained
optimization for shrink wrapping,
I think a test case like the one below is more suitable:
int foo(int x)
{
if (x)
{
__asm__ ("":::"s0","s1");
return x;
}
__asm__ ("":::"s2","s3");
return 0;
}
Otherwise LGTM, thanks!
next prev parent reply other threads:[~2023-04-25 9:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-23 13:19 Xi Ruoyao
2023-04-24 8:51 ` Lulu Cheng
2023-04-25 7:37 ` Lulu Cheng
2023-04-25 9:12 ` Guo Jie [this message]
2023-04-26 9:53 ` Lulu Cheng
2023-04-26 10:02 ` WANG Xuerui
2023-04-26 10:14 ` Lulu Cheng
2023-04-26 10:21 ` WANG Xuerui
2023-05-06 17:07 ` Xi Ruoyao
2023-05-06 23:34 ` chenglulu
2023-04-26 13:29 ` Xi Ruoyao
2023-05-06 17:05 ` Pushed: [PATCH v2] " Xi Ruoyao
2023-05-06 23:40 ` chenglulu
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=afdbf9a0-07ee-1ef6-7e73-f337e5ace3cd@loongson.cn \
--to=guojie@loongson.cn \
--cc=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).