diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c
index b6a1c3dca926649001101819bd2a146c134ce09a..c8d7ca56777e8d914ba8d963e8519f89ac626e42 100644
--- a/libswscale/x86/yuv2rgb_template.c
+++ b/libswscale/x86/yuv2rgb_template.c
@@ -168,7 +168,7 @@
         : "r" (pu - index), "r" (pv - index), "r"(&c->redDither), "r" (py - 2*index) \
         ); \
     } \
-    __asm__ volatile (EMMS); \
+    __asm__ volatile (SFENCE"\n\t"EMMS); \
     return srcSliceH; \
 
 #define YUV2RGB_OPERANDS_ALPHA \
@@ -176,7 +176,7 @@
         : "r" (pu - index), "r" (pv - index), "r"(&c->redDither), "r" (py - 2*index), "r" (pa - 2*index) \
         ); \
     } \
-    __asm__ volatile (EMMS); \
+    __asm__ volatile (SFENCE"\n\t"EMMS); \
     return srcSliceH; \
 
 static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,