qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64


From: Frediano Ziglio
Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-common.h: optimise muldiv64 for x86_64 architecture
Date: Fri, 9 Jan 2015 12:09:14 +0000

2015-01-09 11:43 GMT+00:00 Paolo Bonzini <address@hidden>:
>
>
> On 09/01/2015 12:25, Frediano Ziglio wrote:
>>  /* compute with 96 bit intermediate result: (a*b)/c */
>> -#ifdef CONFIG_INT128
>> +#if defined(CONFIG_INT128) && !defined(__x86_64__)
>>  static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
>>  {
>>      return (__int128)a * b / c;
>>  }
>> +#elif defined(__x86_64__)
>> +/* Optimised x64 version. This assume that a*b/c fits in 64 bit */
>> +static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
>> +{
>> +    uint64_t res;
>> +
>> +    asm ("mulq %2\n\tdivq %3"
>> +         : "=a"(res)
>> +         : "a"(a), "qm"((uint64_t) b), "qm"((uint64_t)c)
>> +         : "rdx", "cc");
>> +    return res;
>> +}
>
> Reorder it the other way, and you can simplify the first #if.
>

Yes, I was however thinking about people reading code. The int128
version is much easier to read so I put it first.

> I applied patch 1 locally, and will send a pull request once the tree is
> thawed.
>
> Paolo

Frediano



reply via email to

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