Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-12 Thread Andrew Pinski
On Sat, May 12, 2012 at 11:36 AM, Maciej W. Rozycki wrote: > On Sun, 6 May 2012, Andrew Pinski wrote: > >> >  For the record: MIPS processors that implement CLZ/CLO (for some reason >> > CTZ/CTO haven't been added to the architecture, but these operations can >> > be cheaply transformed into CLZ/C

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-12 Thread Maciej W. Rozycki
On Sun, 6 May 2012, Andrew Pinski wrote: > >  For the record: MIPS processors that implement CLZ/CLO (for some reason > > CTZ/CTO haven't been added to the architecture, but these operations can > > be cheaply transformed into CLZ/CLO) generally have a dedicated unit that > > causes no pipeline st

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-06 Thread Andrew Pinski
On Sat, May 5, 2012 at 11:52 PM, Maciej W. Rozycki wrote: >  For the record: MIPS processors that implement CLZ/CLO (for some reason > CTZ/CTO haven't been added to the architecture, but these operations can > be cheaply transformed into CLZ/CLO) generally have a dedicated unit that > causes no pi

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-05 Thread Maciej W. Rozycki
On Fri, 27 Apr 2012, Paolo Bonzini wrote: > > What about cost considerations? We only seem to have the general > > "branches are expensive" metric - but ctz/clz may be prohibitely expensive > > themselves, no? > > Yeah, that's a general problem with this kind of tricks. In general > however clz

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-03 Thread Richard Henderson
On 05/03/2012 08:23 AM, Paolo Bonzini wrote: Yeah, not as I posted... of course config/mips/mips.h needs change, but do you disagree that all targets_do_ have the same value at zero for the optab as they have for RTL? I don't agree without a port-by-port review, no. If, as you suggest, we ge

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-03 Thread Paolo Bonzini
Il 03/05/2012 17:10, Richard Henderson ha scritto: >>> >>> >>> ... except that no target sets the macros to 2, and all of them could >>> (as far as I could see). Looks like the code trumps the documentation; >>> how does this look? > > "No target sets to 2"? You mean like mips? You forgot to lo

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-03 Thread Richard Henderson
On 05/03/2012 03:23 AM, Paolo Bonzini wrote: - ctzsi4 expands to bitrev + clz:SI, so it will return 32 too. ctz:SI will never appear at all in the RTX stream, so you can define its value at zero to be whatever you want. Hence the correct valid of CTZ_DEFINED_VALUE_AT_ZERO is also 2. That's for

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-03 Thread Richard Henderson
On Fri, Apr 27, 2012 at 2:43 PM, Paolo Bonzini wrote: Interesting, first time I hear about this... ... except that no target sets the macros to 2, and all of them could (as far as I could see). Looks like the code trumps the documentation; how does this look? "No target sets to 2"? You mean

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-03 Thread Paolo Bonzini
Il 03/05/2012 11:57, Richard Guenther ha scritto: > Hmm, I'll let target maintainers have a look at this - it's non-obvious > for arm (the only case I looked at) at least. My guess is that the > difference was to allow __builtin_ctz to be "optimized" and CTZ > to be always well-defined (which inci

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-05-03 Thread Richard Guenther
On Fri, Apr 27, 2012 at 2:43 PM, Paolo Bonzini wrote: > Il 27/04/2012 13:16, Richard Guenther ha scritto: >> In optabs.c we compare the CTZ_DEFINED_VALUE_AT_ZERO against two, >> is != 0 really what you want here?  The docs suggest to me >> that as you are using the optab below you should compare a

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-04-27 Thread Paolo Bonzini
Il 27/04/2012 13:16, Richard Guenther ha scritto: > In optabs.c we compare the CTZ_DEFINED_VALUE_AT_ZERO against two, > is != 0 really what you want here? The docs suggest to me > that as you are using the optab below you should compare against two, too. Interesting, first time I hear about this.

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-04-27 Thread Richard Guenther
On Fri, 27 Apr 2012, Paolo Bonzini wrote: > If the value at zero is outside the range [0, GET_MODE_BITSIZE (mode)), > "A != 0" and "A == 0" can be compiled to clz/ctz followed by a subtraction > or one's complement (only for A != 0) and a shift. This trick can be > used effectively on PPC (though

Re: [PATCH] teach emit_store_flag to use clz/ctz

2012-04-27 Thread Paolo Bonzini
> Index: config/rs6000/rs6000.md > === > --- config/rs6000/rs6000.md (revisione 186859) > +++ config/rs6000/rs6000.md (copia locale) > @@ -2129,7 +2129,7 @@ > (define_expand "abssi2" >[(set (match_operand:SI 0 "gpc_reg_operan

[PATCH] teach emit_store_flag to use clz/ctz

2012-04-27 Thread Paolo Bonzini
If the value at zero is outside the range [0, GET_MODE_BITSIZE (mode)), "A != 0" and "A == 0" can be compiled to clz/ctz followed by a subtraction or one's complement (only for A != 0) and a shift. This trick can be used effectively on PPC (though there are other problems in the machine descriptio