I'm working on Core i7 on Linux and using g++ 4.63.
I tried the following code:
#include <iostream>
#include <immintrin.h>
int main() {
__m256d a = _mm256_set_pd(1,2,3,4);
__m256d z = _mm256_setzero_pd();
std::cout << _mm256_testz_pd(a,a) << std::endl;
std::cout << _mm256_testz_pd(z,z) << std::endl;
std::cout << _mm256_testz_pd(a,z) << std::endl;
}
It printed 3 1's. I was expecting at least one of them to be 0.
I tried using _mm256_castpd_si256
and then _mm256_testz_si256
, it'll print 0 for the first line.
Why?