[PATCH] middle-end: Recognize idioms for bswap32 and bswap64 in match.pd.

Roger Sayle roger@nextmovesoftware.com
Mon Aug 17 08:06:51 GMT 2020


Hi Jakub and Marc,
Here's version #3 of the patch to recognize bswap32 and bswap64 that
now also implements Jakub's suggestion to support addition and xor in
addition to bitwise ior when recognizing the union of highpart and
lowpart (and two additional tests to check for these variants).

This revised patch has been tested on x86_64-pc-linux-gnu with a
"make bootstrap" and "make -k check" with no new failures, and
confirming all four new tests pass.
Ok for mainline?

2020-08-17  Roger Sayle  <roger@nextmovesoftware.com>
	    Marc Glisse  <marc.glisse@inria.fr>
	    Jakub Jelinek  <jakub@redhat.com>

gcc/ChangeLog
	* match.pd (((T)bswapX(x)<<C)|bswapX(x>>C) -> bswapY(x)):
	New simplifications to recognize __builtin_bswap{32,64}.

gcc/testsuite/ChangeLog
	* gcc.dg/fold-bswap-1.c: New test.
	* gcc.dg/fold-bswap-2.c: New test.
	* gcc.dg/fold-bswap-3.c: New test.
	* gcc.dg/fold-bswap-4.c: New test.


Thanks in advance,
Roger
--

-----Original Message-----
From: Jakub Jelinek <jakub@redhat.com> 
Sent: 15 August 2020 14:26
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: 'GCC Patches' <gcc-patches@gcc.gnu.org>; 'Marc Glisse'
<marc.glisse@inria.fr>
Subject: Re: [PATCH] middle-end: Recognize idioms for bswap32 and bswap64 in
match.pd.

On Sat, Aug 15, 2020 at 11:09:17AM +0100, Roger Sayle wrote:
> +/* Recognize ((T)bswap32(x)<<32)|bswap32(x>>32) as bswap64(x).  */ 
> +(simplify
> +  (bit_ior:c

Any reason for supporting bit_ior only?  Don't plus:c or bit_xor:c work the
same (i.e. use (for op (bit_ior bit_xor plus) ...)?

	Jakub

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patcha2d.txt
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200817/13f2af52/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patcha2b.txt
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200817/13f2af52/attachment-0001.txt>


More information about the Gcc-patches mailing list