qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] int128: optimize


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] int128: optimize
Date: Tue, 02 Jul 2013 16:54:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

Il 02/07/2013 14:46, Jay Foad ha scritto:
>>  static inline Int128 int128_neg(Int128 a)
>>  {
>> -    a.lo = ~a.lo;
>> -    a.hi = ~a.hi;
>> -    return int128_add(a, int128_one());
>> +    uint64_t lo = -a.lo;
>> +    return (Int128) { lo, ~a.hi + !lo };
>>  }
> 
> This leaves int128_one unused. (Also the temporary lo seems a bit
> pointless, since you could just as well write -a.lo and !a.lo.)

The unused int128_one is not a problem, someone might find a use later.

>>  static inline bool int128_ge(Int128 a, Int128 b)
>>  {
>> -    return int128_nonneg(int128_sub(a, b));
>> +    return a.hi > b.hi || (a.hi == b.hi && a.lo >= b.lo);
>>  }
> 
> This is a bug fix. The old version gives the wrong answer when a and b
> are both large and have opposite signs.

We don't really use Int128's that are bigger than 2^64, but you are
right.  I'll add this to the commit message.

Paolo



reply via email to

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