Reputation: 1294
I know how to test if an _m128i register is all zero with the _mm_test_all_zeros
intrinsic.
What is the AVX2 / __m256i version of this intrinsic? If one isn't available, what is the fastest way to test if all 256 bits in a SIMD register are zero?
Upvotes: 6
Views: 1908
Reputation: 21946
The fastest is probably vptest
instruction.
// Return 1 if `x` is all zeros, otherwise 0
inline int test_all_zeros( __m256i x )
{
return _mm256_testz_si256( x, x );
}
Upvotes: 16