From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSz9H-00062f-6Y for qemu-devel@nongnu.org; Fri, 29 Jul 2016 00:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSz9F-0004Zc-1q for qemu-devel@nongnu.org; Fri, 29 Jul 2016 00:11:46 -0400 Date: Fri, 29 Jul 2016 13:46:41 +1000 From: David Gibson Message-ID: <20160729034641.GJ2588@voom.fritz.box> References: <1469688581-30853-1-git-send-email-nikunj@linux.vnet.ibm.com> <1469688581-30853-5-git-send-email-nikunj@linux.vnet.ibm.com> <900e59b4-16f6-25ef-ab82-c33f9fcedcd3@twiddle.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lYetfuAxy9ic4HK3" Content-Disposition: inline In-Reply-To: <900e59b4-16f6-25ef-ab82-c33f9fcedcd3@twiddle.net> Subject: Re: [Qemu-devel] [PATCH v1 4/8] target-ppc: add vabsdu[b, h, w] 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, aneesh.kumar@linux.vnet.ibm.com, benh@kernel.crashing.org, Sandipan Das --lYetfuAxy9ic4HK3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 28, 2016 at 06:22:05PM +0530, Richard Henderson wrote: > On 07/28/2016 12:19 PM, Nikunj A Dadhania wrote: > > + r->element[i] =3D abs(a->element[i] - b->element[i]); = \ > > + } = \ > > +} > > + > > +/* VABSDU - Vector absolute difference unsigned > > + * name - instruction mnemonic suffix (b: byte, h: halfword, w: w= ord) > > + * element - element type to access from vector > > + */ > > +#define VABSDU(type, element) \ > > + VABSDU_DO(absdu##type, element) > > +VABSDU(b, u8) > > +VABSDU(h, u16) > > +VABSDU(w, u32) >=20 > From whence are you receiving this abs definition, and how do you expect = it > to work with an unsigned input? >=20 > I can only imagine you're getting abs(3), aka int abs(int), from stdlib.h. > Which technically does work post-arithmetic promotion for u8 and u16, but= it > does not for u32. So, I noticed this and was also concerned, but I more or less convinced myself that it would still work, by the magic of 2's complement, as long as sizeof(int) >=3D 4. Maybe I'm wrong, though. > I think we'd prefer an explicit (a > b ? a - b : b - a). That probably is easier to follow, though. --=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 --lYetfuAxy9ic4HK3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXmtGhAAoJEGw4ysog2bOSMoIQAJNi7+b8mfakwRh9Bu9SSiE7 h5ygRB+6X8R2XhrtfsnNQzsu+a1a1WRLUBsSJSroksj90rZTFTE4qc79n8vVVvmP +ziG4CNruQjAzQx0aVYz00USGICIwi7ROzW84lKNWM7nC1QEPEmqBt32q0P9tOvh FZ1DfPbL2ULQNskQE/bmrinP0XyU7uCMK5mP+O7rWPR11C5SD7cNsr7ev6VoaWXE k7Gy5tUuvZE8jJA+fTB11VuTUy9b7n9oxyC2EBzAnWCHQf1VHiK5SVj/kgapFXof YsaFK50g/K9OAJiZjIsyw6gqAkYgPVUra0SUo0C0wftlFGUX+kXDV4nRlop0zIm1 lm6LhreF8ZIGxPDhONFR8eWXr0iMt4xzNBeku0q/0n9R4dXIBKLUiG9jZfOqPfR6 2e8Hwb31+62k4gMNwSEb53EjixZiqHMltDM7gGaJLBcvyWe+eY5pCyz1ciZLO6ja vqIy3P2uP86Ye4mwPf4kvMZqWVB93fvDK9shgVWvvElwsvAaM8EPRR0kROgrm9iA AU6RsxNLYp57WXnMPpt/HbMscX0lGOsU8OkRy87cO1U+xPKqcvRxA026rFAX/h6U 1G1Oy2mF/920DqO60gMNnT0ypS1RWPXUqTTEoPi9jgpHcbjQSS+w8IxFQSqpCzp7 ++OAKBWTMKtahW8zJ4za =w1x5 -----END PGP SIGNATURE----- --lYetfuAxy9ic4HK3--