shithub: sl

ref: 4f0538a0ae8bc62d076cfd5c60885fe66179e178
dir: /src/plan9/popcount.c/

View raw version
#include "platform.h"

int
sl_popcount(unsigned int w)
{
	w -= (w >> 1) & 0x55555555U;
	w = (w & 0x33333333U) + ((w >> 2) & 0x33333333U);
	w = (w + (w >> 4)) & 0x0F0F0F0FU;
	w = (w * 0x01010101U) >> 24;
	return w;
}