I want to ask what is the use for MOVMSKB
operation?
I try to find the documentation, but I cannot find the information related.
I want to ask what is the use for MOVMSKB
operation?
I try to find the documentation, but I cannot find the information related.
The paper you're reading describes in the next sentence exactly what it does:
This instruction creates a 16-bit mask from the most significant bits of 16 signed or unsigned 8-bit integers in a register and zeroes the upper bits [of the destination]
That's exactly what pmovmskb
does on an XMM register, so obviously that's the instruction they're talking about. They intentionally or accidentally left out the p
(for packed-integer) from the mnemonic.
Their diagram of how it works is (incorrectly) labeled with vpmovmskb reg, ymm1
. With a YMM source, vpmovmskb
produces a 32-bit mask.
(Although if the input YMM register has been written via the XMM low half with a VEX-encoded instruction like vpxor xmm1, xmm2, xmm3
, then the upper 16 bytes would be all zero, so they'd get the result they described for a different reason.)
Its use-cases include include search loops like strlen
or memchr
(where lzcnt
/ tzcnt
are useful to find which element once you find a match or mismatch element).
Or creating an index for a lookup table of pshufb
masks e.g. for left-packing, or even as part of parsing IPv4 dotted-quad strings into integers. Fastest way to get IPv4 address from string