I’m very stumped.
When I run this code in Visual C++ 2008:
__m128i a, b;
a.m128i_u64[0] = 1;
b.m128i_u64[0] = 0;
a.m128i_u64[1] = 0;
b.m128i_u64[1] = 0;
printf("%d\n", _mm_testc_si128(a, b));
it prints 1. Which is contrary to what I expect, because it’s supposed to be 1 only if a and b are the same.
How is this possible? Is there a bug in my CPU or in Visual C++ 2008 or something else?
I know for a fact that a lot of SSE4.1 intrinsics are broken in VS2008. They fixed them for VS2010. In VS2010 (no SP), some of the AVX intrinsics are broken. They fixed those in VS2010 SP1.
I’ve never used the
_mm_testc_si128intrinsic, so I don’t know if that’s another intrinsic that’s broken in VS2008. But I’ve seen numerous cases where insert/extract intrinsics were broken.EDIT : I just tested this in VS2010 SP1, it also gives 1.
Now that I look at the documentation, it looks like it “should” be returning 1.
So I don’t think it’s a bug in this case.