From 630a94b8b7ac987bc97f38df0d0a087d85eb92af Mon Sep 17 00:00:00 2001 From: Anush Elangovan Date: Thu, 4 Oct 2018 10:48:14 -0700 Subject: [PATCH] _tzcnt_u32() is undefined in clang-cl so use alternate impl _tzcnt_u32() is not exported by clang-cl intrin.h so check for clang-cl and enable an alterate for _tzcnt_u32() Some discussions: http://lists.llvm.org/pipermail/cfe-dev/2016-October/051329.html https://bugs.llvm.org/show_bug.cgi?id=30506 TEST=Build with clang-cl --- modules/core/include/opencv2/core/hal/intrin.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/include/opencv2/core/hal/intrin.hpp b/modules/core/include/opencv2/core/hal/intrin.hpp index a321627081..6ab4ccb36c 100644 --- a/modules/core/include/opencv2/core/hal/intrin.hpp +++ b/modules/core/include/opencv2/core/hal/intrin.hpp @@ -368,6 +368,9 @@ inline unsigned int trailingZeros32(unsigned int value) { unsigned long index = 0; _BitScanForward(&index, value); return (unsigned int)index; +#elif defined(__clang__) + // clang-cl doesn't export _tzcnt_u32 for non BMI systems + return value ? __builtin_ctz(value) : 32; #else return _tzcnt_u32(value); #endif