public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: costs: handle BSWAP
@ 2022-11-08 19:54 Philipp Tomsich
  2022-11-09  2:57 ` Jeff Law
  0 siblings, 1 reply; 7+ messages in thread
From: Philipp Tomsich @ 2022-11-08 19:54 UTC (permalink / raw)
  To: gcc-patches
  Cc: Palmer Dabbelt, Kito Cheng, Christoph Muellner, Vineet Gupta,
	Jeff Law, Philipp Tomsich

The BSWAP operation is not handled in rtx_costs. Add it.

With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
it will expand into two.

gcc/ChangeLog:

        * config/riscv/riscv.c (rtx_costs): Add BSWAP.

---

 gcc/config/riscv/riscv.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 32f9ef9ade9..ab6c745c722 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -2562,6 +2562,16 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN
       *total = riscv_extend_cost (XEXP (x, 0), GET_CODE (x) == ZERO_EXTEND);
       return false;
 
+    case BSWAP:
+      if (TARGET_ZBB)
+	{
+	  /* RISC-V only defines rev8 for XLEN, so we will need an extra
+	     shift-right instruction for smaller modes. */
+	  *total = COSTS_N_INSNS (mode == word_mode ? 1 : 2);
+	  return true;
+	}
+      return false;
+
     case FLOAT:
     case UNSIGNED_FLOAT:
     case FIX:
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: costs: handle BSWAP
  2022-11-08 19:54 [PATCH] RISC-V: costs: handle BSWAP Philipp Tomsich
@ 2022-11-09  2:57 ` Jeff Law
  2022-11-09  3:15   ` Palmer Dabbelt
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Law @ 2022-11-09  2:57 UTC (permalink / raw)
  To: Philipp Tomsich, gcc-patches
  Cc: Palmer Dabbelt, Kito Cheng, Christoph Muellner, Vineet Gupta, Jeff Law


On 11/8/22 12:54, Philipp Tomsich wrote:
> The BSWAP operation is not handled in rtx_costs. Add it.
>
> With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
> it will expand into two.
>
> gcc/ChangeLog:
>
>          * config/riscv/riscv.c (rtx_costs): Add BSWAP.

OK.

Jeff



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: costs: handle BSWAP
  2022-11-09  2:57 ` Jeff Law
@ 2022-11-09  3:15   ` Palmer Dabbelt
  2022-11-09  4:43     ` Andrew Pinski
  2022-11-09  9:33     ` Philipp Tomsich
  0 siblings, 2 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-11-09  3:15 UTC (permalink / raw)
  To: jeffreyalaw
  Cc: philipp.tomsich, gcc-patches, Kito Cheng, christoph.muellner,
	Vineet Gupta, jlaw

On Tue, 08 Nov 2022 18:57:26 PST (-0800), jeffreyalaw@gmail.com wrote:
>
> On 11/8/22 12:54, Philipp Tomsich wrote:
>> The BSWAP operation is not handled in rtx_costs. Add it.
>>
>> With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
>> it will expand into two.
>>
>> gcc/ChangeLog:
>>
>>          * config/riscv/riscv.c (rtx_costs): Add BSWAP.
>
> OK.

It's riscv_rtx_costs.

(I don't usually read ChangeLog entries that closely, just happened to 
stumble on it when poking around.)


>
> Jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: costs: handle BSWAP
  2022-11-09  3:15   ` Palmer Dabbelt
@ 2022-11-09  4:43     ` Andrew Pinski
  2022-11-09  4:53       ` Palmer Dabbelt
  2022-11-09  9:27       ` Philipp Tomsich
  2022-11-09  9:33     ` Philipp Tomsich
  1 sibling, 2 replies; 7+ messages in thread
From: Andrew Pinski @ 2022-11-09  4:43 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: jeffreyalaw, philipp.tomsich, gcc-patches, Kito Cheng,
	christoph.muellner, Vineet Gupta, jlaw

On Tue, Nov 8, 2022 at 7:16 PM Palmer Dabbelt <palmer@rivosinc.com> wrote:
>
> On Tue, 08 Nov 2022 18:57:26 PST (-0800), jeffreyalaw@gmail.com wrote:
> >
> > On 11/8/22 12:54, Philipp Tomsich wrote:
> >> The BSWAP operation is not handled in rtx_costs. Add it.
> >>
> >> With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
> >> it will expand into two.
> >>
> >> gcc/ChangeLog:
> >>
> >>          * config/riscv/riscv.c (rtx_costs): Add BSWAP.
> >
> > OK.
>
> It's riscv_rtx_costs.
>
> (I don't usually read ChangeLog entries that closely, just happened to
> stumble on it when poking around.)

Using contrib/git-commit-mklog.py can help here to make sure you
always get the correct format for the changelog and it does a decent
job of figuring out function names too.
You can also use contrib/gcc-git-customization.sh to install it such
that you can use it when doing git commits.
After invoking that inside the GCC git; you can just do "git
gcc-commit-mklog ...." Where .... would be what you normally put for
"git commit" (but as if in the toplevel directory).

Thanks,
Andrew Pinski

