qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] int128: optimize


From: Jay Foad
Subject: [Qemu-devel] [PATCH] int128: optimize
Date: Tue, 2 Jul 2013 13:46:40 +0100

>  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.)

>  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.

Jay.

reply via email to

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