From nobody Sun Oct 26 00:03:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 152166386428017.28213175554265; Wed, 21 Mar 2018 13:24:24 -0700 (PDT) Received: from localhost ([::1]:57188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eykHQ-0004WJ-Cd for importer@patchew.org; Wed, 21 Mar 2018 16:24:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyk5V-00029q-Sc for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyk5R-0000zb-EA for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:11:57 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:34761) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyk5R-0000yR-6S for qemu-devel@nongnu.org; Wed, 21 Mar 2018 16:11:53 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CC7A6213BA; Wed, 21 Mar 2018 16:11:52 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 21 Mar 2018 16:11:52 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 82CBE24149; Wed, 21 Mar 2018 16:11:52 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=ek9piP889EJ37z qkZ5hXxltUx2T2xnUB13A0VRBFSiU=; b=fFSAvKNzALfUD9SoNu9rf/sXSXIxi/ +zaNAQ8ibpncxYADNit6S+NmU6Wt31OVEwOHdHUJiaEXJI4J78mbyr8nhX5HMxhn a/oZOotO+kwQQYP02KyguI5jBxQA7z5IakSvjSzsQKy5tLzEPW4PhHEfFbPo3DuE s14P8TM9VNdw8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=ek9piP889EJ37zqkZ5hXxltUx2T2xnUB13A0VRBFSiU=; b=Xe9kdAyB ZG/X1wJuTpuJPx9HdsCi0KwNFX41fKrwCDa0J0f8aC5WWaEt8+pvM1S4g6CCGMEE lrCRphgdfeI1IQ0kycgYMQuW/jGiU9yxEq7CJwnjvGuwWOyZZD7Z6UpaouzOSkDn JAuvpx+cTjDGE89gSk3AxvWwBPyyvz2UXCsCwkxMf9EbP4TN4NLsQVWRD3x/VXBz fJrub4ve79gJ48fjpJhr0jkjO5hR5SYbR1Vd9ABw+dhaY43/npMMYi2XAd0WLde5 yHJZo+vBDK10H0+ZcV2xX2ZIZ4oDXpveVoMjJeIzBZT19LhFnrV/cYwQYhEqkQ9p CUlnmKOZSeS0ug== X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 21 Mar 2018 16:11:45 -0400 Message-Id: <1521663109-32262-11-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521663109-32262-1-git-send-email-cota@braap.org> References: <1521663109-32262-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH v1 10/14] hostfloat: support float32/64 division 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: Peter Maydell , Mark Cave-Ayland , Richard Henderson , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Performance results for fp-bench run under aarch64-linux-user on an Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz host: - before: div-single: 29.77 MFlops div-double: 29.85 MFlops - after: div-single: 85.90 MFlops div-double: 86.10 MFlops Signed-off-by: Emilio G. Cota --- include/fpu/hostfloat.h | 2 ++ include/fpu/softfloat.h | 4 ++-- fpu/hostfloat.c | 28 ++++++++++++++++++++++++++++ fpu/softfloat.c | 4 ++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/include/fpu/hostfloat.h b/include/fpu/hostfloat.h index 7049f7e..61a8525 100644 --- a/include/fpu/hostfloat.h +++ b/include/fpu/hostfloat.h @@ -14,9 +14,11 @@ float32 float32_add(float32 a, float32 b, float_status *status); float32 float32_sub(float32 a, float32 b, float_status *status); float32 float32_mul(float32 a, float32 b, float_status *status); +float32 float32_div(float32 a, float32 b, float_status *status); =20 float64 float64_add(float64 a, float64 b, float_status *status); float64 float64_sub(float64 a, float64 b, float_status *status); float64 float64_mul(float64 a, float64 b, float_status *status); +float64 float64_div(float64 a, float64 b, float_status *status); =20 #endif /* HOSTFLOAT_H */ diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 2b07ae8..a690a57 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -345,7 +345,7 @@ float32 float32_round_to_int(float32, float_status *sta= tus); float32 soft_float32_add(float32, float32, float_status *status); float32 soft_float32_sub(float32, float32, float_status *status); float32 soft_float32_mul(float32, float32, float_status *status); -float32 float32_div(float32, float32, float_status *status); +float32 soft_float32_div(float32, float32, float_status *status); float32 float32_rem(float32, float32, float_status *status); float32 float32_muladd(float32, float32, float32, int, float_status *statu= s); float32 float32_sqrt(float32, float_status *status); @@ -485,7 +485,7 @@ float64 float64_trunc_to_int(float64, float_status *sta= tus); float64 soft_float64_add(float64, float64, float_status *status); float64 soft_float64_sub(float64, float64, float_status *status); float64 soft_float64_mul(float64, float64, float_status *status); -float64 float64_div(float64, float64, float_status *status); +float64 soft_float64_div(float64, float64, float_status *status); float64 float64_rem(float64, float64, float_status *status); float64 float64_muladd(float64, float64, float64, int, float_status *statu= s); float64 float64_sqrt(float64, float_status *status); diff --git a/fpu/hostfloat.c b/fpu/hostfloat.c index 985d6f1..ff980ac 100644 --- a/fpu/hostfloat.c +++ b/fpu/hostfloat.c @@ -178,3 +178,31 @@ GEN_FPU_ADDSUB(float64_add, float64_sub, float64, doub= le, fabs, DBL_MIN) GEN_FPU_MUL(float32_mul, float32, float, fabsf, FLT_MIN) GEN_FPU_MUL(float64_mul, float64, double, fabs, DBL_MIN) #undef GEN_FPU_MUL + +#define GEN_FPU_DIV(name, soft_t, host_t, host_abs_func, min_normal) \ + soft_t name(soft_t a, soft_t b, float_status *s) \ + { \ + soft_t ## _input_flush2(&a, &b, s); \ + if (likely(soft_t ## _is_normal(a) && \ + soft_t ## _is_normal(b) && \ + s->float_exception_flags & float_flag_inexact && \ + s->float_rounding_mode =3D=3D float_round_nearest_even)= ) { \ + host_t ha =3D soft_t ## _to_ ## host_t(a); \ + host_t hb =3D soft_t ## _to_ ## host_t(b); \ + host_t hr =3D ha / hb; \ + soft_t r =3D host_t ## _to_ ## soft_t(hr); \ + \ + if (unlikely(soft_t ## _is_infinity(r))) { \ + s->float_exception_flags |=3D float_flag_overflow; \ + } else if (unlikely(host_abs_func(hr) <=3D min_normal)) { \ + goto soft; \ + } \ + return r; \ + } \ + soft: \ + return soft_ ## soft_t ## _div(a, b, s); \ + } + +GEN_FPU_DIV(float32_div, float32, float, fabsf, FLT_MIN) +GEN_FPU_DIV(float64_div, float64, double, fabs, DBL_MIN) +#undef GEN_FPU_DIV diff --git a/fpu/softfloat.c b/fpu/softfloat.c index e3f2918..ebc59be 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1176,7 +1176,7 @@ float16 float16_div(float16 a, float16 b, float_statu= s *status) return float16_round_pack_canonical(pr, status); } =20 -float32 float32_div(float32 a, float32 b, float_status *status) +float32 soft_float32_div(float32 a, float32 b, float_status *status) { FloatParts pa =3D float32_unpack_canonical(a, status); FloatParts pb =3D float32_unpack_canonical(b, status); @@ -1185,7 +1185,7 @@ float32 float32_div(float32 a, float32 b, float_statu= s *status) return float32_round_pack_canonical(pr, status); } =20 -float64 float64_div(float64 a, float64 b, float_status *status) +float64 soft_float64_div(float64 a, float64 b, float_status *status) { FloatParts pa =3D float64_unpack_canonical(a, status); FloatParts pb =3D float64_unpack_canonical(b, status); --=20 2.7.4