From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnpoV-0006Re-1u for qemu-devel@nongnu.org; Sun, 08 Jul 2012 07:38:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SnpoT-0008Hh-GH for qemu-devel@nongnu.org; Sun, 08 Jul 2012 07:38:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SnpoT-0008HO-7J for qemu-devel@nongnu.org; Sun, 08 Jul 2012 07:38:05 -0400 Message-ID: <4FF97114.1050507@redhat.com> Date: Sun, 08 Jul 2012 14:37:56 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1340653135-26749-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Blue Swirl , Peter Maydell , qemu-devel@nongnu.org, Jia Liu , patches@linaro.org On 06/28/2012 08:58 AM, Markus Armbruster wrote: >>> >>> Better code is an argument only if the effect can be demonstrated. >> >> I don't know even for which compilers or CPUs this is true so it's >> unlikely I could demonstrate it. However, googling finds a few >> articles in defense of this. > > Hearsay. Your honor, I rest my case :) On x86_64, conversion from unsigned to unsigned long takes zero instructions, but conversion from int to long takes one instruction. So expressions like a[i] are one instruction shorter if the index is unsigned. unsigned is also slightly safer from a security perspective, since you only need to consider overflow, not underflow. I used to be an int fan but I have been converted. My fingers still prefer int though. -- error compiling committee.c: too many arguments to function