[x264-devel] Inline emms instructions on x86 if possible

Henrik Gramner git at videolan.org
Wed Jun 15 04:54:18 CEST 2011


x264 | branch: master | Henrik Gramner <hengar-6 at student.ltu.se> | Sat May 21 19:04:46 2011 +0200| [0facc4be457b68b7b4ef52badfce8b46b2914cfd] | committer: Jason Garrett-Glaser

Inline emms instructions on x86 if possible

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=0facc4be457b68b7b4ef52badfce8b46b2914cfd
---

 common/cpu.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/common/cpu.h b/common/cpu.h
index 6408566..d539de2 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



More information about the x264-devel mailing list