From patchwork Tue Aug 21 04:33:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 144671 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4783865ljj; Mon, 20 Aug 2018 21:34:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbCPEevtGZC519dKKJfNsQZe1wUKFqHJONsV78qtfme1BhxbJdU6onc0VCJ6iS8Jai1DZRF X-Received: by 2002:a37:a9c5:: with SMTP id s188-v6mr5262730qke.407.1534826073809; Mon, 20 Aug 2018 21:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534826073; cv=none; d=google.com; s=arc-20160816; b=sXro3dNlfwkqywgD3gmrcCwongcpwdimRbox1KTidNfxkMvPsQY7QTK7RkP+KFzmes WOi1PLblAAsW9DDEZrB2t0Kbz7xHBIyE5QYtk6q4k9lQlOBIzJ6Vm5inRgWmqlgnnbCX EIripgI9a3ONLZGXh0ijf84scoGX8VePRGO45cQLe/YZcB/wUqPAVkpXRbYc73SC9Blb HxF9BHiLYZriYYsKPOUs4OPWgMKFoBuHAbJAAoDczz2Nc1a+em/PHknb3/bLm3xdqx8X 1XhXww79S+gLkyffeE6EFY4HWHKpj/H3yD8+xLhmN2EvChRQyYaXuTsJT97sZBPb1hT0 eCnw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=6EY8XcOc5SmNL7gbzSr/VRmCE83nTDyJeVQK17ZFg/E=; b=mtHtG58vkgCXYayNws7MllYiVqWyD6oZkfSsm8yUg1M2bX/XgWgNA/jmodu54iBwxV 49OtX0epFBALaiqxM1ZHSPdrKAyRbCp8jAnN8orurgIx/5/ByLYtCYxEWPkZiJCVh1lK 4LxpSYOY03jEt56sbp/075/RCe8hMPIKCvG4R56nhzmv2DSvXI8fHdSUipoDKXn9tCov hX4aZ8osa8inIFDoYj+ckUjdGR8Gv59vp1+rHKNOtN+B5mLCfc09Wq6iOf4aH+RBkzFL cdPh38ngbl0pouG3TA83z3ftB0iWw+/8Q20vmtsT6J1Z5jVdcxwJ/56xbS2dYxm1wXLF fmtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=S7NknbPB; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b190-v6si1152448qke.317.2018.08.20.21.34.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Aug 2018 21:34:33 -0700 (PDT) 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=@gibson.dropbear.id.au header.s=201602 header.b=S7NknbPB; 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" Received: from localhost ([::1]:50636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fryNF-00044s-3P for patch@linaro.org; Tue, 21 Aug 2018 00:34:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fryMh-00041f-Jd for qemu-devel@nongnu.org; Tue, 21 Aug 2018 00:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fryMg-0000E0-6Z for qemu-devel@nongnu.org; Tue, 21 Aug 2018 00:33:59 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:38557) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fryMf-0000AD-Mg; Tue, 21 Aug 2018 00:33:58 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41vd9D01WJz9s7X; Tue, 21 Aug 2018 14:33:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1534826032; bh=ZHBFLnDftDs3FcvSsrvLiwlkpmtdIs2//4w0Wq+RmX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7NknbPBYp6DL7JFtHI453ABNyB0UILYHzhLwaegFRBdkBTGmP5qdYkjkDF2IL8Ak 5AniK01ivcgtnJQgU/AjCiqTrT6j5+vvzc1rGV9NrbKIkMftQkC7JKosK8cmsZdHT3 K4SX/cjPndY1FzdZeUhQhpz3k6GA9u6Cv67xXVig= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 21 Aug 2018 14:33:24 +1000 Message-Id: <20180821043343.7514-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180821043343.7514-1-david@gibson.dropbear.id.au> References: <20180821043343.7514-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 07/26] target/ppc: Tidy helper_fsqrt 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: lvivier@redhat.com, aik@ozlabs.ru, Richard Henderson , groug@kaod.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Tidy the invalid exception checking so that we rely on softfloat for initial argument validation, and select the kind of invalid operand exception only when we know we must. Pass and return float64 values directly rather than bounce through the CPU_DoubleU union. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 29 ++++++++++++++--------------- target/ppc/helper.h | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) -- 2.17.1 diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 7758372ecd..44f3fed17d 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -858,25 +858,24 @@ uint64_t helper_frsp(CPUPPCState *env, uint64_t arg) } /* fsqrt - fsqrt. */ -uint64_t helper_fsqrt(CPUPPCState *env, uint64_t arg) +float64 helper_fsqrt(CPUPPCState *env, float64 arg) { - CPU_DoubleU farg; - - farg.ll = arg; + float64 ret = float64_sqrt(arg, &env->fp_status); + int status = get_float_exception_flags(&env->fp_status); - if (unlikely(float64_is_any_nan(farg.d))) { - if (unlikely(float64_is_signaling_nan(farg.d, &env->fp_status))) { - /* sNaN reciprocal square root */ - float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); - farg.ll = float64_snan_to_qnan(farg.ll); + if (unlikely(status & float_flag_invalid)) { + if (unlikely(float64_is_any_nan(arg))) { + if (unlikely(float64_is_signaling_nan(arg, &env->fp_status))) { + /* sNaN square root */ + float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); + } + } else { + /* Square root of a negative nonzero number */ + float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1); } - } else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) { - /* Square root of a negative nonzero number */ - farg.ll = float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1); - } else { - farg.d = float64_sqrt(farg.d, &env->fp_status); } - return farg.ll; + + return ret; } /* fre - fre. */ diff --git a/target/ppc/helper.h b/target/ppc/helper.h index d81806dd2c..7ed72c2337 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -93,7 +93,7 @@ DEF_HELPER_4(fmadd, i64, env, i64, i64, i64) DEF_HELPER_4(fmsub, i64, env, i64, i64, i64) DEF_HELPER_4(fnmadd, i64, env, i64, i64, i64) DEF_HELPER_4(fnmsub, i64, env, i64, i64, i64) -DEF_HELPER_2(fsqrt, i64, env, i64) +DEF_HELPER_2(fsqrt, f64, env, f64) DEF_HELPER_2(fre, i64, env, i64) DEF_HELPER_2(fres, i64, env, i64) DEF_HELPER_2(frsqrte, i64, env, i64)