_mm_mask_popcnt_epi8
Classification
AVX-512, Bit Manipulation, CPUID Test: AVX512_BITALG
Header File
immintrin.h
Instruction
VPOPCNTB xmm {k}, xmm
Synopsis
 _mm_mask_popcnt_epi8(__m128i src, __mmask16 k, __m128i a);
Description
Count the number of logical 1 bits in packed 8-bit integers in "a", and store the results in "dst" using writemask "k" (elements are copied from "src" when the corresponding mask bit is not set).
Operation
DEFINE POPCNT(a) {
	count := 0
	DO WHILE a > 0
		count += a[0]
		a >>= 1
	OD
	RETURN count
}
FOR j := 0 to 15
	i := j*8
	IF k[j]
		dst[i+7:i] := POPCNT(a[i+7:i])
	ELSE
		dst[i+7:i] := src[i+7:i]
	FI
ENDFOR
dst[MAX:128] := 0