simde icon indicating copy to clipboard operation
simde copied to clipboard

Remove use of native MMX intrinsics

Open easyaspi314 opened this issue 1 year ago • 18 comments

MMX is broken on modern compilers and should be avoided at all costs.

Reasons:

  • ⚠️Clang and GCC DO NOT automatically switch between MMX and x87 resulting in undefined behavior and potentially X87 overflows. MMX expects the programmer to manually keep X87 and MMX separate with _mm_empty() in between, and in a library like this, the user shouldn't be expected to do this.
  • GCC converts MMX to SSE2 on x64.
  • Clang does not know how to properly optimize MMX vectors and generates garbage, especially when it clashes with autovectorization
  • GCC and Clang will never autovectorize MMX
  • MMX is not supported on the Windows x64 calling convention — only context switch safety is guaranteed
  • MMX has fewer registers on x64
  • When using NEON, half vectors are constantly converted back and forth so conversions should be fast.
  • Operating systems that require MMX without requiring SSE2 are relatively uncommon.
  • SSE2 is always available on x64

easyaspi314 avatar May 21 '23 19:05 easyaspi314