Received: from eggs.gnu.org ([2001:4830:134:3::10]:59798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzw7v-0001Yr-MD for qemu-devel@nongnu.org; Thu, 27 Oct 2016 21:38:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzw7s-0002Ul-IE for qemu-devel@nongnu.org; Thu, 27 Oct 2016 21:38:35 -0400 Date: Fri, 28 Oct 2016 12:34:21 +1100 From: David Gibson Message-ID: <20161028013421.GE19349@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> <878tta2npr.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GxcwvYAGnODwn7V8" 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 --GxcwvYAGnODwn7V8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 27, 2016 at 07:16:24AM -0700, Richard Henderson wrote: > On 10/27/2016 01:36 AM, Nikunj A Dadhania wrote: > > Right, it does reduce number of operations: > >=20 > > +#define SIZE_MASK(x) ((1ULL << (x)) - 1) > > +static uint64_t vparity(uint64_t f1, uint64_t f2, int size) > > +{ > > + uint64_t res =3D f1 ^ f2; > > + if (size =3D=3D 8) return res; > > + return vparity(res & SIZE_MASK(size/2), res >> (size/2), size/2); > > +} >=20 > Why are you using recursion for something that should be 5 operations? > You're making this more complicated than it needs to be. >=20 > uint64_t res =3D b->u64[0] ^ b->u64[1]; > res ^=3D res >> 32; > res ^=3D res >> 16; > res ^=3D res >> 8; > r->u64[LO_IDX] =3D res & 1; We do need to implement it at multiple sizes, which makes it a bit more complex. But I wonder if it makes sense to do this without a helper, something like gen_vprty() { ... gen(shift right 8) gen(xor) if (size > 2) gen(shift right 16) gen(xor) if (size > 4) gen(shift right 32) gen(xor) if (size > 8) gen(xor hi and low words) gen(mask result bits) } --=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 --GxcwvYAGnODwn7V8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYEqsdAAoJEGw4ysog2bOSi2cQAJ3uIAzV7Y5Yr0q/TPMcV0Ue 8lMQLYt2TDFeqhNltt9hkmsFwd13k8hVdGJbJwMRG8P19bqT+Fd/4Cj2YinyshC4 IxxJeBXE9Ohmy5leV8fdbJPSa/NJE03+rKko9XI8nRC8fnCRQakwySRapU7ITI+K 2Ws0l5J7Z3ZPSiwGZV18vXdw6OS3llL3ajc4fk32s08At9AgnPvJEhMeE88E0xry AVpIh/axdTvH5g4REwf2ALgHozJE0raxaG2O/72zw4XVKSKMHySKn1jm/rWjVhbw CgTgDD4EV4OnGV+0KctOirHJmWA7CjLO3ZgddEFc65MJE+zV9dQpm3/hH7ji1Ku4 PvL3o3waJ5Zia7MpFDkewyQwKZJLfrw9FYQjKrW2DnzoMvFTE8To8NHeSBBxZ9hH 1GQCQ2tY7tTExM6GprA8QTCOmdKcrTbuG6Uzi48vlkVG9xfZtvfESrFBIPS1uP3J dl6ClqXeAkMjucp3ZSlYtBUIfZW0JRUU+yr1UeCZ+k24Wl/dCJjt4D4rGcN7yPJl 7BEv8TMJZjST1S668ju9/tTnb8GsaMV05aMAlSugSQVvgathETzqdCOsnL41Hkcn C6sMelJF2xFvplIOX2+oqDj95cT71WKKkTgTV9g1SmHLTzokkrK1ViPdorW5czkl 8WMIhf4PyEyghRchJdeM =Tpz0 -----END PGP SIGNATURE----- --GxcwvYAGnODwn7V8--