From 0facc4be457b68b7b4ef52badfce8b46b2914cfd Mon Sep 17 00:00:00 2001 From: Henrik Gramner Date: Sat, 21 May 2011 19:04:46 +0200 Subject: [PATCH] Inline emms instructions on x86 if possible --- common/cpu.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.47.3