Re: [Patch] catch builtin_bswap16 construct

2012-09-26 Thread Oleg Endo
On Mon, 2012-09-24 at 09:47 +0200, Oleg Endo wrote: > On Mon, 2012-09-24 at 09:15 +0200, Eric Botcazou wrote: > > > A while ago I've tried doing that for SH (implementing bswap16 with RTL > > > combine). It was like an explosion of patterns, because combine would > > > try out a lot of things depe

Re: [Patch] catch builtin_bswap16 construct

2012-09-26 Thread Richard Guenther
On Fri, Sep 21, 2012 at 10:04 AM, Christophe Lyon wrote: > On 20 September 2012 09:55, Christophe Lyon > wrote: >> On 20 September 2012 09:12, Eric Botcazou wrote: The attached patch catches C constructs: (A << 8) | (A >> 8) where A is unsigned 16 bits and maps them to built

Re: [Patch] catch builtin_bswap16 construct

2012-09-25 Thread Eric Botcazou
> I guess I just have to wait for approval by the right maintainer now? Right, GCC's bureaucracy is no legend. :-) I've CCed Richard, who approved the __builtin_bswap16 stuff back in April. -- Eric Botcazou

Re: [Patch] catch builtin_bswap16 construct

2012-09-25 Thread Christophe Lyon
On 25 September 2012 13:32, Segher Boessenkool wrote: >>> Christophe, it looks like the zero-extend in the unsigned case is not >>> needed on any target? Assuming the shifts are at least SImode, of >>> course (I'm too lazy to check, sorry). >> >> >> It's also present when compiling: >> unsigned s

Re: [Patch] catch builtin_bswap16 construct

2012-09-25 Thread Segher Boessenkool
Christophe, it looks like the zero-extend in the unsigned case is not needed on any target? Assuming the shifts are at least SImode, of course (I'm too lazy to check, sorry). It's also present when compiling: unsigned short swapu16(unsigned short x) { return __builtin_bswap16(x); } so it'

Re: [Patch] catch builtin_bswap16 construct

2012-09-25 Thread Christophe Lyon
On 25 September 2012 07:00, Segher Boessenkool wrote: > Christophe, it looks like the zero-extend in the unsigned case is not > needed on any target? Assuming the shifts are at least SImode, of > course (I'm too lazy to check, sorry). > It's also present when compiling: unsigned short swapu16(un

Re: [Patch] catch builtin_bswap16 construct

2012-09-24 Thread Segher Boessenkool
The generated code is now: myswaps16: rlwinm 10,3,8,16,23 rlwinm 9,3,24,24,31 or 9,9,10 extsh 3,9 blr myswapu16: rlwinm 10,3,8,16,23 rlwinm 9,3,24,24,31 or 9,9,10 rlwinm 3,9,0,0x blr While it was (without my patc

Re: [Patch] catch builtin_bswap16 construct

2012-09-24 Thread Eric Botcazou
> I have not yet been able to build an environment to run the testsuite > with qemu-ppc (not sure about the best target & dejagnu board > selection). No problem, that wasn't really a requirement. > However, when compiling a sample test > short myswaps16(short x) { >return (x << 8) | (x >> 8);

Re: [Patch] catch builtin_bswap16 construct

2012-09-24 Thread Christophe Lyon
On 21 September 2012 12:56, Eric Botcazou wrote: >> Here is a new patch, modifying tree-ssa-math-opts.c as you suggested. >> It's indeed simpler :-) >> >> Validated with qemu-arm on target arm-none-linux-gnueabi. > > I cannot formally approve, but this looks good to me. > > However, could you chec

Re: [Patch] catch builtin_bswap16 construct

2012-09-24 Thread Oleg Endo
On Mon, 2012-09-24 at 09:15 +0200, Eric Botcazou wrote: > > A while ago I've tried doing that for SH (implementing bswap16 with RTL > > combine). It was like an explosion of patterns, because combine would > > try out a lot of things depending on the surrounding code around the > > actual bswap16.

Re: [Patch] catch builtin_bswap16 construct

2012-09-24 Thread Eric Botcazou
> A while ago I've tried doing that for SH (implementing bswap16 with RTL > combine). It was like an explosion of patterns, because combine would > try out a lot of things depending on the surrounding code around the > actual bswap16. In the end I decided to drop that stuff for the most > part.

Re: [Patch] catch builtin_bswap16 construct

2012-09-23 Thread Andrew Pinski
On Fri, Sep 21, 2012 at 1:04 AM, Christophe Lyon wrote: > On 20 September 2012 09:55, Christophe Lyon > wrote: >> On 20 September 2012 09:12, Eric Botcazou wrote: The attached patch catches C constructs: (A << 8) | (A >> 8) where A is unsigned 16 bits and maps them to builti

Re: [Patch] catch builtin_bswap16 construct

2012-09-23 Thread Oleg Endo
On Thu, 2012-09-20 at 09:12 +0200, Eric Botcazou wrote: > > The attached patch catches C constructs: > > (A << 8) | (A >> 8) > > where A is unsigned 16 bits > > and maps them to builtin_bswap16(A) which can provide more efficient > > implementations on some targets. > > This belongs in tree-ssa-ma

Re: [Patch] catch builtin_bswap16 construct

2012-09-21 Thread Eric Botcazou
> Here is a new patch, modifying tree-ssa-math-opts.c as you suggested. > It's indeed simpler :-) > > Validated with qemu-arm on target arm-none-linux-gnueabi. I cannot formally approve, but this looks good to me. However, could you check that this is also an improvement for PowerPC, which is t

Re: [Patch] catch builtin_bswap16 construct

2012-09-21 Thread Christophe Lyon
On 20 September 2012 09:55, Christophe Lyon wrote: > On 20 September 2012 09:12, Eric Botcazou wrote: >>> The attached patch catches C constructs: >>> (A << 8) | (A >> 8) >>> where A is unsigned 16 bits >>> and maps them to builtin_bswap16(A) which can provide more efficient >>> implementations o

Re: [Patch] catch builtin_bswap16 construct

2012-09-20 Thread Christophe Lyon
On 20 September 2012 09:12, Eric Botcazou wrote: >> The attached patch catches C constructs: >> (A << 8) | (A >> 8) >> where A is unsigned 16 bits >> and maps them to builtin_bswap16(A) which can provide more efficient >> implementations on some targets. > > This belongs in tree-ssa-math-opts.c:ex

Re: [Patch] catch builtin_bswap16 construct

2012-09-20 Thread Eric Botcazou
> The attached patch catches C constructs: > (A << 8) | (A >> 8) > where A is unsigned 16 bits > and maps them to builtin_bswap16(A) which can provide more efficient > implementations on some targets. This belongs in tree-ssa-math-opts.c:execute_optimize_bswap instead. When I implemented __builti

Re: [Patch] catch builtin_bswap16 construct

2012-09-19 Thread Oleg Endo
On Wed, 2012-09-19 at 18:44 +0200, Georg-Johann Lay wrote: > This seems overly complicated on 16-bit platforms where (A << 8) | (A >> 8) > is the same as rotate:HI (A 8). > > Does your patch make sure that (A << 8) | (A >> 8) is still mapped to ROTATE > on these targets? > If I remember correct

Re: [Patch] catch builtin_bswap16 construct

2012-09-19 Thread Georg-Johann Lay
Christophe Lyon wrote: > Hi, > > The attached patch catches C constructs: > (A << 8) | (A >> 8) > where A is unsigned 16 bits > and maps them to builtin_bswap16(A) which can provide more efficient > implementations on some targets. > > The construct above is equivalent to the default bswap16 impl