From nobody Mon Feb 9 00:38:34 2026 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.zoho.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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488354565362385.72041691068205; Tue, 28 Feb 2017 23:49:25 -0800 (PST) Received: from localhost ([::1]:38916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciz0j-0000Wr-Bu for importer@patchew.org; Wed, 01 Mar 2017 02:49:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ciz0E-0000R4-Vi for qemu-devel@nongnu.org; Wed, 01 Mar 2017 02:48:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ciz0B-0004zP-Pm for qemu-devel@nongnu.org; Wed, 01 Mar 2017 02:48:51 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ciz0B-0004ic-GJ for qemu-devel@nongnu.org; Wed, 01 Mar 2017 02:48:47 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v217lFVP128696 for ; Wed, 1 Mar 2017 02:47:58 -0500 Received: from e28smtp07.in.ibm.com (e28smtp07.in.ibm.com [125.16.236.7]) by mx0a-001b2d01.pphosted.com with ESMTP id 28wt7a81t4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 01 Mar 2017 02:47:56 -0500 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 Mar 2017 13:14:31 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 1 Mar 2017 13:14:29 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 8EEF4394005C; Wed, 1 Mar 2017 13:14:28 +0530 (IST) Received: from d28av07.in.ibm.com (d28av07.in.ibm.com [9.184.220.146]) by d28relay05.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v217iOaL15794374; Wed, 1 Mar 2017 13:14:24 +0530 Received: from d28av07.in.ibm.com (localhost [127.0.0.1]) by d28av07.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v217iRxO001741; Wed, 1 Mar 2017 13:14:27 +0530 Received: from abhimanyu.in.ibm.com (abhimanyu.in.ibm.com [9.124.35.30]) by d28av07.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v217iRFH001738; Wed, 1 Mar 2017 13:14:27 +0530 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, rth@twiddle.net Date: Wed, 1 Mar 2017 13:14:11 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030107-0024-0000-0000-000003AA6D2D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030107-0025-0000-0000-00001126713A Message-Id: <1488354251-20802-1-git-send-email-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-01_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1703010076 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] target/ppc: rewrite f[n]m[add, sub] using float64_muladd 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: qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, bharata@linux.vnet.ibm.com 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" Use the softfloat api for fused multiply-add. As we are using the fused multiply-add, the intermediate result for setting VXISI is not available. Signed-off-by: Nikunj A Dadhania --- target/ppc/fpu_helper.c | 201 +++++++-------------------------------------= ---- 1 file changed, 29 insertions(+), 172 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 58aee64..1701b80 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -742,179 +742,36 @@ uint64_t helper_frim(CPUPPCState *env, uint64_t arg) { return do_fri(env, arg, float_round_down); } - -/* fmadd - fmadd. */ -uint64_t helper_fmadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2, - uint64_t arg3) -{ - CPU_DoubleU farg1, farg2, farg3; - - farg1.ll =3D arg1; - farg2.ll =3D arg2; - farg3.ll =3D arg3; - - if (unlikely((float64_is_infinity(farg1.d) && float64_is_zero(farg2.d)= ) || - (float64_is_zero(farg1.d) && float64_is_infinity(farg2.d)= ))) { - /* Multiplication of zero by infinity */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); - } else { - if (unlikely(float64_is_signaling_nan(farg1.d, &env->fp_status) || - float64_is_signaling_nan(farg2.d, &env->fp_status) || - float64_is_signaling_nan(farg3.d, &env->fp_status))) { - /* sNaN operation */ - float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); - } - /* This is the way the PowerPC specification defines it */ - float128 ft0_128, ft1_128; - - ft0_128 =3D float64_to_float128(farg1.d, &env->fp_status); - ft1_128 =3D float64_to_float128(farg2.d, &env->fp_status); - ft0_128 =3D float128_mul(ft0_128, ft1_128, &env->fp_status); - if (unlikely(float128_is_infinity(ft0_128) && - float64_is_infinity(farg3.d) && - float128_is_neg(ft0_128) !=3D float64_is_neg(farg3.d)= )) { - /* Magnitude subtraction of infinities */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI,= 1); - } else { - ft1_128 =3D float64_to_float128(farg3.d, &env->fp_status); - ft0_128 =3D float128_add(ft0_128, ft1_128, &env->fp_status); - farg1.d =3D float128_to_float64(ft0_128, &env->fp_status); - } - } - - return farg1.ll; -} - -/* fmsub - fmsub. */ -uint64_t helper_fmsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2, - uint64_t arg3) -{ - CPU_DoubleU farg1, farg2, farg3; - - farg1.ll =3D arg1; - farg2.ll =3D arg2; - farg3.ll =3D arg3; - - if (unlikely((float64_is_infinity(farg1.d) && float64_is_zero(farg2.d)= ) || - (float64_is_zero(farg1.d) && - float64_is_infinity(farg2.d)))) { - /* Multiplication of zero by infinity */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); - } else { - if (unlikely(float64_is_signaling_nan(farg1.d, &env->fp_status) || - float64_is_signaling_nan(farg2.d, &env->fp_status) || - float64_is_signaling_nan(farg3.d, &env->fp_status))) { - /* sNaN operation */ - float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); - } - /* This is the way the PowerPC specification defines it */ - float128 ft0_128, ft1_128; - - ft0_128 =3D float64_to_float128(farg1.d, &env->fp_status); - ft1_128 =3D float64_to_float128(farg2.d, &env->fp_status); - ft0_128 =3D float128_mul(ft0_128, ft1_128, &env->fp_status); - if (unlikely(float128_is_infinity(ft0_128) && - float64_is_infinity(farg3.d) && - float128_is_neg(ft0_128) =3D=3D float64_is_neg(farg3.= d))) { - /* Magnitude subtraction of infinities */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI,= 1); - } else { - ft1_128 =3D float64_to_float128(farg3.d, &env->fp_status); - ft0_128 =3D float128_sub(ft0_128, ft1_128, &env->fp_status); - farg1.d =3D float128_to_float64(ft0_128, &env->fp_status); - } - } - return farg1.ll; -} - -/* fnmadd - fnmadd. */ -uint64_t helper_fnmadd(CPUPPCState *env, uint64_t arg1, uint64_t arg2, - uint64_t arg3) -{ - CPU_DoubleU farg1, farg2, farg3; - - farg1.ll =3D arg1; - farg2.ll =3D arg2; - farg3.ll =3D arg3; - - if (unlikely((float64_is_infinity(farg1.d) && float64_is_zero(farg2.d)= ) || - (float64_is_zero(farg1.d) && float64_is_infinity(farg2.d)= ))) { - /* Multiplication of zero by infinity */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); - } else { - if (unlikely(float64_is_signaling_nan(farg1.d, &env->fp_status) || - float64_is_signaling_nan(farg2.d, &env->fp_status) || - float64_is_signaling_nan(farg3.d, &env->fp_status))) { - /* sNaN operation */ - float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); - } - /* This is the way the PowerPC specification defines it */ - float128 ft0_128, ft1_128; - - ft0_128 =3D float64_to_float128(farg1.d, &env->fp_status); - ft1_128 =3D float64_to_float128(farg2.d, &env->fp_status); - ft0_128 =3D float128_mul(ft0_128, ft1_128, &env->fp_status); - if (unlikely(float128_is_infinity(ft0_128) && - float64_is_infinity(farg3.d) && - float128_is_neg(ft0_128) !=3D float64_is_neg(farg3.d)= )) { - /* Magnitude subtraction of infinities */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI,= 1); - } else { - ft1_128 =3D float64_to_float128(farg3.d, &env->fp_status); - ft0_128 =3D float128_add(ft0_128, ft1_128, &env->fp_status); - farg1.d =3D float128_to_float64(ft0_128, &env->fp_status); - } - if (likely(!float64_is_any_nan(farg1.d))) { - farg1.d =3D float64_chs(farg1.d); - } - } - return farg1.ll; -} - -/* fnmsub - fnmsub. */ -uint64_t helper_fnmsub(CPUPPCState *env, uint64_t arg1, uint64_t arg2, - uint64_t arg3) -{ - CPU_DoubleU farg1, farg2, farg3; - - farg1.ll =3D arg1; - farg2.ll =3D arg2; - farg3.ll =3D arg3; - - if (unlikely((float64_is_infinity(farg1.d) && float64_is_zero(farg2.d)= ) || - (float64_is_zero(farg1.d) && - float64_is_infinity(farg2.d)))) { - /* Multiplication of zero by infinity */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); - } else { - if (unlikely(float64_is_signaling_nan(farg1.d, &env->fp_status) || - float64_is_signaling_nan(farg2.d, &env->fp_status) || - float64_is_signaling_nan(farg3.d, &env->fp_status))) { - /* sNaN operation */ - float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); - } - /* This is the way the PowerPC specification defines it */ - float128 ft0_128, ft1_128; - - ft0_128 =3D float64_to_float128(farg1.d, &env->fp_status); - ft1_128 =3D float64_to_float128(farg2.d, &env->fp_status); - ft0_128 =3D float128_mul(ft0_128, ft1_128, &env->fp_status); - if (unlikely(float128_is_infinity(ft0_128) && - float64_is_infinity(farg3.d) && - float128_is_neg(ft0_128) =3D=3D float64_is_neg(farg3.= d))) { - /* Magnitude subtraction of infinities */ - farg1.ll =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXISI,= 1); - } else { - ft1_128 =3D float64_to_float128(farg3.d, &env->fp_status); - ft0_128 =3D float128_sub(ft0_128, ft1_128, &env->fp_status); - farg1.d =3D float128_to_float64(ft0_128, &env->fp_status); - } - if (likely(!float64_is_any_nan(farg1.d))) { - farg1.d =3D float64_chs(farg1.d); - } - } - return farg1.ll; +#define FPU_FMADD(op, sub, negate) \ +uint64_t helper_##op(CPUPPCState *env, uint64_t arg1, \ + uint64_t arg2, \ + uint64_t arg3) \ +{ \ + if (unlikely((float64_is_infinity(arg1) && float64_is_zero(arg2)) || \ + (float64_is_zero(arg1) && float64_is_infinity(arg2)))) { \ + /* Multiplication of zero by infinity */ \ + arg1 =3D float_invalid_op_excp(env, POWERPC_EXCP_FP_VXIMZ, 1); \ + } else { \ + if (unlikely(float64_is_signaling_nan(arg1, &env->fp_status) || \ + float64_is_signaling_nan(arg2, &env->fp_status) || \ + float64_is_signaling_nan(arg3, &env->fp_status))) { \ + /* sNaN operation */ \ + float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1); \ + } \ + arg1 =3D float64_muladd(arg1, arg2, arg3, sub, &env->fp_status); \ + if (negate) { \ + if (likely(!float64_is_any_nan(arg1))) { \ + arg1 =3D float64_chs(arg1); \ + } \ + } \ + float_check_status(env); \ + } \ + return arg1; \ } +FPU_FMADD(fmadd, 0, 0) +FPU_FMADD(fnmadd, 0, 1) +FPU_FMADD(fmsub, float_muladd_negate_c, 0) +FPU_FMADD(fnmsub, float_muladd_negate_c, 1) =20 /* frsp - frsp. */ uint64_t helper_frsp(CPUPPCState *env, uint64_t arg) --=20 2.7.4