microsoft / STL

MSVC's implementation of the C++ Standard Library.
Other
10.07k stars 1.48k forks source link

ARM64 `__popcnt` intrinsics #4683

Closed StephanTLavavej closed 3 months ago

StephanTLavavej commented 4 months ago

In VS 2022 17.11 Preview 1, MSVC-PR-530436 updated intrin0.inl.h to extend the previously x86/x64 __popcnt intrinsic family to ARM64:

__MACHINEX86_X64_ARM64(unsigned int __popcnt(unsigned int))
__MACHINEX86_X64_ARM64(unsigned short __popcnt16(unsigned short))
__MACHINEARM64_X64(unsigned __int64 __popcnt64(unsigned __int64))

It's unclear to me whether it would be simpler and/or faster to replace our existing ARM64 codepath:

https://github.com/microsoft/STL/blob/63354c3fa9c1fb2ab1fccb58c47d23c6af1c290f/stl/inc/__msvc_bit_utils.hpp#L351-L356