From: Jeff Law <jeffreyalaw@gmail.com>
To: Robin Dapp <rdapp.gcc@gmail.com>,
"Wang, Yanzhang" <yanzhang.wang@intel.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: "juzhe.zhong@rivai.ai" <juzhe.zhong@rivai.ai>,
"kito.cheng@sifive.com" <kito.cheng@sifive.com>,
"Li, Pan2" <pan2.li@intel.com>
Subject: Re: [PATCH v2] RISC-V: convert the mulh with 0 to mov 0 to the reg.
Date: Fri, 28 Jul 2023 17:07:11 -0600 [thread overview]
Message-ID: <a385a11e-58b0-87ea-c8d8-2e224f2fac0e@gmail.com> (raw)
In-Reply-To: <2c69bce7-4fb8-1162-304d-7fd016cea576@gmail.com>
On 7/28/23 06:31, Robin Dapp via Gcc-patches wrote:
>> This is a draft patch. I would like to explain it's hard to make the
>> simplify generic and ask for some help.
>>
>> There're 2 categories we need to optimize.
>>
>> - The op in optab such as div / 1.
>> - The unspec operation such as mulh * 0, (vadc+vmadc) + 0.
>>
>> Especially for the unspec operation, I found we need to write one by
>> one to match the special pattern. Seems there's no way to write a
>> generic pattern that will match mulh, (vadc+vmadc), sll... This way
>> is too complicated and not so elegant because need to write so much
>> md patterns.
>>
>> Do you have any ideas?
>
> Yes, it's cumbersome having to add the patterns individually
> and it would be nicer to have the middle end optimize for us.
>
> However, adding new rtl expressions, especially generic ones that
> are useful for others and the respective optimizations is a tedious
> process as well. Still, just recently Roger Sayle added bitreverse
> and copysign. You can refer to his patch as well as the follow-up
> ones to get an idea of what would need to be done.
> ("Add RTX codes for BITREVERSE and COPYSIGN")
>
> So if we have few patterns that are really performance critical
> (like for some benchmark) my take is to add them in a similar way you
> were proposing but I would advise against using this excessively.
> Is the mulh case somehow common or critical?
Well, I would actually back up even further. What were the
circumstances that led to the mulh with a zero operand? That would
tend to be an indicator of a problem earlier. Perhaps in the gimple
pipeline or the gimple->rtl conversion. I'd be a bit surprised to see a
const0_rtx propagate in during the RTL pipeline, I guess it's possible,
but I'd expect it to be relatively rare.
The one case I could see happening would be cases from the builtin
apis... Of course one might call that user error ;-)
jeff
next prev parent reply other threads:[~2023-07-28 23:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 6:08 [PATCH] " yanzhang.wang
2023-06-21 6:20 ` juzhe.zhong
2023-06-21 6:54 ` Wang, Yanzhang
2023-06-21 6:23 ` juzhe.zhong
2023-06-21 6:27 ` Robin Dapp
2023-06-21 6:33 ` juzhe.zhong
2023-06-21 7:08 ` Wang, Yanzhang
2023-06-21 7:25 ` juzhe.zhong
2023-07-28 11:50 ` [PATCH v2] " yanzhang.wang
2023-07-28 12:00 ` Kito Cheng
2023-07-28 12:00 ` Wang, Yanzhang
2023-07-28 12:31 ` Robin Dapp
2023-07-28 23:07 ` Jeff Law [this message]
2023-07-31 12:14 ` Wang, Yanzhang
2023-07-31 15:48 ` 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=a385a11e-58b0-87ea-c8d8-2e224f2fac0e@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=juzhe.zhong@rivai.ai \
--cc=kito.cheng@sifive.com \
--cc=pan2.li@intel.com \
--cc=rdapp.gcc@gmail.com \
--cc=yanzhang.wang@intel.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).