I am trying to understand how the following code snippet works. This program uses SIMD vector instructions (Intel SSE) to calculate the absolute value of 4 floats (so, basic
-0.0
is represented as 1000...000
1. Therefore _mm_andnot_ps(-0.0, x)
2 is equivalent to 0111...111 & x
. This forces the MSB (which is the sign bit) to 0.
2. The _mm_andnot_ps
intrinsic does not mean "NAND"; see e.g. http://msdn.microsoft.com/en-us/library/68h7wd02(v=vs.90).aspx.