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


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



  reply	other threads:[~2022-11-28 15:39 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 [this message]
2022-11-29  1:53   ` Feng Wang
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=3419fa12-6de8-ab2f-ef36-fc849f67cabb@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kito.cheng@gmail.com \
    --cc=research_trasio@irq.a4lg.com \
    --cc=wangfeng@eswincomputing.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).