From 354660a42caee3356556bc9c0ae68e60b7009d37 Mon Sep 17 00:00:00 2001 From: pratham-mcw Date: Thu, 12 Jun 2025 15:55:37 +0530 Subject: [PATCH 1/2] Remove ARM exclusion for __popcnt on MSVC --- modules/bgsegm/src/bgfg_gsoc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bgsegm/src/bgfg_gsoc.cpp b/modules/bgsegm/src/bgfg_gsoc.cpp index 0ed67648210..2cc33febfc6 100644 --- a/modules/bgsegm/src/bgfg_gsoc.cpp +++ b/modules/bgsegm/src/bgfg_gsoc.cpp @@ -70,7 +70,7 @@ const float LSBPtau = 0.05f; inline int LSBPDist32(unsigned n) { #if defined(__GNUC__) || defined(__clang__) return __builtin_popcount(n); -#elif defined(_MSC_VER) && !(defined(_M_ARM) || defined(_M_ARM64)) +#elif defined(_MSC_VER) return __popcnt(n); #else // Taken from http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel From 1cb94494cc2e41317b4ace4b51def8cca74eb58a Mon Sep 17 00:00:00 2001 From: pratham-mcw Date: Tue, 24 Jun 2025 10:20:50 +0530 Subject: [PATCH 2/2] fix popcnt for msvc on arm64 compilation --- modules/bgsegm/src/bgfg_gsoc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bgsegm/src/bgfg_gsoc.cpp b/modules/bgsegm/src/bgfg_gsoc.cpp index 2cc33febfc6..49cdcbc8881 100644 --- a/modules/bgsegm/src/bgfg_gsoc.cpp +++ b/modules/bgsegm/src/bgfg_gsoc.cpp @@ -70,7 +70,7 @@ const float LSBPtau = 0.05f; inline int LSBPDist32(unsigned n) { #if defined(__GNUC__) || defined(__clang__) return __builtin_popcount(n); -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && !(defined(_M_ARM) || (defined(_M_ARM64) && _MSC_VER < 1941)) return __popcnt(n); #else // Taken from http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel