public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Xi Ruoyao <xry111@xry111.site>, Jin Ma <jinma@linux.alibaba.com>,
	gcc-patches@gcc.gnu.org
Cc: palmer@dabbelt.com, richard.sandiford@arm.com,
	kito.cheng@gmail.com, philipp.tomsich@vrull.eu,
	christoph.muellner@vrull.eu, rdapp.gcc@gmail.com,
	juzhe.zhong@rivai.ai, vineetg@rivosinc.com,
	jinma.contrib@gmail.com
Subject: Re: [PATCH v2] In the pipeline, USE or CLOBBER should delay execution if it starts a new live range.
Date: Sun, 12 Nov 2023 11:02:18 -0700	[thread overview]
Message-ID: <68dc5f7e-2cc6-43ba-a1ec-bf17af244476@gmail.com> (raw)
In-Reply-To: <37172a21172cbe6ddb580d2619ca3bf3e93b580c.camel@xry111.site>



On 11/12/23 10:41, Xi Ruoyao wrote:
> On Sat, 2023-11-11 at 13:12 -0700, Jeff Law wrote:
>>
>>
>> On 8/14/23 05:22, Jin Ma wrote:
>>> CLOBBER and USE does not represent real instructions, but in the
>>> process of pipeline optimization, they will wait for transmission
>>> in ready list like other insns, without considering resource
>>> conflicts and cycles. This results in a multi-issue CPU architecture
>>> that can be issued at any time if other regular insns have resource
>>> conflicts or cannot be launched for other reasons. As a result,
>>> its position is advanced in the generated insns sequence, which
>>> will affect register allocation and often lead to more redundant
>>> mov instructions.
>>>
>>> A simple example:
>>> https://github.com/majin2020/gcc-test/blob/master/test.c
>>> This is a function in the dhrystone benchmark.
>>>
>>> https://github.com/majin2020/gcc-test/blob/0b08c1a13de9663d7d9aba7539b960ec0607ca24/test.c.299r.sched1
>>> This is a log of the pass 'sched1' When -mtune=rocket but issue_rate
>>> == 2.
>>>
>>> The pipeline is:
>>> ;; | insn | prio |
>>> ;; |  17  |  3   | r142=a0 alu
>>> ;; |  14  |  0   | clobber r136 nothing
>>> ;; |  13  |  0   | clobber a0 nothing
>>> ;; |  18  |  2   | r143=a1 alu
>>> ...
>>> ;; |  12  |  0   | a0=r136 alu
>>> ;; |  15  |  0   | use a0 nothing
>>>
>>> In this log, insn 13 and 14 are much ahead of schedule, which risks
>>> generating
>>> redundant mov instructions, which seems unreasonable.
>>>
>>> Therefore, I submit patch again on the basis of the last review
>>> opinions to try to solve this problem.
>>>
>>> https://github.com/majin2020/gcc-test/commit/efcb43e3369e771bde702955048bfe3f501263dd#diff-805031b1be5092a2322852a248d0b0f92eef7cad5784a8209f4dfc6221407457L189
>>> This is the diff log of shed1 after patch is added.
>>>
>>> The new pipeline is:
>>> ;; | insn | prio |
>>> ;; |  17  |  3   | r142=a0 alu
>>> ...
>>> ;; |  10  |  0   | [r144]=r141 alu
>>> ;; |  13  |  0   | clobber a0 nothing
>>> ;; |  14  |  0   | clobber r136 nothing
>>> ;; |  12  |  0   | a0=r136 alu
>>> ;; |  15  |  0   | use a0 nothing
>>>
>>> gcc/ChangeLog:
>>> 	* haifa-sched.cc (use_or_clobber_starts_range_p): New.
>>> 	(prune_ready_list): USE or CLOBBER should delay execution
>>> 	if it starts a new live range.
>> OK for the trunk.  It doesn't look like you have write access and I
>> don't see anything about what testing was done.  Standard practice is
>> to
>> do a bootstrap and regression test on a primary platform such as x86,
>> aarch64, ppc64.
>>
>> I went ahead and did a bootstrap and regression test on x86_64, then
>> pushed this to the trunk.
> 
> Unfortunately this patch has triggered a bootstrap comparison failure on
> loongarch64-linux-gnu: https://gcc.gnu.org/PR112497.
It's also causing simple build failures on other targets.  For example 
c6x-elf aborts when compiling gcc.c-torture/execute/pr82210 (and others) 
with -O2 with that patch applied.

I've reverted it for now.  I'm not going to have time to investigate 
this week.

Jeff
> 

  reply	other threads:[~2023-11-12 18:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  8:07 [PATCH] In the ready lists of pipeline, put unrecog insns (such as CLOBBER,USE) at the latest to issue Jin Ma
2023-03-27 17:01 ` [PATCH] In the ready lists of pipeline, put unrecog insns (such as CLOBBER, USE) " Richard Sandiford
2023-04-14 21:38   ` Jeff Law
2023-05-29 10:51     ` [PATCH] In the pipeline, UNRECOG INSN is not executed in advance if it starts a live range Jin Ma
2023-06-08  1:50       ` Jin Ma
2023-06-09 23:40       ` Jeff Law
2023-06-12  3:38         ` Jin Ma
2023-11-11 18:51           ` Jeff Law
2023-08-14 11:22         ` [PATCH v2] In the pipeline, USE or CLOBBER should delay execution if it starts a new " Jin Ma
2023-08-29  8:00           ` Jin Ma
2023-11-11 20:12           ` Jeff Law
2023-11-12 17:41             ` Xi Ruoyao
2023-11-12 18:02               ` Jeff Law [this message]
2023-11-12 18:11                 ` Xi Ruoyao
2023-11-13  2:16                 ` Jin Ma
2023-11-13  2:28                   ` 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=68dc5f7e-2cc6-43ba-a1ec-bf17af244476@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=christoph.muellner@vrull.eu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jinma.contrib@gmail.com \
    --cc=jinma@linux.alibaba.com \
    --cc=juzhe.zhong@rivai.ai \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=rdapp.gcc@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=vineetg@rivosinc.com \
    --cc=xry111@xry111.site \
    /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).