Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

__m256i version of _mm_test_all_zeros

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?

like image 482
Thomas Kejser Avatar asked Dec 17 '22 17:12

Thomas Kejser


1 Answers

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 );
}
like image 143
Soonts Avatar answered Mar 06 '23 02:03

Soonts