qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Frediano Ziglio <frediano.ziglio@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] x86_64: optimise muldiv64 for x86_64 architecture
Date: Fri, 09 Jan 2015 12:00:17 -0800	[thread overview]
Message-ID: <54B03351.8000405@twiddle.net> (raw)
In-Reply-To: <1420797188-20833-1-git-send-email-frediano.ziglio@huawei.com>

On 01/09/2015 01:53 AM, Frediano Ziglio wrote:
> As this platform can do multiply/divide using 128 bit precision use
> these instruction to implement it.
> 
> Signed-off-by: Frediano Ziglio <frediano.ziglio@huawei.com>
> ---
>  include/qemu-common.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index f862214..5366220 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -370,6 +370,7 @@ static inline uint8_t from_bcd(uint8_t val)
>  }
>  
>  /* compute with 96 bit intermediate result: (a*b)/c */
> +#ifndef __x86_64__
>  static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
>  {
>      union {
> @@ -392,6 +393,18 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
>      res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
>      return res.ll;
>  }
> +#else
> +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;
> +}
> +#endif

Honestly, this ought to move into qemu/host-utils.h, and it should
use __int128 for targets that support it.  Which includes x86_64,
but also other 64-bit hosts.


r~

  reply	other threads:[~2015-01-09 20:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09  9:53 [Qemu-devel] [PATCH] x86_64: optimise muldiv64 for x86_64 architecture Frediano Ziglio
2015-01-09 20:00 ` Richard Henderson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-01-09 10:27 Frediano Ziglio
2015-01-09 10:35 ` Paolo Bonzini
2015-01-09 11:04   ` Frediano Ziglio
2015-01-09 11:24     ` Paolo Bonzini
2015-01-09 11:38       ` Peter Maydell
2015-01-09 12:07       ` Frediano Ziglio

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=54B03351.8000405@twiddle.net \
    --to=rth@twiddle.net \
    --cc=aliguori@amazon.com \
    --cc=frediano.ziglio@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).