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

2020-08-22 Thread Marc Glisse
On Sat, 15 Aug 2020, Roger Sayle wrote: Here's version #2 of the patch to recognize bswap32 and bswap64 incorporating your suggestions and feedback. The test cases now confirm the transformation is applied when int is 32 bits and long is 64 bits, and should pass otherwise; the patterns now

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

2020-08-17 Thread Roger Sayle
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

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

2020-08-15 Thread Jakub Jelinek via Gcc-patches
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) ...)?

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

2020-08-15 Thread Roger Sayle
Hi Marc, Here's version #2 of the patch to recognize bswap32 and bswap64 incorporating your suggestions and feedback. The test cases now confirm the transformation is applied when int is 32 bits and long is 64 bits, and should pass otherwise; the patterns now reuse (more) capturing groups, and

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

2020-08-12 Thread Marc Glisse
On Wed, 12 Aug 2020, Roger Sayle wrote: This patch is inspired by a small code fragment in comment #3 of bugzilla PR rtl-optimization/94804. That snippet appears almost unrelated to the topic of the PR, but recognizing __builtin_bswap64 from two __builtin_bswap32 calls, seems like a

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

2020-08-12 Thread Roger Sayle
This patch is inspired by a small code fragment in comment #3 of bugzilla PR rtl-optimization/94804. That snippet appears almost unrelated to the topic of the PR, but recognizing __builtin_bswap64 from two __builtin_bswap32 calls, seems like a clever/useful trick. GCC's optabs.c contains the