public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Fei Gao" <gaofei@eswincomputing.com>
To: jeffreyalaw <jeffreyalaw@gmail.com>,
	 "Kito Cheng" <kito.cheng@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	 "Palmer Dabbelt" <palmer@dabbelt.com>
Subject: Re: Re: [PATCH 0/2] fix RISC-V zcmp popretz [PR113715]
Date: Fri, 28 Jun 2024 18:46:08 +0800	[thread overview]
Message-ID: <2024062818460778180331@eswincomputing.com> (raw)
In-Reply-To: <66f5ddac-7e72-42d7-90db-ad0bdf59fe47@gmail.com>

On 2024-06-09 04:36  Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
>On 6/5/24 8:42 PM, Fei Gao wrote:
>
>>> But let's back up and get a good explanation of what the problem is.
>>> Based on patch 2/2 it looks like we have lost an assignment to the
>>> return register.
>>>
>>> To someone not familiar with this code, it sounds to me like we've made
>>> a mistake earlier and we're now defining a hook that lets us go back and
>>> fix that earlier mistake.   I'm probably wrong, but so far that's what
>>> it sounds like.
>> Hi Jeff
>>
>> You're right. Let me rephrase  patch 2/2 with more details. Search /* feigao to location the point I'm
>> tring to explain.
>>
>> code snippets from gcc/function.cc
>> void
>> thread_prologue_and_epilogue_insns (void)
>> {
>> ...
>>    /*feigao:
>>          targetm.gen_epilogue () is called here to generate epilogue sequence.
>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b27d323a368033f0b37e93c57a57a35fd9997864
>> Commit above tries in targetm.gen_epilogue () to detect if
>> there's li	a0,0 insn at the end of insn chain, if so, cm.popret 
Hi Jeff
I should have made it clear that there're  li	a0,0 and use a0 insns instead of just li a0, 0 here.
>> is replaced by cm.popretz and li	a0,0 insn is deleted.
>So that seems like the critical issue.  Generation of the
>prologue/epilogue really shouldn't be changing other instructions in the
>instruction stream.  I'm not immediately aware of another target that
>does that, an it seems like a rather risky thing to do.
>
>
>It looks like the cm.popretz's RTL exposes the assignment to a0 and
>there's a DCE pass that runs after insertion of the prologue/epilogue.
>So I would suggest leaving the assignment to a0 in the RTL chain and see
>if the later DCE pass after prologue generation eliminates the redundant
>assignment.  That seems a lot cleaner. 
The DCE pass  after prologue generation may not help here for the following reasons:
1. The use a0 insn is not deletable, and then li a0,0 that defines a0 cannot be deleted.
2. We need to detect pattern (clear a0, use a0 and cm.popret) before generating cm.popretz. 
    I don't think DCE is a good place to put this piece of codes. 
    And I insist prologue and epilogue pass is a better place to do it with simplicity and clear logic
    as I explained earlier to Kito. Hook was added here safely without any impact on other targets.

Please let me know your idea. 

Thanks. 
Fei
>
>
>
>Jeff

  reply	other threads:[~2024-06-28 10:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  1:50 Fei Gao
2024-06-05  1:50 ` [PATCH 1/2] target hooks: allow post processing after epilogue inserted Fei Gao
2024-06-05  1:50 ` [PATCH 2/2] [RISC-V]: fix zcmp popretz [PR113715] Fei Gao
2024-06-05  6:36 ` [PATCH 0/2] fix RISC-V " Kito Cheng
2024-06-05  7:47   ` Fei Gao
2024-06-05 13:58     ` Jeff Law
2024-06-06  2:42       ` Fei Gao
2024-06-08 20:36         ` Jeff Law
2024-06-28 10:46           ` Fei Gao [this message]
2024-06-05 13:51   ` Jeff Law

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=2024062818460778180331@eswincomputing.com \
    --to=gaofei@eswincomputing.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.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).