Received: from eggs.gnu.org ([2001:4830:134:3::10]:46658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzlD8-0007gf-Db for qemu-devel@nongnu.org; Thu, 27 Oct 2016 09:59:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzlD4-0003v0-B4 for qemu-devel@nongnu.org; Thu, 27 Oct 2016 09:59:14 -0400 Date: Fri, 28 Oct 2016 00:28:05 +1100 From: David Gibson Message-ID: <20161027132805.GR19918@umbus.fritz.box> References: <1477463189-26971-1-git-send-email-nikunj@linux.vnet.ibm.com> <1477463189-26971-6-git-send-email-nikunj@linux.vnet.ibm.com> <20161027034734.GN19918@umbus.fritz.box> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ivHc2SZskddb40s2" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: Nikunj A Dadhania , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com, sandipandas1990@gmail.com, ego@linux.vnet.ibm.com, Ankit Kumar --ivHc2SZskddb40s2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 26, 2016 at 10:22:10PM -0700, Richard Henderson wrote: > On 10/26/2016 08:47 PM, David Gibson wrote: > > > > +void helper_vprtybq(ppc_avr_t *r, ppc_avr_t *b) > > > > +{ > > > > + int i; > > > > + uint8_t s =3D 0; > > > > + for (i =3D 0; i < 16; i++) { > > > > + s ^=3D (b->u8[i] & 1); > > > > + } > > > > + r->u64[LO_IDX] =3D (!s) ? 0 : 1; > > > > + r->u64[HI_IDX] =3D 0; > > > > +} > > > > + > > I think you can implement these better. First mask with 0x01010101 > > (of the appropriate length) to extract the LSB bits of each byte. > > Then XOR the two halves together, then quarters and so forth, > > ln2(size) times to arrive at the parity. This is similar to the usual > > Hamming weight implementation. > >=20 >=20 > You don't even have to mask with 0x01010101 to start. Just fold halves t= il > you get to the byte level and then mask with 1. Good point. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --ivHc2SZskddb40s2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYEgDiAAoJEGw4ysog2bOSrOYQALkS1WXYJxVLqf3OMUe4+kBQ /DStObIwweC6YwPHI919fUgB7n6v2nvlN9QKM+MvTAf/wGeMv0/n3qsHYmuO7cDq SVqjjkuWi6unnIifKum4zQD8S4AJCt6ed06ALOjPCunAWJYQ5sDD9X3MJcYhMMIx DCm/lvY1/HEPBiktU31DEi960eQEiTUgWJBh3M05IN8GvgB/TZTIM7ptA5ww/2fa a5qKDGswinV6hK7NFMnWz6/fnphScZVm3QDsBWPsmEYgJBU7GZYAHG3V7ru3z15Z DxXG/MyMGCFP+cbhTStXUXbhojJRJfEMTZYP3tbUdgKjx1wJvTrGEF4C6NpaAJl8 QJt4Sr28vNyUby535VisjbwCmKHZbT/xORIqvUlgVZV96fmJJj4ubN/4iC2sO1Fz khEnFbr3U+zhe3dV64C8OfTTJTzQIPa81tJSbSWjMiyedTQo/knizbWP9etIoUS3 npydlWxuFwl+3Zv36CUQGpXn60ZY7s3lNRqj8VrYUPwyOkCCppqRCdJX3m/wogoM EQskD03PZHQeqv9b+tX6Jk+mDxab6eUyiCFA7L0u9awxpMjktPfSfhkRCvJeS3Uw DYEq3eBk66hudCDJgBqJ4vuZXVZwPWAKNZO45S3SRBCTwy4xG/O2L3zqPP1dyIdk k9sxONzaIowE9N4Y/fhf =DW2k -----END PGP SIGNATURE----- --ivHc2SZskddb40s2--