qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH] bitops.h: Add field32() and field64() functions to extract bitfields
Date: Sun, 8 Jul 2012 11:45:33 +0000

On Sun, Jul 8, 2012 at 11:37 AM, Avi Kivity <address@hidden> wrote:
> 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.

Q.E.D. Expect patches to convert bitops to unsigned shortly.

>
> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]