From patchwork Tue Mar 9 16:32:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 84346 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o29GWsBF004179 for ; Tue, 9 Mar 2010 16:32:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754784Ab0CIQcy (ORCPT ); Tue, 9 Mar 2010 11:32:54 -0500 Received: from casper.infradead.org ([85.118.1.10]:54611 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754595Ab0CIQcx (ORCPT ); Tue, 9 Mar 2010 11:32:53 -0500 Received: from e35131.upc-e.chello.nl ([213.93.35.131] helo=dyad.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.69 #1 (Red Hat Linux)) id 1Np2MW-0006Ld-Jb for linux-kbuild@vger.kernel.org; Tue, 09 Mar 2010 16:32:52 +0000 Received: by dyad.programming.kicks-ass.net (Postfix, from userid 65534) id 348CA8BF4; Tue, 9 Mar 2010 17:34:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on dyad X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.2.5 Received: from [IPv6:::1] (dyad [192.168.0.60]) by dyad.programming.kicks-ass.net (Postfix) with ESMTP id A372CF7E5; Tue, 9 Mar 2010 17:34:53 +0100 (CET) Subject: Re: [PATCH] x86: Add optimized popcnt variants From: Peter Zijlstra To: Borislav Petkov Cc: "H. Peter Anvin" , Michal Marek , linux-kbuild , Andrew Morton , Wu Fengguang , LKML , Jamie Lokier , Roland Dreier , Al Viro , "linux-fsdevel@vger.kernel.org" , Ingo Molnar , Brian Gerst In-Reply-To: <20100309162352.GB2371@aftab> References: <20100223175457.GA2401@aftab> <4B841BC3.1000908@zytor.com> <20100223190614.GB2401@aftab> <4B875BBD.4060104@zytor.com> <20100226074714.GA15310@aftab> <4B88097E.7010608@zytor.com> <20100227082807.GA21706@aftab> <4B8979DA.9000201@zytor.com> <20100309153628.GA2371@aftab> <1268149840.5037.3.camel@laptop> <20100309162352.GB2371@aftab> Date: Tue, 09 Mar 2010 17:32:49 +0100 Message-ID: <1268152369.5037.10.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 09 Mar 2010 16:32:54 +0000 (UTC) Index: linux-2.6/include/linux/bitops.h =================================================================== --- linux-2.6.orig/include/linux/bitops.h +++ linux-2.6/include/linux/bitops.h @@ -45,31 +45,6 @@ static inline unsigned long hweight_long return sizeof(w) == 4 ? hweight32(w) : hweight64(w); } -/* - * Clearly slow versions of the hweightN() functions, their benefit is - * of course compile time evaluation of constant arguments. - */ -#define HWEIGHT8(w) \ - ( BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + \ - (!!((w) & (1ULL << 0))) + \ - (!!((w) & (1ULL << 1))) + \ - (!!((w) & (1ULL << 2))) + \ - (!!((w) & (1ULL << 3))) + \ - (!!((w) & (1ULL << 4))) + \ - (!!((w) & (1ULL << 5))) + \ - (!!((w) & (1ULL << 6))) + \ - (!!((w) & (1ULL << 7))) ) - -#define HWEIGHT16(w) (HWEIGHT8(w) + HWEIGHT8((w) >> 8)) -#define HWEIGHT32(w) (HWEIGHT16(w) + HWEIGHT16((w) >> 16)) -#define HWEIGHT64(w) (HWEIGHT32(w) + HWEIGHT32((w) >> 32)) - -/* - * Type invariant version that simply casts things to the - * largest type. - */ -#define HWEIGHT(w) HWEIGHT64((u64)(w)) - /** * rol32 - rotate a 32-bit value left * @word: value to rotate