Bug 48: Bit Insertion Misguided By Mask
- This is Guy L. Steele Jr.'s parallel suffix algorithm for bit insertion (U.S. Patent 6715066).
- Let n be the number of 1-bits in m. The low n bits of x may be 0 or 1 but all other bits of x must be 0.
- The low n bits of x are moved to positions corresponding to 1-bits in m, preserving their relative order.
- This is Steele's bit extraction method in reverse, repeatedly shifting 1-bits of x high by powers of two.
- A bit that moves a distance of d is shifted high by a series of decreasing powers of two that sum to d.
Fix The Tiny Bug In This Go Code: