From owner-svn-src-all@FreeBSD.ORG Sat Jul 9 17:04:42 2011 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C87B1065670; Sat, 9 Jul 2011 17:04:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id C99D68FC17; Sat, 9 Jul 2011 17:04:41 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p69H4WlV010389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 9 Jul 2011 20:04:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id p69H4WwH020502; Sat, 9 Jul 2011 20:04:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p69H4WtI020500; Sat, 9 Jul 2011 20:04:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 9 Jul 2011 20:04:32 +0300 From: Kostik Belousov To: Ed Schouten Message-ID: <20110709170432.GL48734@deviant.kiev.zoral.com.ua> References: <201107091429.p69ETNNu003910@svn.freebsd.org> <20110709153628.GJ16219@hoeg.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eULE+JHRRz2mSqwH" Content-Disposition: inline In-Reply-To: <20110709153628.GJ16219@hoeg.nl> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r223884 - head/sys/sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jul 2011 17:04:42 -0000 --eULE+JHRRz2mSqwH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 09, 2011 at 05:36:28PM +0200, Ed Schouten wrote: > Hi Kostik, >=20 > * Konstantin Belousov , 20110709 16:29: > > +static __inline uint16_t > > +bitcount16(uint32_t x) >=20 > Shouldn't we use uint16_t for the argument here? Not sure. uint32_t type of argument avoids repromotion, allowing to do the full-register calculation on both 32 and 64 bit architectures. The function correctly handles non-zero upper half-word on its own. >=20 > When I saw the code, I thought by myself, this could be done more > efficiently: >=20 > | static __inline uint16_t > | bitcount16(uint16_t x) > | { > | > | x =3D (x & 0x5555) + ((x >> 1) & 0x5555); > | x =3D (x & 0x3333) + ((x >> 2) & 0x3333); > | x *=3D 0x1111; > | return (x >> 12); > | } >=20 > But some testing revealed it works for all inputs, except 65536. d'oh! >=20 > --=20 > Ed Schouten > WWW: http://80386.nl/ --eULE+JHRRz2mSqwH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk4YiiAACgkQC3+MBN1Mb4hBxQCgtf1CQybdUzbopmNuPw8ysusr tEgAoK3a/E/FBBoO/16ZZyV2p6ew7w6v =uHxi -----END PGP SIGNATURE----- --eULE+JHRRz2mSqwH--