From owner-cvs-src@FreeBSD.ORG Wed Nov 5 22:46:45 2003 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 33C3F16A4CF for ; Wed, 5 Nov 2003 22:46:45 -0800 (PST) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id AFC024401A for ; Wed, 5 Nov 2003 22:46:42 -0800 (PST) (envelope-from nate@rootlabs.com) Received: (qmail 17091 invoked by uid 1000); 6 Nov 2003 06:47:00 -0000 Date: Wed, 5 Nov 2003 22:47:00 -0800 (PST) From: Nate Lawson To: Peter Wemm In-Reply-To: <20031106012459.0094816A542@hub.freebsd.org> Message-ID: <20031105224619.Q17086@root.org> References: <20031106012459.0094816A542@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/i386/i386 mp_machdep.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2003 06:46:45 -0000 On Wed, 5 Nov 2003, Peter Wemm wrote: > Modified files: > sys/i386/i386 mp_machdep.c > Log: > OK, this might be a bit silly, but add another popcnt() candidate. > > Revision Changes Path > 1.221 +6 -0 src/sys/i386/i386/mp_machdep.c > > @@ -915,6 +915,12 @@ > * -mcpu=pentiumpro and -march=pentiumpro then gcc-3.1 will use > * an imull, and in that case it is faster. In most other cases > * it appears slightly slower. > + * > + * Another variant (also from fortune): > + * #define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255) > + * #define BX_(x) ((x) - (((x)>>1)&0x77777777) \ > + * - (((x)>>2)&0x33333333) \ > + * - (((x)>>3)&0x11111111)) > */ > static __inline u_int32_t > popcnt(u_int32_t m) Ah, the O(1) bit count, a MSFT interview question. :) -Nate