>
>
> >
> > Jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: costs: handle BSWAP
  2022-11-09  4:43     ` Andrew Pinski
@ 2022-11-09  4:53       ` Palmer Dabbelt
  2022-11-09  9:27       ` Philipp Tomsich
  1 sibling, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2022-11-09  4:53 UTC (permalink / raw)
  To: pinskia
  Cc: jeffreyalaw, philipp.tomsich, gcc-patches, Kito Cheng,
	christoph.muellner, Vineet Gupta, jlaw

On Tue, 08 Nov 2022 20:43:20 PST (-0800), pinskia@gmail.com wrote:
> On Tue, Nov 8, 2022 at 7:16 PM Palmer Dabbelt <palmer@rivosinc.com> wrote:
>>
>> On Tue, 08 Nov 2022 18:57:26 PST (-0800), jeffreyalaw@gmail.com wrote:
>> >
>> > On 11/8/22 12:54, Philipp Tomsich wrote:
>> >> The BSWAP operation is not handled in rtx_costs. Add it.
>> >>
>> >> With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
>> >> it will expand into two.
>> >>
>> >> gcc/ChangeLog:
>> >>
>> >>          * config/riscv/riscv.c (rtx_costs): Add BSWAP.
>> >
>> > OK.
>>
>> It's riscv_rtx_costs.
>>
>> (I don't usually read ChangeLog entries that closely, just happened to
>> stumble on it when poking around.)
>
> Using contrib/git-commit-mklog.py can help here to make sure you
> always get the correct format for the changelog and it does a decent
> job of figuring out function names too.
> You can also use contrib/gcc-git-customization.sh to install it such
> that you can use it when doing git commits.
> After invoking that inside the GCC git; you can just do "git
> gcc-commit-mklog ...." Where .... would be what you normally put for
> "git commit" (but as if in the toplevel directory).

Thanks, that's awesome.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: costs: handle BSWAP
  2022-11-09  4:43     ` Andrew Pinski
  2022-11-09  4:53       ` Palmer Dabbelt
@ 2022-11-09  9:27       ` Philipp Tomsich
  1 sibling, 0 replies; 7+ messages in thread
From: Philipp Tomsich @ 2022-11-09  9:27 UTC (permalink / raw)
  To: Andrew Pinski
  Cc: Palmer Dabbelt, jeffreyalaw, gcc-patches, Kito Cheng,
	christoph.muellner, Vineet Gupta, jlaw

On Wed, 9 Nov 2022 at 05:43, Andrew Pinski <pinskia@gmail.com> wrote:
>
> On Tue, Nov 8, 2022 at 7:16 PM Palmer Dabbelt <palmer@rivosinc.com> wrote:
> >
> > On Tue, 08 Nov 2022 18:57:26 PST (-0800), jeffreyalaw@gmail.com wrote:
> > >
> > > On 11/8/22 12:54, Philipp Tomsich wrote:
> > >> The BSWAP operation is not handled in rtx_costs. Add it.
> > >>
> > >> With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
> > >> it will expand into two.
> > >>
> > >> gcc/ChangeLog:
> > >>
> > >>          * config/riscv/riscv.c (rtx_costs): Add BSWAP.
> > >
> > > OK.
> >
> > It's riscv_rtx_costs.
> >
> > (I don't usually read ChangeLog entries that closely, just happened to
> > stumble on it when poking around.)
>
> Using contrib/git-commit-mklog.py can help here to make sure you
> always get the correct format for the changelog and it does a decent
> job of figuring out function names too.
> You can also use contrib/gcc-git-customization.sh to install it such
> that you can use it when doing git commits.
> After invoking that inside the GCC git; you can just do "git
> gcc-commit-mklog ...." Where .... would be what you normally put for
> "git commit" (but as if in the toplevel directory).

We always pass them through contrib/mklog,py (or git-commit-mklog.py,
which invokes it) anyway, but (as the ".c" in the filename indicates)
this one hasn't been refreshed in over a year's time.
Don't worry, this will need to get adjusted again once I merge it (as
the commit hooks won't let it pass).

Philipp.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] RISC-V: costs: handle BSWAP
  2022-11-09  3:15   ` Palmer Dabbelt
  2022-11-09  4:43     ` Andrew Pinski
@ 2022-11-09  9:33     ` Philipp Tomsich
  1 sibling, 0 replies; 7+ messages in thread
From: Philipp Tomsich @ 2022-11-09  9:33 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: jeffreyalaw, gcc-patches, Kito Cheng, christoph.muellner,
	Vineet Gupta, jlaw

Applied to master, with the commit-message regenerated as:

    gcc/ChangeLog:

            * config/riscv/riscv.cc (riscv_rtx_costs): Add BSWAP.

Thanks,
Philipp.

On Wed, 9 Nov 2022 at 04:15, Palmer Dabbelt <palmer@rivosinc.com> wrote:
>
> On Tue, 08 Nov 2022 18:57:26 PST (-0800), jeffreyalaw@gmail.com wrote:
> >
> > On 11/8/22 12:54, Philipp Tomsich wrote:
> >> The BSWAP operation is not handled in rtx_costs. Add it.
> >>
> >> With Zbb, BSWAP for XLEN is a single instruction; for smaller modes,
> >> it will expand into two.
> >>
> >> gcc/ChangeLog:
> >>
> >>          * config/riscv/riscv.c (rtx_costs): Add BSWAP.
> >
> > OK.
>
> It's riscv_rtx_costs.
>
> (I don't usually read ChangeLog entries that closely, just happened to
> stumble on it when poking around.)
>
>
> >
> > Jeff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-09  9:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 19:54 [PATCH] RISC-V: costs: handle BSWAP Philipp Tomsich
2022-11-09  2:57 ` Jeff Law
2022-11-09  3:15   ` Palmer Dabbelt
2022-11-09  4:43     ` Andrew Pinski
2022-11-09  4:53       ` Palmer Dabbelt
2022-11-09  9:27       ` Philipp Tomsich
2022-11-09  9:33     ` Philipp Tomsich

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).