simdsseintrinsicssse2

What is the difference between these 128bit SIMD xor operations


Intel provides several SIMD commands, which seems all performing bitwise XOR on 128-bit data:

_mm_xor_pd(__m128d, __m128d)
_mm_xor_ps(__m128, __m128)
_mm_xor_si128(__m128i, __m128i)

Isn't bitwise operations only operate on bit streams? Why there are three operations that have different type but same data size?


Solution

  • _mm_xor_pd(__m128d, __m128d) operates on two 64 bit double precision floats

    [https://msdn.microsoft.com/en-us/library/w87cdc33%28v=vs.90%29.aspx1

    _mm_xor_ps(__m128d, __m128d) operates on four 32 bit single precision floats

    https://msdn.microsoft.com/en-us/library/ss6k3wk8(v=vs.90).aspx

    _mm_xor_si128(__m128d, __m128d) operates on one 128 bit value

    https://msdn.microsoft.com/en-us/library/fzt08www%28v=vs.90%29.aspx

    An XOR can be used between any two binary numbers regardless of their format. Why three? Because it's a balance to support common data types (float, double and 128 bits) and not have two many instructions.

    The balance is the amount of silicon used, as each set of operations may occur in a separate functional units (integer, float, double). If they use different silicon all the different types of operation could execute in parallel.