Copy bits of uint64_t into two uint64_t at specific location

  bit-manipulation, bmi, c++, x86

I have an input uint64_t X and number of its N least significant bits that I want to put into the target Y, Z uint64_t values starting from bit index M in the Z. How I can implement it efficiently in C++ for the latest intel CPUs?

illustration:

illustration

Source: Windows Questions C++

LEAVE A COMMENT