From patchwork Fri Nov 19 16:04:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 519277 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp2757874imj; Fri, 19 Nov 2021 08:36:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJz421huSqd4V1vd/uK+ZqHY142HUT7TNEeWRbKMv7g3WjyOP2B2bWK9L4WNLzmvwMUuBbrH X-Received: by 2002:ab0:1c4c:: with SMTP id o12mr50969457uaj.136.1637339798185; Fri, 19 Nov 2021 08:36:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637339798; cv=none; d=google.com; s=arc-20160816; b=Zp+ClGKyJ4S6oryd7RdU22kVsYMNvAJP34kCMbShRpfKpL2vkhjQURD9JTm+ZiN0KN acnxOPf/1tjQ9xDNujPOvlushkEO12jB8cIZXWdk7JAx+q1OAvcwx1ziTJMQqydEX1ru RLf7Mv0yPq9DACdKYihOoQssTAyUZGlEVo2uiCmk+LSlqt2XijPCMzogP9fNjIiKJ68X 1kYYU1dWTonokmcsTt0THitwgONzAb6FyFqKrinQ9P0SQQhUE++26+EPX9xNfx3jWlk8 19pEa4dB4HDt1F5JNSwottaWj+VSwLSoqtdR+RXWtus4MGpYN86SkaY7lbyzVJ3bQAK4 S86Q== 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=oeLIswcSVdWllblb8zsAtciTHxrmWmXEMgr/6V/SjGY=; b=qdrhuNtvjrB5RAaR0qgrAgtKtqWKstRhp1FOyH3E2RklI66MNKrpudqiBV6GQVIp/Y 4vWmg/tZETJ/stsKet/72JTkNUAaAW0QJY+/iIKmTa5Eo+Dfp4UNnJxD41kl/Vex6KZu zPGjJOjKgs48DruJ7QrLwIu8hwzmKnzbr+HrS2HMpRJf0D91QDxhZ7OGpCvuv2a/Y5q4 Aj8A+20TOdhc1zZeRdMTLL5SpnXniZ8Zn7LAW6Wjp9QTgY6JiudA1VZVhfjza8B0MKGZ RXGF3BdsnK4F5vRPUJXjDP9I9KvxbUESWGwguaoELHSHFc3FewLPyzPqYoo0n2HOUiVi JGWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q7pdQHmy; 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=fail (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 u18si709175vsj.238.2021.11.19.08.36.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Nov 2021 08:36:38 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=Q7pdQHmy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mo6sP-0005YU-Le for patch@linaro.org; Fri, 19 Nov 2021 11:36:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mo6PM-00076Q-Ng for qemu-devel@nongnu.org; Fri, 19 Nov 2021 11:06:39 -0500 Received: from [2a00:1450:4864:20::432] (port=38449 helo=mail-wr1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mo6P6-0004Xy-7v for qemu-devel@nongnu.org; Fri, 19 Nov 2021 11:06:23 -0500 Received: by mail-wr1-x432.google.com with SMTP id u18so18987297wrg.5 for ; Fri, 19 Nov 2021 08:06:18 -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=oeLIswcSVdWllblb8zsAtciTHxrmWmXEMgr/6V/SjGY=; b=Q7pdQHmy5rxjhV1AMuFC1fHPaIybjaA0wc0KSuopEiDLcp5azdiGJFHrSbAmCIRNJc 0dF1hbo6pWTjgnBJpdP5cechtaKYcSdBp6OLdTKJAC2iW4pIWOXyfDlhTrkbtL9D5Ldr Tugyf7A0qJW8m6rX6XslEmQVbUwR4Txb0HRSfEvOBQPw2LTE4FZi3Ty5uqcvCrFxQRJF 3cXwt4ChounxnsV5WKuPrtHa8/j7XsQWgAlqN+A8syAB3DX2Mbye6hMYuHTy/MbGNWc9 apLG0TOv78LEAouV3zeMhQgqZJnv7DRI2WMae7yH6hfFVgAzdvopYyhpQBzFBj2oT0it F1Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oeLIswcSVdWllblb8zsAtciTHxrmWmXEMgr/6V/SjGY=; b=JNNCEqK8Z5WBQ/9/3fneGQ5fVmgwxOnq+jmJNi2JurVYWQEz6WJ6mwnRhAzWoyKxKR 3acCMTLgaKyTa2hAn88kGXHCZieKDuqyDhaytiPQA1LjgIMBUot0RYW8yIjDXpiFc1oZ 4bZZUvQgBekCmQUtW+L0hw3DjlbTJiSBvcFhY3q244joYMBvfwxgk151KyEOuUKXIukO u76vggEHFntH50VzaX0TqIo9YnPu0ymG0j5+ItCRIC9X4FM5M+HmU9lWicEbsYoQlUXj bC7rtQAsC7Oxj93FZp/PPEH6XUY9h5enPLEI5bNvEv28tP6vKelsCKHXuD699NkNvn9f Kl1A== X-Gm-Message-State: AOAM531+TJHRNYyaMOxdnK5DZjxWpX1hQmUV4xxknVAkxQwj7plVGBZu paUsZ+9UsobSrVhUYnJcLATBIqYtNb0xf190j9M= X-Received: by 2002:adf:db47:: with SMTP id f7mr8560886wrj.113.1637337977308; Fri, 19 Nov 2021 08:06:17 -0800 (PST) Received: from localhost.localdomain (165.red-37-158-79.dynamicip.rima-tde.net. [37.158.79.165]) by smtp.gmail.com with ESMTPSA id q84sm14044877wme.3.2021.11.19.08.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 08:06:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 32/35] target/ppc: Add helper for frsqrtes Date: Fri, 19 Nov 2021 17:04:59 +0100 Message-Id: <20211119160502.17432-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211119160502.17432-1-richard.henderson@linaro.org> References: <20211119160502.17432-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::432 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com, alex.bennee@linaro.org, clg@kaod.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There is no double-rounding bug here, because the result is merely an estimate to within 1 part in 32, but perform the operation with float64r32_div for consistency. Signed-off-by: Richard Henderson --- target/ppc/helper.h | 1 + target/ppc/fpu_helper.c | 19 +++++++++++++++++++ target/ppc/translate/fp-impl.c.inc | 3 +-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 9810d416cf..48d12233ea 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -113,6 +113,7 @@ DEF_HELPER_2(fsqrts, f64, env, f64) DEF_HELPER_2(fre, i64, env, i64) DEF_HELPER_2(fres, i64, env, i64) DEF_HELPER_2(frsqrte, i64, env, i64) +DEF_HELPER_2(frsqrtes, i64, env, i64) DEF_HELPER_4(fsel, i64, env, i64, i64, i64) DEF_HELPER_FLAGS_2(ftdiv, TCG_CALL_NO_RWG_SE, i32, i64, i64) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 6278d61d36..cb511f2050 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -848,6 +848,25 @@ float64 helper_frsqrte(CPUPPCState *env, float64 arg) return retd; } +/* frsqrtes - frsqrtes. */ +float64 helper_frsqrtes(CPUPPCState *env, float64 arg) +{ + /* "Estimate" the reciprocal with actual division. */ + float64 rets = float64_sqrt(arg, &env->fp_status); + float64 retd = float64r32_div(float64_one, rets, &env->fp_status); + int flags = get_float_exception_flags(&env->fp_status); + + if (unlikely(flags & float_flag_invalid)) { + float_invalid_op_sqrt(env, flags, 1, GETPC()); + } + if (unlikely(flags & float_flag_divbyzero)) { + /* Reciprocal of (square root of) zero. */ + float_zero_divide_excp(env, GETPC()); + } + + return retd; +} + /* fsel - fsel. */ uint64_t helper_fsel(CPUPPCState *env, uint64_t arg1, uint64_t arg2, uint64_t arg3) diff --git a/target/ppc/translate/fp-impl.c.inc b/target/ppc/translate/fp-impl.c.inc index 17b4d46040..9056a773cb 100644 --- a/target/ppc/translate/fp-impl.c.inc +++ b/target/ppc/translate/fp-impl.c.inc @@ -212,8 +212,7 @@ static void gen_frsqrtes(DisasContext *ctx) t1 = tcg_temp_new_i64(); gen_reset_fpstatus(); get_fpr(t0, rB(ctx->opcode)); - gen_helper_frsqrte(t1, cpu_env, t0); - gen_helper_frsp(t1, cpu_env, t1); + gen_helper_frsqrtes(t1, cpu_env, t0); set_fpr(rD(ctx->opcode), t1); gen_compute_fprf_float64(t1); if (unlikely(Rc(ctx->opcode) != 0)) {