[FFmpeg-cvslog] Don't use _tzcnt instrinics with clang for windows w/o BMI.

Dale Curtis git at videolan.org
Wed Oct 25 22:52:27 EEST 2017


ffmpeg | branch: master | Dale Curtis <dalecurtis at chromium.org> | Tue Oct 24 13:03:59 2017 -0700| [50e30d9bb71e1dff27be16c264fac90e362b9896] | committer: Michael Niedermayer

Don't use _tzcnt instrinics with clang for windows w/o BMI.

Technically _tzcnt* intrinsics are only available when the BMI
instruction set is present. However the instruction encoding
degrades to "rep bsf" on older processors.

Clang for Windows debatably restricts the _tzcnt* instrinics behind
the __BMI__ architecture define, so check for its presence or
exclude the usage of these intrinics when clang is present.

See also:
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-November/183404.html
https://bugs.llvm.org/show_bug.cgi?id=30506
http://lists.llvm.org/pipermail/cfe-dev/2016-October/051034.html

Signed-off-by: Dale Curtis <dalecurtis at chromium.org>
Reviewed-by: Matt Oliver <protogonoi at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=50e30d9bb71e1dff27be16c264fac90e362b9896
---

 libavutil/x86/intmath.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h
index e83971c084..40743fd13e 100644
--- a/libavutil/x86/intmath.h
+++ b/libavutil/x86/intmath.h
@@ -47,7 +47,8 @@ static av_always_inline av_const int ff_log2_x86(unsigned int v)
 #   endif
 #   define ff_log2_16bit av_log2
 
-#if defined(__INTEL_COMPILER) || (defined(_MSC_VER) && (_MSC_VER >= 1700))
+#if defined(__INTEL_COMPILER) || (defined(_MSC_VER) && (_MSC_VER >= 1700) && \
+                                  (defined(__BMI__) || !defined(__clang__)))
 #   define ff_ctz(v) _tzcnt_u32(v)
 
 #   if ARCH_X86_64



More information about the ffmpeg-cvslog mailing list