From patchwork Mon Dec 17 10:56:47 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: 153984 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2332140ljp; Mon, 17 Dec 2018 03:05:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/UmtLEsMIUspsmPOjX9Uli+fw9uoI/61lvt9ZdlbPlHYHdawjMr3F+W/AuHC4L1ET6G8ojA X-Received: by 2002:a0c:e610:: with SMTP id z16mr12790067qvm.81.1545044743706; Mon, 17 Dec 2018 03:05:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545044743; cv=none; d=google.com; s=arc-20160816; b=zWUlx8Wg3GyHcIsjQuv5wMdlVYEngPHtGBPG2AwALq32s3zFghzK0FuObxvol9soTI UacOx3KiKLypcuDTsSY2VxObNroQiWUEXB5mSkb53OZZ7HEVt4YoBLhu38DWOuBkPgdZ vkgSTUjCjSFsDDBm5jevHA+UNnHeUeNeiIu+NhFGtm/5yMOt32FPr2tuIDYK5M/8IgjD kL8LJche4Pwdeon2EYTcA08K0yynpulQvz+P+aoqB+2HGchgtPiHcdpBwnrPwDPDHRmF 6+49BZcTWA7hHf9uOY8E8EBm1kA21hgTyLOHPqYHFOb7kUEcQscBu4UfXqG2BaBUmSsJ 9CzA== 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=RMhnnIR17SBiSba935IicBicApMGoHG/QIEwdhjzhO4=; b=YIFmAmKkpSidpef8xqE6i7TPopTmGCLo4qMSi8cHkUEPmPOdPf4r5yuoxeUKh1e2DT 0epihPmoSK4UvL/azSxiujPR2+oDQskHagEAamEzn4YQLXKTcP+6FmdQZIWgGNrktk5C aLXOnwAX8W2UlxVj1IXoAcPNzFvDYjiVbkWK1iVqELRo0LEQHGavM+L3ZRXFRrLulkar BJcuQEvoKle7qdWqzLJIOAVxGbUvIqY/D2Jlkybad85oXsXq+E2FPdVRhCEwKd/CHLV4 3Fdhkg9Th+nHnp3sxrw61WABSH+pVuIW1tMpdNlITuZnfsaM0mwavrXepXC9L27z7N0T 9HXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dH4YmQ+Z; 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 f1si1256298qkc.106.2018.12.17.03.05.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 17 Dec 2018 03:05:43 -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=dH4YmQ+Z; 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]:45935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYqiU-0007hZ-U2 for patch@linaro.org; Mon, 17 Dec 2018 06:05:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYqbP-0002Y7-Fs for qemu-devel@nongnu.org; Mon, 17 Dec 2018 05:58:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYqa8-0000CN-Jz for qemu-devel@nongnu.org; Mon, 17 Dec 2018 05:57:09 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:40502) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gYqa8-0000Bg-CA for qemu-devel@nongnu.org; Mon, 17 Dec 2018 05:57:04 -0500 Received: by mail-wr1-x42a.google.com with SMTP id p4so11764735wrt.7 for ; Mon, 17 Dec 2018 02:57:04 -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=RMhnnIR17SBiSba935IicBicApMGoHG/QIEwdhjzhO4=; b=dH4YmQ+ZwygFmYgXcaufA5E0WbnOgHuriKtolwXsmYfpeOj8KoKcykU/rWiCg6+kkC dCg7tIkUobdlVsciPivc2WUC+oESQwCEkRWudksLfaPz11vsm0nfHjFYJklMWjjzjuiZ nmEaY+Y41gjLZ9PDglFC5HNn9VPoRmKpeMnLk= 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=RMhnnIR17SBiSba935IicBicApMGoHG/QIEwdhjzhO4=; b=s5hioITKzpYIT4ouImJYujjCu94exUv/DONZu0DvsIepZcTJvMl7TM+Tt6N/E1Eo/K NBnCjacAJELMlZlDZslqOBrddW9+MVMLbLdt8ODr5UvZv9qFQOWRmDN+KDU0mJZzTEsm JxYsi2icIb1lVqNU/JWtN5mZ8GY1OG/1GMpVOISZeGiLPbb+fiZzpSbNcon5Wrc008+z jQenHp8ZVWaX+BSS6thQjTOgjamORZL9C2/X7VzBe84VaLnZaWBNCAwGUV9tdbqAQWVt GZyKxWBU0vY6wO35qjT4cy6IhSiszRoAdRFV3GJP6wYxEn3LpNEEOo2Xu7qQ4gUG8ih1 ijuA== X-Gm-Message-State: AA+aEWZIOdvp97zGhJxOamyYUZzovq1gUpw8nBmooa8UOAK+VllgEnLh cKDQOWX/BD/Hq0iU3ZbbBdstiQ== X-Received: by 2002:adf:a28d:: with SMTP id s13mr10800556wra.100.1545044223000; Mon, 17 Dec 2018 02:57:03 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y1sm12524673wme.1.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 95B5E3E0605; 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:47 +0000 Message-Id: <20181217105650.27361-13-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::42a Subject: [Qemu-devel] [PULL v3 12/15] hardfloat: implement 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: "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: div-single: 34.84 MFlops div-double: 34.04 MFlops - after: div-single: 275.23 MFlops div-double: 216.38 MFlops 2. ARM Aarch64 A57 @ 2.4GHz - before: div-single: 9.33 MFlops div-double: 9.30 MFlops - after: div-single: 51.55 MFlops div-double: 15.09 MFlops 3. IBM POWER8E @ 2.1 GHz - before: div-single: 25.65 MFlops div-double: 24.91 MFlops - after: div-single: 96.83 MFlops div-double: 31.01 MFlops Here setting 2FP64_USE_FP to 1 pays off for x86_64: [1] 215.97 vs [0] 62.15 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 dad2ce2d9f..82294458fe 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1628,7 +1628,8 @@ float16 float16_div(float16 a, float16 b, float_status *status) return float16_round_pack_canonical(pr, status); } -float32 float32_div(float32 a, float32 b, float_status *status) +static float32 QEMU_SOFTFLOAT_ATTR +soft_f32_div(float32 a, float32 b, float_status *status) { FloatParts pa = float32_unpack_canonical(a, status); FloatParts pb = float32_unpack_canonical(b, status); @@ -1637,7 +1638,8 @@ float32 float32_div(float32 a, float32 b, float_status *status) return float32_round_pack_canonical(pr, status); } -float64 float64_div(float64 a, float64 b, float_status *status) +static float64 QEMU_SOFTFLOAT_ATTR +soft_f64_div(float64 a, float64 b, float_status *status) { FloatParts pa = float64_unpack_canonical(a, status); FloatParts pb = float64_unpack_canonical(b, status); @@ -1646,6 +1648,64 @@ float64 float64_div(float64 a, float64 b, float_status *status) return float64_round_pack_canonical(pr, status); } +static float hard_f32_div(float a, float b) +{ + return a / b; +} + +static double hard_f64_div(double a, double b) +{ + return a / b; +} + +static bool f32_div_pre(union_float32 a, union_float32 b) +{ + if (QEMU_HARDFLOAT_2F32_USE_FP) { + return (fpclassify(a.h) == FP_NORMAL || fpclassify(a.h) == FP_ZERO) && + fpclassify(b.h) == FP_NORMAL; + } + return float32_is_zero_or_normal(a.s) && float32_is_normal(b.s); +} + +static bool f64_div_pre(union_float64 a, union_float64 b) +{ + if (QEMU_HARDFLOAT_2F64_USE_FP) { + return (fpclassify(a.h) == FP_NORMAL || fpclassify(a.h) == FP_ZERO) && + fpclassify(b.h) == FP_NORMAL; + } + return float64_is_zero_or_normal(a.s) && float64_is_normal(b.s); +} + +static bool f32_div_post(union_float32 a, union_float32 b) +{ + if (QEMU_HARDFLOAT_2F32_USE_FP) { + return fpclassify(a.h) != FP_ZERO; + } + return !float32_is_zero(a.s); +} + +static bool f64_div_post(union_float64 a, union_float64 b) +{ + if (QEMU_HARDFLOAT_2F64_USE_FP) { + return fpclassify(a.h) != FP_ZERO; + } + return !float64_is_zero(a.s); +} + +float32 QEMU_FLATTEN +float32_div(float32 a, float32 b, float_status *s) +{ + return float32_gen2(a, b, s, hard_f32_div, soft_f32_div, + f32_div_pre, f32_div_post, NULL, NULL); +} + +float64 QEMU_FLATTEN +float64_div(float64 a, float64 b, float_status *s) +{ + return float64_gen2(a, b, s, hard_f64_div, soft_f64_div, + f64_div_pre, f64_div_post, NULL, NULL); +} + /* * Float to Float conversions *