Re: [Patch ARM] implement bswap16

2012-09-12 Thread Richard Earnshaw
On 11/09/12 16:04, Christophe Lyon wrote: > On 11 September 2012 12:52, Richard Earnshaw wrote: >> Try something like: >> >> short foo(int); >> >> short swaps (short x, int y) >> { >> int z = x; >> if (y) >> z = __builtin_bswap16(x); >> return foo (z); >> } >> >> If that's not enough

Re: [Patch ARM] implement bswap16

2012-09-11 Thread Christophe Lyon
On 11 September 2012 12:52, Richard Earnshaw wrote: > Try something like: > > short foo(int); > > short swaps (short x, int y) > { > int z = x; > if (y) > z = __builtin_bswap16(x); > return foo (z); > } > > If that's not enough, try adding 1 to z before calling foo. > Thanks, it wor

Re: [Patch ARM] implement bswap16

2012-09-11 Thread Richard Earnshaw
On 11/09/12 11:25, Christophe Lyon wrote: > On 10 September 2012 19:30, Richard Earnshaw wrote: >> On 10/09/12 16:40, Christophe Lyon wrote: >>> Why do we have to keep room for the predicate here? (%?) Doesn't this >>> pattern match only in unconditional cases? >>> >> >> Because the ARM back-end h

Re: [Patch ARM] implement bswap16

2012-09-11 Thread Christophe Lyon
On 10 September 2012 19:30, Richard Earnshaw wrote: > On 10/09/12 16:40, Christophe Lyon wrote: >> Why do we have to keep room for the predicate here? (%?) Doesn't this >> pattern match only in unconditional cases? >> > > Because the ARM back-end has a very late conditionalizer pass that can > als

Re: [Patch ARM] implement bswap16

2012-09-10 Thread Richard Earnshaw
On 10/09/12 16:40, Christophe Lyon wrote: > On 7 September 2012 17:28, Richard Earnshaw wrote: >> >> Ah, sigh! I'd forgotten about the cond-exec issue. That makes things >> a little awkward, since we also have to deal with the fact that thumb1 >> does not support predication. The solution, unfo

Re: [Patch ARM] implement bswap16

2012-09-10 Thread Christophe Lyon
On 7 September 2012 17:28, Richard Earnshaw wrote: > > Ah, sigh! I'd forgotten about the cond-exec issue. That makes things > a little awkward, since we also have to deal with the fact that thumb1 > does not support predication. The solution, unfortunately, is thus a > bit more involved. > Sorr

Re: [Patch ARM] implement bswap16

2012-09-07 Thread Richard Earnshaw
On 07/09/12 12:45, Christophe Lyon wrote: > On 6 September 2012 18:42, Richard Earnshaw wrote: >> On 06/09/12 17:07, Christophe Lyon wrote: >>> >>> But why are the thumb1_XXX patterns still necessary? >>> I tried removing them, but compiling the testcase with -march=armv6 >>> -mthumb makes the com

Re: [Patch ARM] implement bswap16

2012-09-07 Thread Christophe Lyon
On 6 September 2012 18:42, Richard Earnshaw wrote: > On 06/09/12 17:07, Christophe Lyon wrote: >> >> But why are the thumb1_XXX patterns still necessary? >> I tried removing them, but compiling the testcase with -march=armv6 >> -mthumb makes the compiler fail (internal compiler error: >> output_op

Re: [Patch ARM] implement bswap16

2012-09-06 Thread Richard Earnshaw
On 06/09/12 17:07, Christophe Lyon wrote: > On 6 September 2012 10:48, Richard Earnshaw wrote: >> On 05/09/12 17:01, Christophe Lyon wrote: >> >> +(define_insn "*arm_revsh" >> + [(set (match_operand:SI 0 "s_register_operand" "=r") >> + (sign_extend:SI (bswap:HI (match_operand:HI 1 "s_regist

Re: [Patch ARM] implement bswap16

2012-09-06 Thread Christophe Lyon
On 6 September 2012 10:48, Richard Earnshaw wrote: > On 05/09/12 17:01, Christophe Lyon wrote: > > +(define_insn "*arm_revsh" > + [(set (match_operand:SI 0 "s_register_operand" "=r") > + (sign_extend:SI (bswap:HI (match_operand:HI 1 "s_register_operand" > "r"] > + "TARGET_32BIT && arm

Re: [Patch ARM] implement bswap16

2012-09-06 Thread Richard Earnshaw
On 05/09/12 17:01, Christophe Lyon wrote: > Hi, > > This patch implements __builtin_bswap16() on ARM (v6 and above) using > revsh with a signed input and rev16 with an unsigned input. > > It is pretty much equal to the patch posted some time ago > http://gcc.gnu.org/ml/gcc-patches/2012-04/msg0096

[Patch ARM] implement bswap16

2012-09-05 Thread Christophe Lyon
Hi, This patch implements __builtin_bswap16() on ARM (v6 and above) using revsh with a signed input and rev16 with an unsigned input. It is pretty much equal to the patch posted some time ago http://gcc.gnu.org/ml/gcc-patches/2012-04/msg00962.html, but it's hard to write such patterns differently