From: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>
To: "Qian, Jianhua" <qianjh@cn.fujitsu.com>,
"gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: A problem with one instruction multiple latencies and pipelines
Date: Mon, 14 Sep 2020 10:08:16 +0100 [thread overview]
Message-ID: <bf510003-2cb3-a668-bf77-12961dcc3475@foss.arm.com> (raw)
In-Reply-To: <60063587247240e7b9cd419da7138bd0@G08CNEXMBPEKD06.g08.fujitsu.local>
On 14/09/2020 03:53, Qian, Jianhua wrote:
>> -----Original Message-----
>> From: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>
>> Sent: Friday, September 11, 2020 9:30 PM
>> To: Qian, Jianhua/钱 建华 <qianjh@cn.fujitsu.com>; gcc@gcc.gnu.org
>> Subject: Re: A problem with one instruction multiple latencies and pipelines
>>
>> On 07/09/2020 07:08, Qian, Jianhua wrote:
>>> Hi
>>>
>>> I'm adding a new machine model. I have a problem when writing the
>> "define_insn_reservation" for instruction scheduling.
>>> How to write the "define_insn_reservation" for one instruction that there are
>> different latencies and pipelines according to parameter.
>>>
>>> For example, the ADD (shifted register) instruction in a64fx
>>>
>>> Instruction Option Latency
>> Pipeline
>>> ADD (shifted register) <amount> = 0 1 EX*
>> | EAG*
>>> <amount> = [1-4] && <shift>=LSL 1+1
>> (EXA + EXA) | (EXB + EXB)
>>> 2+1 (EXA
>> + EXA) | (EXB + EXB)
>>>
>>
>> A shift by immediate zero isn't a shift, so should never use this RTL pattern.
>> We can ignore that case.
>>
>>> In aarch64.md ADD (shifted register) instruction is defined as following.
>>> (define_insn "*add_<shift>_<mode>"
>>> [(set (match_operand:GPI 0 "register_operand" "=r")
>>> (plus:GPI (ASHIFT:GPI (match_operand:GPI 1 "register_operand"
>> "r")
>>> (match_operand:QI 2
>> "aarch64_shift_imm_<mode>" "n"))
>>> (match_operand:GPI 3 "register_operand" "r")))]
>>> ""
>>> "add\\t%<w>0, %<w>3, %<w>1, <shift> %2"
>>> [(set_attr "type" "alu_shift_imm")]
>>> )
>>
>> You might consider using a define_bypass to adjust the cost - the matcher rule
>> takes a producer and consumer RTL - you don't care about the consumer, but
>> you can use the bypass to reduce the cost if the producer uses an immediate in
>> the 'low latency' range. This would avoid having to make a load of whole-sale
>> changes to the main parts of the machine description.
>
> Thanks for your comment.
> But I think the define_bypass can only change the latency for special instruction.
> Pipeline also could be changed by define_bypass?
>
Possibly, but if this is part of the out-of-order units of the pipe, I
really don't think it will matter. In fact, I'm not even convinced that
trying to model the out-of-order stages is worthwhile - let the CPU
handle that: any long-latency instruction, such as a memory access that
misses the L1 cache will completely mess up the compiler's understanding
of the pipeline state anyway.
What I think is more important is to get a good model for the in-order
bits at the front of the pipe accurately modelled so that you can
maximize the throughput of those stages. Try to get a mix of
instructions so that a single issue unit in the core doesn't get clogged
up and block further decode.
R.
> Regards
> Qian
>
>>>
>>> It could not be distinguished by the type "alu_shift_imm" when writing
>> "define_insn_reservation" for ADD (shifted register).
>>> What should I do?
>>>
>>> Regards
>>> Qian
>>>
>>>
>>>
>>
>> R.
>>
>
>
>
prev parent reply other threads:[~2020-09-14 9:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 6:08 Qian, Jianhua
2020-09-07 7:40 ` Richard Biener
2020-09-07 8:45 ` Qian, Jianhua
2020-09-07 11:58 ` Richard Biener
2020-09-07 20:20 ` Richard Sandiford
2020-09-08 5:34 ` Qian, Jianhua
2020-09-09 21:22 ` Segher Boessenkool
2020-09-10 5:01 ` Qian, Jianhua
2020-09-10 10:04 ` Richard Sandiford
2020-09-10 23:00 ` Segher Boessenkool
2020-09-11 7:44 ` Richard Sandiford
2020-09-11 13:58 ` Segher Boessenkool
2020-09-14 5:41 ` Qian, Jianhua
2020-09-14 9:55 ` Richard Sandiford
2020-09-14 18:41 ` Segher Boessenkool
2020-09-14 19:35 ` Richard Sandiford
2020-09-14 22:14 ` Segher Boessenkool
2020-09-11 13:30 ` Richard Earnshaw
2020-09-14 2:53 ` Qian, Jianhua
2020-09-14 9:08 ` Richard Earnshaw [this message]
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=bf510003-2cb3-a668-bf77-12961dcc3475@foss.arm.com \
--to=richard.earnshaw@foss.arm.com \
--cc=gcc@gcc.gnu.org \
--cc=qianjh@cn.fujitsu.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).