Problem
Does an instruction exist that gathers/extracts the first bit of an int[32]
and stores it into a int
?
I know about the intrinsic
pext
but that is not really what I want.I do have a code for that but I thought maybe there a designated instruction.
- The
ints
array is zero besides the first bit. Ergo, no masking needed.
Code
void ints2bits(int &bits, int *ints) {
bits = (ints[0] << 0) + (ints[1] << 1) + ... + (ints[31] << 31);
}
UPDATE & FEEDBACK:
Just tested harold suggestions. It works very well and I can attain nice speed up.