Open deepinthebuild opened 6 years ago
That would definitely be feasible, but I'm wondering if there's a way to make this portable for all vector lengths, though. Perhaps a bit_vec::BitVec
would be a more suitable return type?
a u64 is large enough for all existing vector types, including AVX-512. 512 bits is only u8x64, after all.
To be clear about what I'm after, I want an operation that takes a vector like:
u8x8(255, 255, 0, 255, 255, 0, 0, 0)
and returns a u64:
0b00011011
where the nth least significant bit of the output is set to 1 if the nth byte of the input is 255.
It would be useful to me if there were an operation like
fn bytemask<T: Packed>(v: T) -> usize
that set the bits of the usize to 1 where the packed vector's bytes are all 1, corresponding to the asm PMOVMSKB or VPMOVMSKB. I don't know how possible this would be for faster, but it would be nice.