__m128 a;
__m128 b;
How to code a != b
?
what to use: _mm_cmpneq_ps
or _mm_cmpneq_ss
?
How to process the result ?
Can't find adequate docs.
__m128 a;
__m128 b;
How to code a != b
?
what to use: _mm_cmpneq_ps
or _mm_cmpneq_ss
?
How to process the result ?
Can't find adequate docs.
You should probably use
_mm_cmpneq_ps
. However the interpretation of comparisons is a little different with SIMD code than with scalar code. Do you want to test for any corresponding element not being equal ? Or all corresponding elements not being equal ?To test the results of the 4 comparisons from
_mm_cmpneq_ps
you can use_mm_movemask_epi8
.Note that comparing floating point values for equality or inequality is usually a bad idea, except in very specific cases.
For documentation you want these two volumes from Intel:
Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2A: Instruction Set Reference, A-M
Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2B: Instruction Set Reference, N-Z
Consider using the SSE4.1 instruction ptest
This is a single instruction.
The answer to this question also depends on whether you want actual inequality where you'd use something along the lines of what @PaulR has shown:
or whether you want to use some epsilon to specify that elements are still considered to be "equal" if they do not differ more than the threshold:
Example:
Prints: