Guidelines for When to Use EMMS

Microsoft Specific

These guidelines help you determine when to use the EMMS instruction:

  • If the next instruction is a floating-point instruction, use _mm_empty after an MMX instruction (for example, before doing calculations on floats, doubles, or long doubles).

  • Don't empty when already empty. If the next instruction uses an MMX register, _mm_empty incurs an operation with no benefit (no-op).

  • Use different functions for regions that use floating-point instructions and those that use MMX instructions. This eliminates needing an EMMS instruction within the body of a critical loop.

  • Use _mm_empty during run-time initialization of __m64 and FP data types. This ensures resetting the register between data type transitions. See usage coding in the following example.

Correct EMMS Usage in Initialization Code

Incorrect usage

Correct usage

__m64 x = _m_paddd(y, z);
float f = init();
__m64 x = _m_paddd(y, z);
float f = (_mm_empty(), init());

Further, you must be aware of all situations when your code generates an MMX instruction:

  • When using an MMX intrinsic.

  • When using the Streaming SIMD Extensions (for those intrinsics that use MMX data).

  • When using an MMX instruction through inline assembly.

  • When referencing an __m64 data type variable.

For more documentation on EMMS, see http://developer.intel.com.

MMX intrinsics use the __m64 data type, which is not supported on x64 processors.

See Also

Concepts

MMX Technology

MMX Technology General Support Intrinsics