shithub: sl

ref: ea74e72bf9f4ba8cc9bf290b3c6c748bc277d48e
dir: /src/plan9/popcount.c/

View raw version
#include "platform.h"

int
fl_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;
}