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 3E5363858CDA for ; Wed, 26 Apr 2023 09:53:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E5363858CDA 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 _____8DxyOms9Ehk9_0AAA--.1752S3; Wed, 26 Apr 2023 17:53:49 +0800 (CST) Received: from [10.20.4.52] (unknown [10.20.4.52]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxfb6q9Ehk16c8AA--.34872S2; Wed, 26 Apr 2023 17:53:48 +0800 (CST) Subject: Re: [PATCH] LoongArch: Enable shrink wrapping To: Guo Jie , Xi Ruoyao , gcc-patches@gcc.gnu.org Cc: WANG Xuerui , Chenghua Xu References: <20230423131903.155998-1-xry111@xry111.site> From: Lulu Cheng Message-ID: <182bca4f-c605-8e0c-19ce-e840258b05d2@loongson.cn> Date: Wed, 26 Apr 2023 17:53:46 +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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8Cxfb6q9Ehk16c8AA--.34872S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7ZryxWFy3uryUJw45GrW7Arb_yoW8Cw4kpa 97GFWrKrykAFn3Ww4xWFyjqFyfZr17tw15Zr97WFy0yrZ3ZryIgr4YqrWqgF17Gw48Gr15 Z345ursxua15Z3DanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bxAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l42 xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWU GwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI4 8JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4U MIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I 8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07UNvtZUUUUU= X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,BODY_8BITS,GIT_PATCH_0,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Hi, ruoyao:       The performance of spec2006 is finished. The fixed-point 400.perlbench has about 3% performance improvement, and the other basics have not changed, and the floating-point tests have basically remained the same.       Do you have any questions about the test cases mentioned by Guo Jie? If there is no problem, modify the test case, I think the code can be merged into the main branch. Thanks! 在 2023/4/25 下午5:12, Guo Jie 写道: > /* 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!