So first I'll just describe the task:
I need to:
- Compare two
__m128i
. - Somehow do the bitwise and of the result with a certain
uint16_t
value (probably using_mm_movemask_epi8
first and then just&
). - Do the
blend
of the initial values based on the result of that.
So the problem is as you might've guessed that blend accepts __m128i
as a mask and I will be having uint16_t
. So either I need some sort of inverse instruction for _mm_movemask_epi8
or do something else entirely.
Some points -- I probably cannot change that uint16_t
value to some other type, it's complicated; I doing that on SSE4.2, so no AVX; there's a similar question here How to perform the inverse of _mm256_movemask_epi8 (VPMOVMSKB)? but it's about avx and I'm very inexperienced with this so I cannot adopt the solution.
PS: I might need to do that for arm as well, would appreciate any suggestions.
uint16_t
to a mask for_mm_and_si128
, since that can happen in parallel with comparing the __m128i inputs, and avoids a round-trip. See also is there an inverse instruction to the movemask instruction in intel avx2? for a list of links, including Convert 16 bits mask to 16 bytes mask which has an SSSE3 version.