public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: 丁乐华 <lehua.ding@rivai.ai>
To: "Richard Sandiford" <richard.sandiford@arm.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, 钟居哲 <juzhe.zhong@rivai.ai>
Subject: Re: [PATCH 1/1] [fwprop]: Add the support of forwarding the vec_duplicate rtx
Date: Wed, 18 Jan 2023 08:49:14 +0800	[thread overview]
Message-ID: <tencent_745D59B72219BB677DD22E87@qq.com> (raw)
In-Reply-To: <mpt3589rw06.fsf@arm.com>

[-- Attachment #1: Type: text/plain, Size: 2196 bytes --]

&gt; I don't think this pattern is correct, because SEL isn't commutative
&gt; in the vector operands.


Indeed, I think I should invert PRED operand or the comparison
operator&nbsp;which produce the PRED operand first.


&gt;&nbsp;I think this should be:
&gt;
&gt;&nbsp; if (...)
&gt;&nbsp; &nbsp; to = XEXP (to, 0);&gt;
&gt; and should be before the REG_P test.&nbsp; We don't want to treat
&gt; arbitrary duplicates as profitable.

Agree, the&nbsp;adjustment&nbsp;is more rigorous.

&gt;&nbsp;It's not obvious that vec_duplicate is special enough that we should
&gt; treat it differently from other unary operators.&nbsp; For example,
&gt; zero_extend and sign_extend don't seem fundamentally more expensive
&gt; than vec_duplicate.

Juzhe and I also discussed offline recently. We also have widened vector
operator that needs to be added, this can be finished in RTL with forwarding
instead of adding widen GIMPLE internal function. We think we can add a
TARGET HOOK, for example:&nbsp;
`rtx try_forward (rtx dest, rtx src, rtx use_insn, rtx def_insn)`


If it returns NULL_RTX, it means that it cannot be forwarded, otherwise
it means replace the dest part in use_insn with the returned rtx.
Letting the backend decide which ones can be forwarded has several
advantages compared to:
1. Let the insn related to TARGET, such as unspec, also can be forwarded,
&nbsp; &nbsp; and when forwarding, the corresponding content can be extracted
&nbsp; &nbsp; from def_insn instead of the complete src part.
2. By default&nbsp; this HOOK returns NULL_TREE, which can reduce compatibility
&nbsp; &nbsp; issues.


&gt; It's a while since I looked at this code, but I assume that, even after
&gt; this change, we will still require the new in-loop instruction to be
&gt; no more expensive than the old in-loop instruction.&nbsp; Is that right?


Yeah. Forwarding vec_duplicate maybe reduce the use of vector registers,
but increase the life cycle of scalar registers. If the scalar register pressure
is higher, this change may become more expensive. This decision&nbsp;does not
feel very easy to make, is there some way to do this?


Best,




Lehua

  parent reply	other threads:[~2023-01-18  0:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13  9:42 lehua.ding
2023-01-13 10:59 ` juzhe.zhong
2023-01-17 16:00 ` Richard Sandiford
2023-01-17 22:37   ` Jeff Law
2023-01-18  0:49   ` 丁乐华 [this message]
2023-01-18  9:07     ` Richard Sandiford
  -- strict thread matches above, loose matches on Subject: below --
2023-01-13  9:14 lehua.ding

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=tencent_745D59B72219BB677DD22E87@qq.com \
    --to=lehua.ding@rivai.ai \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=juzhe.zhong@rivai.ai \
    --cc=richard.sandiford@arm.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).