public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/106601] New: __builtin_bswap16 code gen could be improved with ZBB enabled
@ 2022-08-12 20:09 pinskia at gcc dot gnu.org
2022-08-12 20:40 ` [Bug target/106601] " andrew at sifive dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-12 20:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106601
Bug ID: 106601
Summary: __builtin_bswap16 code gen could be improved with ZBB
enabled
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: target
Assignee: pinskia at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: riscv
unsigned short t(unsigned short a)
{
return __builtin_bswap16(a);
}
This could just be rev8 followed by a srli (I think).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/106601] __builtin_bswap16 code gen could be improved with ZBB enabled
2022-08-12 20:09 [Bug target/106601] New: __builtin_bswap16 code gen could be improved with ZBB enabled pinskia at gcc dot gnu.org
@ 2022-08-12 20:40 ` andrew at sifive dot com
2022-08-12 20:53 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: andrew at sifive dot com @ 2022-08-12 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106601
Andrew Waterman <andrew at sifive dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |andrew at sifive dot com
--- Comment #1 from Andrew Waterman <andrew at sifive dot com> ---
Yep.
(I don't know whether bswap32 has already been similarly optimized on RV64, but
it needs to use srai so that the 32-bit result is canonicalized properly.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/106601] __builtin_bswap16 code gen could be improved with ZBB enabled
2022-08-12 20:09 [Bug target/106601] New: __builtin_bswap16 code gen could be improved with ZBB enabled pinskia at gcc dot gnu.org
2022-08-12 20:40 ` [Bug target/106601] " andrew at sifive dot com
@ 2022-08-12 20:53 ` pinskia at gcc dot gnu.org
2022-08-24 18:31 ` cvs-commit at gcc dot gnu.org
2022-08-24 18:32 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-12 20:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106601
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2022-08-12
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Waterman from comment #1)
> (I don't know whether bswap32 has already been similarly optimized on RV64,
> but it needs to use srai so that the 32-bit result is canonicalized
> properly.)
It is:
t:
rev8 a0,a0
srai a0,a0,32
ret
For:
unsigned int t(unsigned int a)
{
return __builtin_bswap32(a);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/106601] __builtin_bswap16 code gen could be improved with ZBB enabled
2022-08-12 20:09 [Bug target/106601] New: __builtin_bswap16 code gen could be improved with ZBB enabled pinskia at gcc dot gnu.org
2022-08-12 20:40 ` [Bug target/106601] " andrew at sifive dot com
2022-08-12 20:53 ` pinskia at gcc dot gnu.org
@ 2022-08-24 18:31 ` cvs-commit at gcc dot gnu.org
2022-08-24 18:32 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-24 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106601
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:
https://gcc.gnu.org/g:e5e6983c3da53729e58a32af1d531ea74b3dbf5d
commit r13-2179-ge5e6983c3da53729e58a32af1d531ea74b3dbf5d
Author: Andrew Pinski <apinski@marvell.com>
Date: Fri Aug 19 17:46:40 2022 +0000
Fix PR 106601: __builtin_bswap16 code gen could be improved with ZBB
enabled
The default expansion for bswap16 is two extractions (shift/and)
followed by an insertation (ior) and then a zero extend. This can be
improved
with ZBB enabled to just full byteswap followed by a (logical) shift right.
This patch adds a new pattern for this which does that.
OK? Built and tested on riscv32-linux-gnu and riscv64-linux-gnu.
gcc/ChangeLog:
PR target/106601
* config/riscv/bitmanip.md (bswaphi2): New pattern.
gcc/testsuite/ChangeLog:
PR target/106601
* gcc.target/riscv/zbb_32_bswap-2.c: New test.
* gcc.target/riscv/zbb_bswap-2.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/106601] __builtin_bswap16 code gen could be improved with ZBB enabled
2022-08-12 20:09 [Bug target/106601] New: __builtin_bswap16 code gen could be improved with ZBB enabled pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2022-08-24 18:31 ` cvs-commit at gcc dot gnu.org
@ 2022-08-24 18:32 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-24 18:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106601
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |13.0
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-24 18:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 20:09 [Bug target/106601] New: __builtin_bswap16 code gen could be improved with ZBB enabled pinskia at gcc dot gnu.org
2022-08-12 20:40 ` [Bug target/106601] " andrew at sifive dot com
2022-08-12 20:53 ` pinskia at gcc dot gnu.org
2022-08-24 18:31 ` cvs-commit at gcc dot gnu.org
2022-08-24 18:32 ` pinskia at gcc dot gnu.org
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).