Changeset 41


Ignore:
Timestamp:
Feb 11, 2008, 5:26:11 AM (11 years ago)
Author:
cameron
Message:

PPC bitstream_scan fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/altivec_simd.h

    r40 r41  
    380380static inline int bitstream_scan(SIMD_type * stream, int bit_posn) {
    381381  unsigned long * bitstream_ptr = (unsigned long *) (((intptr_t) stream) + bit_posn/8);
    382   unsigned long bitstream_slice = *bitstream_ptr & (-1L << bit_posn % 8);
    383   int base_posn;
    384   if (bitstream_slice == 0) {
     382  unsigned long bitstream_slice = *bitstream_ptr << (bit_posn % 8);
     383  if (bitstream_slice != 0) return bit_posn + __builtin_clzl(bitstream_slice);
     384  else {
    385385    do {
    386386      bitstream_ptr++;
    387387      bitstream_slice = *bitstream_ptr;
    388388    } while (bitstream_slice == 0);
     389    int base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
     390    return base_posn + __builtin_clzl(bitstream_slice);
    389391  }
    390   base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
    391   return base_posn + __builtin_clzl(bitstream_slice);
    392392}
    393393
Note: See TracChangeset for help on using the changeset viewer.