numpy/numpy — pull request #3411 by juliantaylor (2013-06-06 20:49:36+00:00)
Title: ENH: Vectorize float absolute operation with sse2

fabs on x86 can be implemented by masking out the sign bit.
Obtaining such a bit pattern is best done by a bitwise not on the
negative zero.
This is the same operation the compiler will convert fabs to on amd64.

Improves performance by ~1.7/3.5 for float/double for cached data
and ~1.4/1.1 for non-cached data.

If one simplifies the loops gcc could also autovectorize it but with all
hints its almost the same code length and slightly worse assembly.

The code can easily be extended to support AVX by changing vpre and
vtype to 256.