All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Jay Foad <jay.foad@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] int128: optimize
Date: Tue, 02 Jul 2013 16:54:52 +0200	[thread overview]
Message-ID: <51D2E9BC.1060401@redhat.com> (raw)
In-Reply-To: <CANd1uZm7GFAUcNT=qUQjtAHOp2N8Mrv7=K2gidQrn-_szYK1Tg@mail.gmail.com>

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	other threads:[~2013-07-02 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 12:46 [Qemu-devel] [PATCH] int128: optimize Jay Foad
2013-07-02 14:54 ` Paolo Bonzini [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-06-20 15:00 Paolo Bonzini
2013-06-20 16:46 ` Richard Henderson
2013-06-20 21:20   ` Paolo Bonzini

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=51D2E9BC.1060401@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jay.foad@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.