From patchwork Fri Jan 9 13:43:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 427069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C987D140119 for ; Sat, 10 Jan 2015 00:43:51 +1100 (AEDT) Received: from localhost ([::1]:50676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Zqu-0005tH-OA for incoming@patchwork.ozlabs.org; Fri, 09 Jan 2015 08:43:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9ZqY-0005JC-HG for qemu-devel@nongnu.org; Fri, 09 Jan 2015 08:43:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9ZqT-00007y-DE for qemu-devel@nongnu.org; Fri, 09 Jan 2015 08:43:26 -0500 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:62082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9ZqT-00007o-6i for qemu-devel@nongnu.org; Fri, 09 Jan 2015 08:43:21 -0500 Received: by mail-wi0-f178.google.com with SMTP id em10so2362973wid.5 for ; Fri, 09 Jan 2015 05:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Dl9DpDYmaWbyjibxGH2WQBSFrVwE7W21qi36kO8wAh8=; b=gzTCkRuYHKb6PpLMAx2AZjOZ8ITVY9CYUNRovyZNJ5/HXmBZYotxrHK78BTzH7Bo4t gfva6Z5ISWK15snz1TZOnCpEtvH+BOgSytcEwPvHKB3nZgHEzt83AnXtqnH1eq1J9Ay1 h5M1Y/pOQIZ2DzFnGBcHXQECkXIZFeMveGCP9I1uwhtHjJnZtHOk4lbMh4H7H05OpZ+5 x56VHQXSO0kzBdiYPE4YrsWtfBCZhYJh1DakUyQt6pgv6mKKy7ZFfSNYwsfZyTtQjgy8 OORxz7pYRDm1W8pdE3dnhOOgU+FQctGxJqGbhE3pX5MXwas2ridu7Auhr32xx/7AhLUe 5+/w== X-Received: by 10.180.84.98 with SMTP id x2mr5256911wiy.14.1420811000549; Fri, 09 Jan 2015 05:43:20 -0800 (PST) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id gu5sm25756678wib.24.2015.01.09.05.43.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Jan 2015 05:43:19 -0800 (PST) From: Frediano Ziglio X-Google-Original-From: Frediano Ziglio To: Paolo Bonzini , Anthony Liguori , Stefan Hajnoczi Date: Fri, 9 Jan 2015 13:43:11 +0000 Message-Id: <1420810991-22722-1-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::232 Cc: Frediano Ziglio , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 1/2] qemu-common.h: optimise muldiv64 if int128 is available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Let compiler do the job to optimise the function. 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..f3033ae 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 (__uint128_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))