[tremor] A possible improvement for some of the processor where tables hit hard

Nicolas Pitre nico at cam.org
Sat Oct 19 19:02:21 PDT 2002



On Wed, 16 Oct 2002, Monty wrote:

> On Sun, Oct 13, 2002 at 04:01:56PM -0400, marc dukette wrote:
> > I have replaced the mask table in bitwise.c with the following, and while it
> > has little to no effect on an SA processor it does appear to help the
> > version we have running on MIPS, so it may be of value to other processors
> > as well:
> > 
> > old:
> >   unsigned long m= mask[bits];
> > 
> > new:
> >   unsigned long m= (((unsigned int)-1)>>(32-bits));
> > 
> > and of course you can now remove the mask table.  I'm just throwing this
> > out, not sure if it's worth adding to the standard or not.
> 
> Good basic idea, but not equivalent.  In the case where bits==0...

What's wrong here?  0xffffffffUL >> (32 - 0) should be 0 like the lookup 
table.

Or what about: unsigned long m = (1 << bits) - 1;

The ARM assembly for this could be just this:

        mov	r1, #1
        rsb	r1, r1, r1, lsl r0

where r0 = bits and r1 = m.  This would certainly be faster than a table 
lookup, but I doubt any compiler would generate that by itself though.

<p>Nicolas

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'tremor-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Tremor mailing list