Received: from eggs.gnu.org ([2001:4830:134:3::10]:39989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBKSc-0002pk-5Q for qemu-devel@nongnu.org; Wed, 14 Jan 2015 04:42:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBKSa-0000B8-Ry for qemu-devel@nongnu.org; Wed, 14 Jan 2015 04:41:58 -0500 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:44573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBKSa-0000Aw-Lh for qemu-devel@nongnu.org; Wed, 14 Jan 2015 04:41:56 -0500 Received: by mail-wg0-f51.google.com with SMTP id x12so7755586wgg.10 for ; Wed, 14 Jan 2015 01:41:56 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 14 Jan 2015 10:41:27 +0100 Message-Id: <1421228492-19856-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1421228492-19856-1-git-send-email-pbonzini@redhat.com> References: <1421228492-19856-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 10/15] qemu-common.h: optimise muldiv64 if int128 is available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Frediano Ziglio , Frediano Ziglio From: Frediano Ziglio Let compiler do the job to optimise the function. Signed-off-by: Frediano Ziglio Signed-off-by: Paolo Bonzini Signed-off-by: Frediano Ziglio --- include/qemu-common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/qemu-common.h b/include/qemu-common.h index f862214..644b46d 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -370,6 +370,12 @@ static inline uint8_t from_bcd(uint8_t val) } /* compute with 96 bit intermediate result: (a*b)/c */ +#ifdef CONFIG_INT128 +static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) +{ + return (__int128_t)a * b / c; +} +#else static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) { union { @@ -392,6 +398,7 @@ 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; } +#endif /* Round number down to multiple */ #define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) -- 1.8.3.1