tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel bitreverse function



>   ((b * 0x80200802ull) & 0x0884422110ull) * 0x0101010101ull >> 32

>   ((b * 0x0802u & 0x22110u) | (b * 0x8020u & 0x88440u)) * 0x10101u >> 16

Maybe.  Do all machines NetBSD still cares about have fast-enough
multiply instructions?  Unless the multiply is unusually fast compared
to shift and mask instructions, I'd say it would likely have a hard
time beating

        b = ((b & 0x0f) << 4) | ((b >> 4) & 0x0f);
        b = ((b & 0x33) << 2) | ((b >> 2) & 0x33);
        b = ((b & 0x55) << 1) | ((b >> 1) & 0x55);

> It is also worth allowing for cpus that can have a hardware
> instruction (and then do it in 1 clock!)

Yes, I'd say this definitely should support MD implementations.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index