All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, Jia Liu <proljc@gmail.com>,
	patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields
Date: Sun, 08 Jul 2012 14:37:56 +0300	[thread overview]
Message-ID: <4FF97114.1050507@redhat.com> (raw)
In-Reply-To: <m3r4t0565f.fsf@blackfin.pond.sub.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

       reply	other threads:[~2012-07-08 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1340653135-26749-1-git-send-email-peter.maydell@linaro.org>
     [not found] ` <CAAu8pHuqj513DVNLXqsdD2Qg9+LwDHz6DzQxYn-HEnAA=0Unwg@mail.gmail.com>
     [not found]   ` <CAFEAcA-uHBFkfcwCtv0EKcJRNzYYf_jtTs1W9BECEeJo6gT+Xg@mail.gmail.com>
     [not found]     ` <CAAu8pHtcv6Z4Sa4FY53tA3zp3n8xBvQD_E1yYugaAVa-36eZow@mail.gmail.com>
     [not found]       ` <CAFEAcA8_BXHb8VPf8sqfJs39JF-CagaHj92tzA6ijtgnSVhmcA@mail.gmail.com>
     [not found]         ` <CAAu8pHtWt+aAaO-Vr_N5z7_qqzWknP+nRsxPg+iQAeoHdzmF4w@mail.gmail.com>
     [not found]           ` <m3zk7p2szw.fsf@blackfin.pond.sub.org>
     [not found]             ` <CAAu8pHv_CjT+bd_GA4eM9eG=1Sxz0EWF=nhSLTyixNjOXPMhTg@mail.gmail.com>
     [not found]               ` <m3r4t0565f.fsf@blackfin.pond.sub.org>
2012-07-08 11:37                 ` Avi Kivity [this message]
2012-07-08 11:45                   ` [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FF97114.1050507@redhat.com \
    --to=avi@redhat.com \
    --cc=armbru@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=proljc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.