------- Comment #2 from mattst88 at gmail dot com  2009-04-18 15:25 -------
(In reply to comment #0)
> unsigned parity(unsigned x) {
>     x ^= x >> 16;
>     x ^= x >> 8;
>     x ^= x >> 4;
>     x &= 0xf;
>     return (0x6996 >> x) & 1;
> }
> 
> gcc 4.2.0 20060506 produces:
>         extwl   a0,0x2,t2
>         lda     v0,27030
>         xor     t2,a0,t2
>         zapnot  t2,0xf,t1 # redundant zero-extension
>         srl     t1,0x8,t1
>         xor     t1,t2,t1
>         zapnot  t1,0xf,t0 # redundant zero-extension
>         srl     t0,0x4,t0
>         xor     t0,t1,t0
>         and     t0,0xf,t0
>         sra     v0,t0,v0
>         and     v0,0x1,v0
> 
> -fsee doesn't change anything here.
> 

Compaq C generates:
0000000000000000 <parity>:
   0:   82 16 02 4a     srl     a0,0x10,t1
   4:   96 69 bf 20     lda     t4,27030
   8:   02 08 02 46     xor     a0,t1,t1
   c:   83 16 41 48     srl     t1,0x8,t2
  10:   02 08 43 44     xor     t1,t2,t1
  14:   84 96 40 48     srl     t1,0x4,t3
  18:   02 08 44 44     xor     t1,t3,t1
  1c:   02 f0 41 44     and     t1,0xf,t1
  20:   82 07 a2 48     sra     t4,t1,t1
  24:   00 30 40 44     and     t1,0x1,v0
  28:   01 80 fa 6b     ret


-- 

mattst88 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mattst88 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27469

Reply via email to