From: Jeff Law <jeffreyalaw@gmail.com>
To: Roger Sayle <roger@nextmovesoftware.com>,
'GCC Patches' <gcc-patches@gcc.gnu.org>
Subject: Re: [xstormy16 PATCH] Add support for byte and word swapping instructions.
Date: Tue, 25 Apr 2023 20:24:51 -0600 [thread overview]
Message-ID: <770f5e42-0293-dc79-e87b-4c59ed785647@gmail.com> (raw)
In-Reply-To: <019e01d977b3$6ea3cc20$4beb6460$@nextmovesoftware.com>
On 4/25/23 14:20, Roger Sayle wrote:
>
> This patch adds support for xstormy16's swpb (swap bytes) and swpw (swap
> words) instructions. The most obvious application of these to implement
> the __builtin_bswap16 and __builtin_bswap32 intrinsics.
>
> Currently, __builtin_bswap16 is implemented as:
> foo: mov r7,r2
> shl r7,#8
> shr r2,#8
> or r2,r7
> ret
>
> but with this patch becomes:
> foo: swpb r2
> ret
>
> Likewise, __builtin_bswap32 now becomes:
> foo: swpb r2 | swpb r3 | swpw r2,r3
> ret
>
> Finally, the swpw instruction on its own can be used to exchange
> two word mode registers without a temporary, so a new pattern and
> peephole2 have been added to catch this. As described in the
> PR rtl-optimization/106518, register allocation can (in theory)
> be more efficient on targets that provide a swap/exchange instruction.
> The slightly unusual swap<mode> naming matches that used in i386.md.
>
> This patch has been tested by building a cross-compiler to xstormy16-elf
> from x86_64-pc-linux-gnu, and confirming the new test cases pass.
> Ok for mainline?
>
>
> 2024-04-25 Roger Sayle <roger@nextmovesoftware.com>
>
> gcc/ChangeLog
> * config/stormy16/stormy16.md (bswaphi2): New define_insn.
> (bswapsi2): New define_insn.
> (swaphi): New define_insn to exchange two registers (swpw).
> (define_peephole2): Recognize exchange of registers as swaphi.
>
> gcc/testsuite/ChangeLog
> * gcc.target/xstormy16/bswap16.c: New test case.
> * gcc.target/xstormy16/bswap32.c: Likewise.
> * gcc.target/xstormy16/swpb.c: Likewise.
> * gcc.target/xstormy16/swpw-1.c: Likewise.
> * gcc.target/xstormy16/swpw-2.c: Likewise.
OK. And like prior patches, if it causes any problems in wider testing,
we'll know ~24hrs after the bits go in.
jeff
prev parent reply other threads:[~2023-04-26 2:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 20:20 Roger Sayle
2023-04-26 2:24 ` Jeff Law [this message]
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=770f5e42-0293-dc79-e87b-4c59ed785647@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=roger@nextmovesoftware.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).