From: Henrik Gramner Date: Sat, 21 May 2011 17:04:46 +0000 (+0200) Subject: Inline emms instructions on x86 if possible X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06fbd9df654cd2b7a025c12b3a7d4b3fb3386e23;p=libx264 Inline emms instructions on x86 if possible --- diff --git a/common/cpu.h b/common/cpu.h index 64085662..d539de22 100644 --- a/common/cpu.h +++ b/common/cpu.h @@ -31,7 +31,16 @@ int x264_cpu_num_processors( void ); void x264_cpu_emms( void ); void x264_cpu_sfence( void ); #if HAVE_MMX +/* There is no way to forbid the compiler from using float instructions + * before the emms so miscompilation could theoretically occur in the + * unlikely event that the compiler reorders emms and float instructions. */ +#if HAVE_X86_INLINE_ASM +/* Clobbering memory makes the compiler less likely to reorder code. */ +#define x264_emms() asm volatile( "emms":::"memory","st","st(1)","st(2)", \ + "st(3)","st(4)","st(5)","st(6)","st(7)" ) +#else #define x264_emms() x264_cpu_emms() +#endif #else #define x264_emms() #endif