From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10477 invoked by alias); 28 Jul 2018 01:49:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10291 invoked by uid 89); 28 Jul 2018 01:49:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-2.5 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,GARBLED_BODY,GIT_PATCH_2,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy==bf=e4=bb, 983, H*r:0700, HContent-Transfer-Encoding:8bit?= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Jul 2018 01:49:33 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1fjEML-0005tw-TX from Sandra_Loosemore@mentor.com ; Fri, 27 Jul 2018 18:49:29 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 27 Jul 2018 18:49:27 -0700 Subject: Re: [2/5] C-SKY port: Backend implementation To: =?UTF-8?B?556/5LuZ5re8?= , Jeff Law CC: "gcc-patches@gcc.gnu.org" , Yunhai Shang References: <49d0a2c8-51a0-4a74-d015-0bf1c1098e38@codesourcery.com> <28cb3a6e-4594-3545-5236-c68784af6a57@codesourcery.com> <8a1b9bac-82dc-bb4f-e0a2-9a9b9cbea98a@redhat.com> <56004587-F43E-4004-B618-B819CF7A5E4A@c-sky.com> From: Sandra Loosemore Message-ID: <37200996-f535-b070-4415-227d2dad794b@codesourcery.com> Date: Sat, 28 Jul 2018 01:49:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <56004587-F43E-4004-B618-B819CF7A5E4A@c-sky.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2018-07/txt/msg01771.txt.bz2 On 07/26/2018 12:06 AM, 瞿仙淼 wrote: > > I wrote a case to reproduce this problem on C-SKY. C code is as follows: > ----------------------------------------------------------------------- > int e1, e2; > > void func (int a, int b, int c, int d, int f, int g) > { > e1 = a > b ? f : g; > e2 = a > b ? c : d; > > return; > } > ----------------------------------------------------------------------- > > compile to assembler with option “-O3 -S” : > ----------------------------------------------------------------------- > func: > cmplt a1, a0 > ld.w t1, (sp, 0) > ld.w t0, (sp, 4) > movt t0, t1 > cmplt a1, a0 > movt a3, a2 > lrw a1, e2 > lrw a2, e1 > st.w a3, (a1, 0) > st.w t0, (a2, 0) > rts > ----------------------------------------------------------------------- > There is an extra “cmplt a1, a0" in the above code without cse_cc. This situation mainly occurs when a relatively short branch jump is converted into a conditional execution instruction. And the CSE pass can not reduce the same conditional comparison instruction . Here is the rtx sequence after “cse2” pass. > > ----------------------------------------------------------------------- > (insn 28 13 29 2 (set (reg:CC 33 c) > (gt:CC (reg/v:SI 77 [ a ]) > (reg/v:SI 78 [ b ]))) func.c:5 1099 {*cmpgtsi} > (nil)) > (insn 29 28 30 2 (set (reg/v:SI 82 [ g ]) > (if_then_else:SI (eq (reg:CC 33 c) > (const_int 0 [0])) > (reg/v:SI 82 [ g ]) > (reg/v:SI 81 [ f ]))) func.c:5 983 {movf} > (expr_list:REG_DEAD (reg/v:SI 81 [ f ]) > (expr_list:REG_DEAD (reg:CC 33 c) > (nil)))) > (insn 30 29 31 2 (set (reg:CC 33 c) > (gt:CC (reg/v:SI 77 [ a ]) > (reg/v:SI 78 [ b ]))) func.c:5 1099 {*cmpgtsi} > (expr_list:REG_DEAD (reg/v:SI 78 [ b ]) > (expr_list:REG_DEAD (reg/v:SI 77 [ a ]) > (nil)))) > (insn 31 30 18 2 (set (reg/v:SI 80 [ d ]) > (if_then_else:SI (eq (reg:CC 33 c) > (const_int 0 [0])) > (reg/v:SI 80 [ d ]) > (reg/v:SI 79 [ c ]))) func.c:5 983 {movf} > (expr_list:REG_DEAD (reg/v:SI 79 [ c ]) > (expr_list:REG_DEAD (reg:CC 33 c) > (nil)))) > ----------------------------------------------------------------------- > > It doesn't seem to check the same conditional comparison instruction .So I wrote this to solve this problem, but I am not sure if this is the best way : ) > > PS, the same conditional comparison instruction cannot be reduced with the latest version gcc with C-SKY because I just insert the “cse_cc” after “cse1”, when I insert after “cse2”, this problem can be solved very well. Thanks, this is very helpful. I've verified this and I'm moving the pass as you suggest, adding a more detailed comment to the source to explain what the pass is for, and adding your test case to the testsuite. This will be included when I resubmit the patches to address other review comments too. Jeff, does that adequately address your concerns about whether the pass is useful? -Sandra