From: Jeff Law <law@redhat.com>
To: "Sandra Loosemore" <sandra@codesourcery.com>,
瞿仙淼 <xianmiao_qu@c-sky.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Yunhai Shang <yunhai_shang@c-sky.com>
Subject: Re: [2/5] C-SKY port: Backend implementation
Date: Thu, 02 Aug 2018 22:33:00 -0000 [thread overview]
Message-ID: <ecebda09-c079-a1dc-82fe-c995228220ec@redhat.com> (raw)
In-Reply-To: <37200996-f535-b070-4415-227d2dad794b@codesourcery.com>
On 07/27/2018 07:49 PM, Sandra Loosemore wrote:
> 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?
I think the pass is papering over problems elsewhere (see my most other
reply on this thread). I do think it would be useful to take that code
and create a test based on it. I suspect you'll want to verify multiple
GT expressions prior to CSE2 and that after CSE2 you have a single GT
expression. Presumably it'd be in the csky specific test.
jeff
next prev parent reply other threads:[~2018-08-02 22:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-24 4:17 [0/5] C-SKY port Sandra Loosemore
2018-07-24 4:20 ` [1/5] C-SKY port: Configury Sandra Loosemore
2018-07-24 15:09 ` Jeff Law
2018-07-24 4:21 ` [2/5] C-SKY port: Backend implementation Sandra Loosemore
2018-07-24 15:45 ` Jeff Law
2018-07-24 18:19 ` Sandra Loosemore
2018-07-24 21:25 ` Jeff Law
2018-07-25 0:17 ` Sandra Loosemore
2018-07-25 4:50 ` Jeff Law
2018-07-25 13:17 ` Paul Koning
2018-07-25 14:54 ` Sandra Loosemore
2018-07-26 6:07 ` 瞿仙淼
2018-07-28 1:49 ` Sandra Loosemore
2018-08-02 22:33 ` Jeff Law [this message]
2018-08-02 22:28 ` Jeff Law
2018-08-03 7:58 ` Yunhai
2018-08-03 16:26 ` Sandra Loosemore
2018-07-24 4:23 ` [3/5] C-SKY port: Documentation Sandra Loosemore
2018-07-24 15:10 ` Jeff Law
2018-07-24 4:25 ` [4/5] C-SKY port: Testsuite Sandra Loosemore
2018-07-24 15:10 ` Jeff Law
2018-07-24 4:26 ` [5/5] C-SKY port: libgcc Sandra Loosemore
2018-07-24 15:12 ` Jeff Law
2018-07-24 18:10 ` Segher Boessenkool
2018-07-24 18:19 ` Sandra Loosemore
2018-07-24 19:46 ` Segher Boessenkool
2018-07-24 15:23 ` [0/5] C-SKY port Sandra Loosemore
2018-07-26 23:04 ` Joseph Myers
2018-07-30 16:59 ` Sandra Loosemore
2018-08-01 14:28 ` 瞿仙淼
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=ecebda09-c079-a1dc-82fe-c995228220ec@redhat.com \
--to=law@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=sandra@codesourcery.com \
--cc=xianmiao_qu@c-sky.com \
--cc=yunhai_shang@c-sky.com \
/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).