I have two __m256i
vectors (each containing chars), and I want to find out if they are completely identical or not. All I need is true
if all bits are equal, and 0
otherwise.
What's the most efficient way of doing that? Here's the code loading the arrays:
char * a1 = "abcdefhgabcdefhgabcdefhgabcdefhg";
__m256i r1 = _mm256_load_si256((__m256i *) a1);
char * a2 = "abcdefhgabcdefhgabcdefhgabcdefhg";
__m256i r2 = _mm256_load_si256((__m256i *) a2);
pshufb
shuffle-control vectors. There's a lot of crazy stuff you can do with SIMD that's sometimes worth it, and worth thinking about for your use case, that the compiler is not going to do for you. Not even Intel's compiler (which is still better at auto-vectorizing than gcc/clang) - Peter Cordes