This topic has not yet been rated - Rate this topic

_mm_popcnt_u64

Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction popcnt. This instruction calculates the number of bits of the parameter that are set to 1.

int _mm_popcnt_u64 (
   unsigned __int64 a
); 

Parameter

Description

[in] a

An integer.

The number of bits set to one in a.

Intrinsic

Architecture

_mm_popcnt_u64

x64

Header file <nmmintrin.h>

Before you use this intrinsic, software must ensure that the processor supports the instruction.

#include <stdio.h>
#include <nmmintrin.h>

int main ()
{
    unsigned __int64 a = 0x123456789ABCDEF0;

    int res = _mm_popcnt_u64(a);

    printf_s("Result res should be 32: %d\n", res);

    return 0;
}
Result res should be 32: 32

Reference

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Return value type inconsistency?
Code and documentation appear to be out of sync. Should the return value be an __int64 per nmmintrin.h?