I have a case to compare two 128-bit unsigned long long a, b on my computer (i7-11700). I need to find out whether a is greater than or equal to b or not. (a >= b) I try to use AVX2 first. I divide the 128-bit value into four part. ( e.g. a -> a1 a2 a3 a4 , b -> b1 b2 b3 b4 ) Each part is 32-bit of 128-bit. With AVX2, I try with the following code.
maxVal = _mm256_set1_epi32(0xFFFFFFFF);
stop = _mm256_set1_epi32(0);
maskgt = _mm256_cmpgt_epu32_mask(a1, b1);
maskeq = _mm256_cmpeq_epi32_mask(a1, b1);
maskbl = _mm256_or_si256(maskeq, stop);
maskge = _mm256_blendv_epi8(maskgt, maskge, maskbl);
stop = _mm256_blendv_epi8(maxVal, stop, maskbl);
maskgt = _mm256_cmpgt_epu32(a2, b2);
maskeq = _mm256_cmpeq_epi32(a2, b2);
maskbl = _mm256_or_si256(maskeq, stop);
maskge = _mm256_blendv_epi8(maskgt, maskge, maskbl);
stop = _mm256_blendv_epi8(maxVal, stop, maskbl);
maskgt = _mm256_cmpgt_epu32(a3, b3);
maskeq = _mm256_cmpeq_epi32(a3, b3);
maskbl = _mm256_or_si256(maskeq, stop);
maskge = _mm256_blendv_epi8(maskgt, maskge, maskbl);
stop = _mm256_blendv_epi8(maxVal, stop, maskbl);
maskgt = _mm256_cmpgt_epu32(a4, b4);
maskeq = _mm256_cmpeq_epi32(a4, b4);
maskbl = _mm256_or_si256(maskeq, stop);
maskge = _mm256_blendv_epi8(maskgt, maskge, maskbl);
Is there a good way to do the comparison with AVX512? I'm confused with the mask registers. Thanks!