From patchwork Thu Jun 3 21:41:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 453336 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp635027jao; Thu, 3 Jun 2021 14:58:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIG2WMAkg5c+UlkTGlBCL+r3ZVTRoHhZr/3Ct503WhaXQ5bJs277jghPhrrQb0FoYKhdim X-Received: by 2002:a05:620a:787:: with SMTP id 7mr1386067qka.397.1622757493959; Thu, 03 Jun 2021 14:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622757493; cv=none; d=google.com; s=arc-20160816; b=locqFEdHA+ldlbtbnvM4EkGpkh+DeqBR+j6gAhVKVM7epwqaVMpjtaXnriYABQXpyB 3nF/6i3hy/zl0F4t2nYWUb8dFxH2PA56wYmGZzAkL0fcOhhVjN0rP7jyOGy63lEBfOOq qkD0taDJ8Ep4G94lTz5Amvys5x+uOVpvo0M7bojzad8MmtMv/3iIQ2CHyhPt3ODSdpg+ 3kXnTU55fcr9TNPgReeyQSwmr5GiS6775FbkkjdawaBWIvfzWnxnHXqK3CUp1NPf5ceB n7amGA5N0uTvdvx4fBldXe0mm8K9YBMjg3hJev4+3KEG9Kfs720DNTQ52qQr3iBI+jBX AQng== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=96c6uJZ3c+bY6czT9boE4Qd+QkQsfFNNXC+3KlgI5bI=; b=GGopasHPKssYoUzQx3D0jfyDRDWFlF/3zC55bLL7/k8diaPJ1N4cHuMOkhpXtjlb3e Iha0T94EU7A+0S46NSfaiviL9U6lHjXPyOZ2oB+ueQaX4f2g6s73PCZ33T0nipmJ/fOF wZ+ryoozdmiBtmOkJTl/ZyXjnvwljTSCZcnGEegCobs0rGOtsLqf9KrFfAVVl6B9Q6VW zEGJBhEBdncB49L4n7gBE5yWj8cRcYwsQXc0bYZHjEPf6rgnonpHTunoNG9qs/1cBJC8 kTABpaBWHoZJfpz3yxExifHJMpMcUE0Uymx8ptLV3b6tLkgf6ZK7FKUhyrWSlYR6vmm8 2Rkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BM6d3PSu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g3si2732294qvi.128.2021.06.03.14.58.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Jun 2021 14:58:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BM6d3PSu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lovLx-0004b2-D1 for patch@linaro.org; Thu, 03 Jun 2021 17:58:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lov6J-00038S-RI for qemu-devel@nongnu.org; Thu, 03 Jun 2021 17:42:03 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:38650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lov66-0001AC-IB for qemu-devel@nongnu.org; Thu, 03 Jun 2021 17:42:03 -0400 Received: by mail-pj1-x1030.google.com with SMTP id m13-20020a17090b068db02901656cc93a75so6260193pjz.3 for ; Thu, 03 Jun 2021 14:41:49 -0700 (PDT) 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=96c6uJZ3c+bY6czT9boE4Qd+QkQsfFNNXC+3KlgI5bI=; b=BM6d3PSuznr1qtaq+jeJeZCPFmK2oO0q8oIZ4QuuUUuXE0sZaRnfRKc4mnY3QuKNzx XkRNKSdm67CDTE9UabSoIkYX6zkXA2kBCkX+VXBBz5b880mvu2MLuOYCM6z2M7H2FmEx 2GqRcSd9E39VcLqTMi/eHaCoskHB/6tdoppD7hHKXUTQ4FoKKutttwI+dQtdv1feBI3M uxCFyTXgaij8a8kqxhZ8iwFkDHz7AqrqvUa01uXrQ5xHwLu7HEn4ThoB0B0gKS5wuzop /+i4SFBr9ibqmORnbS1XrmH94gMovIHE4YpAO10V+ekyJOKBjp2sG6OJsMnRqX/P0u8W AMrQ== 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=96c6uJZ3c+bY6czT9boE4Qd+QkQsfFNNXC+3KlgI5bI=; b=GJG2HM+tRDRBM6kYBfalsWWerwWcn+TL8Pf2KuvOEKYUpG+/+bEmh0NmwFCbb5nJLa 8QcM+rhzZ4tl0d6Tw27rwbsA+AlLjo9jGpWGq5ekcS7lP0bBnFuYwHbeY//VH9dIaEOW b6nViB0/EtQnxH6WFQnr+P1fkKOMIEXB+WgkQbwlrWmE17QsDYUDeQ1gf1qfG10cbqwT 9b5CGRvkpM2UFe32QpWpH7A2/UnsM03QaRTxvz3Jn80Zpng1yzfXRiCcak6tBp2INIr8 VeQl9aYbUiwMeAlC6LHGZaOIu3ECDXidBWmCVJWDf3gLeZwuY+EWKC+vOI/1CVUa4Hph 11BQ== X-Gm-Message-State: AOAM533BBOeZTcqdIN3eGSAH4Ok7XbmbxqjLXHIC33U9Xoge6Eu3a7v6 OpbU1tiASF4cyuhQzuXVwOrOGc116+c98A== X-Received: by 2002:a17:90a:b782:: with SMTP id m2mr5154492pjr.147.1622756509057; Thu, 03 Jun 2021 14:41:49 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id p65sm40115pfb.62.2021.06.03.14.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 14:41:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/29] softfloat: Convert float32_exp2 to FloatParts Date: Thu, 3 Jun 2021 14:41:27 -0700 Message-Id: <20210603214131.629841-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210603214131.629841-1-richard.henderson@linaro.org> References: <20210603214131.629841-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Keep the intermediate results in FloatParts instead of converting back and forth between float64. Use muladd instead of separate mul+add. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- fpu/softfloat.c | 53 +++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) -- 2.25.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index c32b1c7113..27306d6a93 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5210,47 +5210,40 @@ static const float64 float32_exp2_coefficients[15] = float32 float32_exp2(float32 a, float_status *status) { - bool aSign; - int aExp; - uint32_t aSig; - float64 r, x, xn; + FloatParts64 xp, xnp, tp, rp; int i; - a = float32_squash_input_denormal(a, status); - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - - if ( aExp == 0xFF) { - if (aSig) { - return propagateFloat32NaN(a, float32_zero, status); + float32_unpack_canonical(&xp, a, status); + if (unlikely(xp.cls != float_class_normal)) { + switch (xp.cls) { + case float_class_snan: + case float_class_qnan: + parts_return_nan(&xp, status); + return float32_round_pack_canonical(&xp, status); + case float_class_inf: + return xp.sign ? float32_zero : a; + case float_class_zero: + return float32_one; + default: + break; } - return (aSign) ? float32_zero : a; - } - if (aExp == 0) { - if (aSig == 0) return float32_one; + g_assert_not_reached(); } float_raise(float_flag_inexact, status); - /* ******************************* */ - /* using float64 for approximation */ - /* ******************************* */ - x = float32_to_float64(a, status); - x = float64_mul(x, float64_ln2, status); + float64_unpack_canonical(&xnp, float64_ln2, status); + xp = *parts_mul(&xp, &tp, status); + xnp = xp; - xn = x; - r = float64_one; + float64_unpack_canonical(&rp, float64_one, status); for (i = 0 ; i < 15 ; i++) { - float64 f; - - f = float64_mul(xn, float32_exp2_coefficients[i], status); - r = float64_add(r, f, status); - - xn = float64_mul(xn, x, status); + float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status); + rp = *parts_muladd(&tp, &xp, &rp, 0, status); + xnp = *parts_mul(&xnp, &xp, status); } - return float64_to_float32(r, status); + return float32_round_pack_canonical(&rp, status); } /*----------------------------------------------------------------------------