shithub: sl

ref: 52d518b5e346b66e9023ec35101480f706810977
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;
}