From: "Jan Beulich" Subject: Re: [PATCH] linux/x86: convert 'cpu' (and a few other)variables to unsigned Date: Fri, 18 Jan 2008 16:27:49 +0000 Message-ID: <4790E195.76E4.0078.0@novell.com> References: <4790DC8F.76E4.0078.0@novell.com> <18320.53497.157752.151108@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <18320.53497.157752.151108@mariner.uk.xensource.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> Ian Jackson 18.01.08 17:16 >>> >Jan Beulich writes ("[Xen-devel] [PATCH] linux/x86: convert 'cpu' (and a = few other) variables to unsigned"): >> .. producing better code for x86-64. >>=20 >> As usual, written and tested on 2.6.24-rc7 and made apply to the 2.6.18 >> tree without further testing. > >In what way does this produce better code for x86-64 ? When signed int is used as array index or in pointer arithmetic, the compiler has to insert an explicit, unconditional sign extension operation, whereas in many cases zero extension is implicit by preceding operations or can be done with a 32-bit move (which doesn't require a REX prefix and thus results in [statisitically]=20 half a byte shorter instructions). >Normally it's IMO best practice to avoid `unsigned' other than for >bitfields, clock arithmetic, and the like, because the behaviour of >unsigned in the presence of subtraction and comparision is often >surprising. I would disagree here, but it's certainly a personal thing what's considered surprising. Regardless of this personal aspect, the x86 Linux maintainers are actively doing the same thing (or are respectively asking for it to be done). Jan