public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Feng Wang" <wangfeng@eswincomputing.com>
To: "Jeff Law" <jeffreyalaw@gmail.com>,
	 gcc-patches <gcc-patches@gcc.gnu.org>
Cc: kito.cheng <kito.cheng@gmail.com>,
	 research_trasio <research_trasio@irq.a4lg.com>
Subject: Re: Re: [PATCH] RISC-V: Support the ins "rol" with immediate operand
Date: Tue, 29 Nov 2022 09:53:54 +0800	[thread overview]
Message-ID: <2022112909535334321719@eswincomputing.com> (raw)
In-Reply-To: <3419fa12-6de8-ab2f-ef36-fc849f67cabb@gmail.com>

on 2022-11-28 23:39  Jeff Law<jeffreyalaw@gmail.com> wrote:
>
>
>On 11/27/22 19:14, Feng Wang wrote:
>> From: wangfeng <wangfeng@eswincomputing.com>
>>
>> There is no Immediate operand of ins "rol" accroding to the B-ext,
>> so the immediate operand should be loaded into register at first.
>> But we can convert it to the ins "rori" or "roriw", and then one
>> immediate load ins can be reduced.
>>
>> Please refer to the following use cases:
>> unsigned long foo2(unsigned long rs1)
>> {
>>      return (rs1 << 10) | (rs1 >> 54);
>> }
>>
>> The complier result is:
>> li	a1,10
>> rol	a0,a0,a1
>>
>> This patch will generate one ins
>> rori a0,a0,54
>>
>> gcc/ChangeLog:
>>
>>          * config/riscv/bitmanip.md: Add immediate_operand support in rotl RTL pattern
>>
>> gcc/testsuite/ChangeLog:
>>
>>          * gcc.target/riscv/zbb-rol-ror-04.c: New test.
>>          * gcc.target/riscv/zbb-rol-ror-05.c: New test.
>
>So this arrived after stage1 close and I'm not aware of an existing BZ
>around this issue, so I'd tend to think this should wait for stage1 to
>re-open in the spring.
>
>
> From a technical standpoint, would it be better to hand this in a more
>generic way?   ie, when converting from gimple into RTL, if we want to
>generate a rotate left by immediate and don't have a suitable insn, then
>change it to a rotate right by an adjusted immediate.    This could
>probably be done in optabs.cc::expand_binop.
>
>
>We might need similar code in combine.cc or simplify-rtx.cc since some
>rotate cases (or exposure of the constant) may not show up until later
>in the RTL pipeline.
>
>
>Anyway, doing this in a more generic way seems like it's worth
>investigating.
>
>
>jeff
> 
Hi jeff,

Thanks for your reply. In the currently it will judge the rotate shift number when converting from
gimple into RTL, if the shift number bigger than mode_size/2, then reverse the rotate direction. 
I think the purpose of this process is to handle rotate shift quickly. I will think about your advice
and try to modify it in the expand pass.

Wang Feng
Best regards

  reply	other threads:[~2022-11-29  1:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  2:14 Feng Wang
2022-11-28 15:39 ` Jeff Law
2022-11-29  1:53   ` Feng Wang [this message]
2022-11-29  4:52     ` 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=2022112909535334321719@eswincomputing.com \
    --to=wangfeng@eswincomputing.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=kito.cheng@gmail.com \
    --cc=research_trasio@irq.a4lg.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).