Open utterances-bot opened 2 years ago
Nice article.The vectorization example can be way simpler: cmp
to compare each byte, pmovmskb
to take the high bit of each byte, then lzcnt
. Supported back to SSE2 (for 128b regs). If you have AVX-512, then you can compare into a k reg directly.
Nice article.The vectorization example can be way simpler:
cmp
to compare each byte,pmovmskb
to take the high bit of each byte, thenlzcnt
. Supported back to SSE2 (for 128b regs). If you have AVX-512, then you can compare into a k reg directly.
The post is about what was possible with the Vector API prototype back in 2019. It may be possible to write simpler code now, but the API abstracts over instruction sets so won’t look exactly the same.
Ah right, looks like that sequence could be abstracted by VectorMask<T>::firstTrue()
in JDK16.
Finding Bytes in Arrays | Richard Startin’s Blog
Thanks to everybody who reviewed and made helpful suggestions to improve this post.
https://richardstartin.github.io/posts/finding-bytes