Going by [1], it looks like we can use the __popcnt and __popcnt64 intrinsic functions on MSVC if the CPU supports POPCNT. We already have code to check for that, we just need to enable it on MSVC.
The attached patch seems to be all that's needed. David [1] https://docs.microsoft.com/en-us/cpp/intrinsics/popcnt16-popcnt-popcnt64?view=msvc-140
use_popcnt_on_msvc.patch
Description: Binary data