From patchwork Mon Dec 17 10:56:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 153986 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2334135ljp; Mon, 17 Dec 2018 03:07:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/UBU2RQfT5jJ+Aw42lNsFcFuV13leTSb49atdxhZOBGN8EeBtxGZIVtnZkyBLvdKhUu7pn6 X-Received: by 2002:ad4:4084:: with SMTP id l4mr9117746qvp.165.1545044850289; Mon, 17 Dec 2018 03:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545044850; cv=none; d=google.com; s=arc-20160816; b=QH/QKV8PGj/PyyNPh3GBAp7cTtjh4hYZPHxpyOc1NN2kZFB3cpMg97TZ/QgcMg+yrw QLNZa0mVx3GSY85zOh6eofa99fCydWqp3mEFpoh6sUVXgOMOejPgEDwmASbHgNIHxvPF 6yXhcauRhG682kaLGIDcry1CyyGbXL1lpXr/n/XaTwDN/X96Aa9Rxn+AOAR/jdCN/DPq ZlmwGgsR6wpzXBQZwK2uQMYWkQxziZTLWGP2i4bkoOxvdFq0m1TsHllhB+rt6+DtlbAw DsEn+5b74JAVKNyT/SyHfRwFL+U/qol3Kf3Evg9mQax3SLds+mjtT0i156SjFAH1zPAv En5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=c/PerMWSPIjcbhwxD3x33iKPftA7Si/+WsOd5NZj+vM=; b=E9W0uxF3rg1poWBvNauNj9vbXAsHXorljn98FwFrSIeNJ43VX+CIWCsSzaHowf5wRh m396Z/L7uRgow4UsagffzkxO0TcmUI60gsZhJXqRm4VRGn2FOM4k1U6/m1rifpaXFo2r 2h5P+4zqyY4ld7AVnCBpaggwcZs0+VgKSTRxh3dVlqWb9YzGnJRCeGH66w8mWTUu2yVp X2q1qx2B6FfzxOMfL2ftZOzxbOqkXuWtT/59Z0PT1L+Z701VobinWEGUIuGQEyIYsz9A Lhf9hCs9mQJfMybgKwjtnNE8aFH1GDm5/tCtnBypXHZmKdJ0EPrJOKBHpaicJDe2fgeY /29A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f4GuolQy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s31si1170671qtc.107.2018.12.17.03.07.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 17 Dec 2018 03:07:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f4GuolQy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYqkD-0000dL-IV for patch@linaro.org; Mon, 17 Dec 2018 06:07:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYqbg-0002Y7-60 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 05:58:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYqa7-0000BY-FN for qemu-devel@nongnu.org; Mon, 17 Dec 2018 05:57:04 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:35762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gYqa7-0000Ah-75 for qemu-devel@nongnu.org; Mon, 17 Dec 2018 05:57:03 -0500 Received: by mail-wm1-x332.google.com with SMTP id c126so12101386wmh.0 for ; Mon, 17 Dec 2018 02:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c/PerMWSPIjcbhwxD3x33iKPftA7Si/+WsOd5NZj+vM=; b=f4GuolQyVc+O27W7905fEJJD0afJWZyuQP2oLvXZLacNvsp/13ITG6b2/I3SUofGIn Uggbf0Myzz+yEWzJakZ+aeJ9q7GTpJlEMnVw1fsjKIWe0CsT4RnNAmLL9thz2+dAg1/s TYxKPOMLoxH6LF11gk8nr3JGLMKEs/QAsxizE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c/PerMWSPIjcbhwxD3x33iKPftA7Si/+WsOd5NZj+vM=; b=Z1dzV+X8HxYf6VLkPRVzq5ahIgcDhPVmmM2l+OQ9QSxe7AtI/+VYBqElvaQlctlC+R qCO9QVeVcloRqRN3GCzAakXwsiSav4qNeRnXNDDftCiu1T3Ak4Twn4KrWE2xuk/77hAh neQdenYYpyAnb9ZAwiT9g7XB4ioJM2A1JTxydyukCTCFw1xxjTSxMdfWaYHIRXRJ+cTh kLUMxiGu5u2fpEteroUcDgPThOEgNq9aNkxZd/H3Z2UWasBNy2SySgPYbjM6rR7zVSSl ejYDRZeHGsQa/lqTe1nrfwThK7sCRd9AraXZdqGY31Bxd06kQwAmLcPmGJ6V2xt6ymrw eqJA== X-Gm-Message-State: AA+aEWYgEDhFg0/4epXRSseuJg8jzK8xmtChpIf314vCYLDikDLl+HSW Aj263SlS/gMcxYcmNF8f6zJDLg== X-Received: by 2002:a1c:e484:: with SMTP id b126mr10539857wmh.119.1545044221842; Mon, 17 Dec 2018 02:57:01 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 126sm22540815wmx.26.2018.12.17.02.56.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Dec 2018 02:56:58 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 82E483E05F2; Mon, 17 Dec 2018 10:56:51 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 17 Dec 2018 10:56:46 +0000 Message-Id: <20181217105650.27361-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181217105650.27361-1-alex.bennee@linaro.org> References: <20181217105650.27361-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::332 Subject: [Qemu-devel] [PULL v3 11/15] hardfloat: implement float32/64 multiplication X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Performance results for fp-bench: 1. Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz - before: mul-single: 126.91 MFlops mul-double: 118.28 MFlops - after: mul-single: 258.02 MFlops mul-double: 197.96 MFlops 2. ARM Aarch64 A57 @ 2.4GHz - before: mul-single: 37.42 MFlops mul-double: 38.77 MFlops - after: mul-single: 73.41 MFlops mul-double: 76.93 MFlops 3. IBM POWER8E @ 2.1 GHz - before: mul-single: 58.40 MFlops mul-double: 59.33 MFlops - after: mul-single: 60.25 MFlops mul-double: 94.79 MFlops Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée -- 2.17.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 08afa861a7..dad2ce2d9f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1236,7 +1236,8 @@ float16 QEMU_FLATTEN float16_mul(float16 a, float16 b, float_status *status) return float16_round_pack_canonical(pr, status); } -float32 QEMU_FLATTEN float32_mul(float32 a, float32 b, float_status *status) +static float32 QEMU_SOFTFLOAT_ATTR +soft_f32_mul(float32 a, float32 b, float_status *status) { FloatParts pa = float32_unpack_canonical(a, status); FloatParts pb = float32_unpack_canonical(b, status); @@ -1245,7 +1246,8 @@ float32 QEMU_FLATTEN float32_mul(float32 a, float32 b, float_status *status) return float32_round_pack_canonical(pr, status); } -float64 QEMU_FLATTEN float64_mul(float64 a, float64 b, float_status *status) +static float64 QEMU_SOFTFLOAT_ATTR +soft_f64_mul(float64 a, float64 b, float_status *status) { FloatParts pa = float64_unpack_canonical(a, status); FloatParts pb = float64_unpack_canonical(b, status); @@ -1254,6 +1256,54 @@ float64 QEMU_FLATTEN float64_mul(float64 a, float64 b, float_status *status) return float64_round_pack_canonical(pr, status); } +static float hard_f32_mul(float a, float b) +{ + return a * b; +} + +static double hard_f64_mul(double a, double b) +{ + return a * b; +} + +static bool f32_mul_fast_test(union_float32 a, union_float32 b) +{ + return float32_is_zero(a.s) || float32_is_zero(b.s); +} + +static bool f64_mul_fast_test(union_float64 a, union_float64 b) +{ + return float64_is_zero(a.s) || float64_is_zero(b.s); +} + +static float32 f32_mul_fast_op(float32 a, float32 b, float_status *s) +{ + bool signbit = float32_is_neg(a) ^ float32_is_neg(b); + + return float32_set_sign(float32_zero, signbit); +} + +static float64 f64_mul_fast_op(float64 a, float64 b, float_status *s) +{ + bool signbit = float64_is_neg(a) ^ float64_is_neg(b); + + return float64_set_sign(float64_zero, signbit); +} + +float32 QEMU_FLATTEN +float32_mul(float32 a, float32 b, float_status *s) +{ + return float32_gen2(a, b, s, hard_f32_mul, soft_f32_mul, + f32_is_zon2, NULL, f32_mul_fast_test, f32_mul_fast_op); +} + +float64 QEMU_FLATTEN +float64_mul(float64 a, float64 b, float_status *s) +{ + return float64_gen2(a, b, s, hard_f64_mul, soft_f64_mul, + f64_is_zon2, NULL, f64_mul_fast_test, f64_mul_fast_op); +} + /* * Returns the result of multiplying the floating-point values `a' and * `b' then adding 'c', with no intermediate rounding step after the