From nobody Tue May 13 17:06:24 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1675205949; cv=none; d=zohomail.com; s=zohoarc; b=ND2YBVVtGZ5QKlKf47dsRIxBo6ipc0qCtO4lxVq+9+VLfzJtaZ+oZmOJ2cJNnZfOGdfXVn2ex3pBRFn0+uAERAIYiC5JB2LyUhXZ0XiVEWXUTNnZK8fOsnmEh4Wk7afd3hUIht4cUMC/aPVzXxII2FfXXo6d89On35N4I6GaO74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675205949; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OYx8J3tK/3hUCjFX9IlAs8QxJIfhOYDikXV1ZUmrCJM=; b=Gy5Uydv5DtahyLWgO7oCWFi3NO2lRcE+alw8sj3N+hG9g9VHUMAk4EkgRNXnALCgY+8fm9QR8wPlqo3BivjzPJSXU8K97NqCXPrLBWwN4wQaCSJ4s3aJBWwK4j3Tq1dvFaf+7Jc5wHHyn51+QimQCKtbsiWje5V9d/SqUPG3uVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675205949683379.278199247623; Tue, 31 Jan 2023 14:59:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMzYk-0000fN-FH; Tue, 31 Jan 2023 17:57:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMzYj-0000eQ-C6 for qemu-devel@nongnu.org; Tue, 31 Jan 2023 17:57:01 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMzYg-0003tr-8C for qemu-devel@nongnu.org; Tue, 31 Jan 2023 17:57:01 -0500 Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30VMUURe000552; Tue, 31 Jan 2023 22:56:56 GMT Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nfbuh0135-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Jan 2023 22:56:56 +0000 Received: from pps.filterd (NALASPPMTA05.qualcomm.com [127.0.0.1]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 30VMq0ZQ028677; Tue, 31 Jan 2023 22:56:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTPS id 3ncvskts7x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 31 Jan 2023 22:56:54 +0000 Received: from NALASPPMTA05.qualcomm.com (NALASPPMTA05.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30VMushf001458; Tue, 31 Jan 2023 22:56:54 GMT Received: from hu-devc-lv-u18-c.qualcomm.com (hu-tsimpson-lv.qualcomm.com [10.47.235.220]) by NALASPPMTA05.qualcomm.com (PPS) with ESMTP id 30VMurvN001452; Tue, 31 Jan 2023 22:56:54 +0000 Received: by hu-devc-lv-u18-c.qualcomm.com (Postfix, from userid 47164) id 12279500118; Tue, 31 Jan 2023 14:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=qcppdkim1; bh=OYx8J3tK/3hUCjFX9IlAs8QxJIfhOYDikXV1ZUmrCJM=; b=GHGbYJDohM0iIK5x5JO0RJmsNpUc7Q6W0ei1rB7x6bHrMdLGcgHcVH7t4N0lbHQA2g0G pLGAqeWVrFVHQRZdeCnQAG1VXicpktr2qkfK1UyJ/FJiDnSxDnaqEBeFcpR5qC0STbZi Q544TSNxknn+4kxWh0FvZJurG7Tldp/VbN8C88go9WoUzQmbWZZcV7q6g4/rQCq43FLM C400vISBxUbDP/Zyjb6F5IbfOVx/GSCqqJUSKZ2kXEBL3nfygH8tpLdWdNieT9UGXjyH ovPNoB/nvHvXrkOu+4TPKZKGv4SI0SJiqH4JgoAt51LqfnBMSx1jFgJNLpn+6aKnGQIw 8w== From: Taylor Simpson To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, ale@rev.ng, anjo@rev.ng, bcain@quicinc.com, quic_mathbern@quicinc.com Subject: [PATCH v5 11/14] Hexagon (target/hexagon) Change subtract from zero to change sign Date: Tue, 31 Jan 2023 14:56:44 -0800 Message-Id: <20230131225647.25274-12-tsimpson@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230131225647.25274-1-tsimpson@quicinc.com> References: <20230131225647.25274-1-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: jyd_aOBXelEqU5iqxGA8574FIp5HYzHe X-Proofpoint-GUID: jyd_aOBXelEqU5iqxGA8574FIp5HYzHe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 priorityscore=1501 phishscore=0 suspectscore=0 spamscore=0 impostorscore=0 adultscore=0 mlxlogscore=527 malwarescore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310197 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=tsimpson@qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, 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: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quicinc.com) X-ZM-MESSAGEID: 1675205950124100001 The F2_sffms instruction [r0 -=3D sfmpy(r1, r2)] doesn't properly handle -0. Previously we would negate the input operand by subtracting from zero. Instead, we negate by changing the sign bit. Test case added to tests/tcg/hexagon/fpstuff.c Signed-off-by: Taylor Simpson Reviewed-by: Anton Johansson --- target/hexagon/op_helper.c | 2 +- tests/tcg/hexagon/fpstuff.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 38b8aee193..9425941c69 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -1169,7 +1169,7 @@ float32 HELPER(sffms)(CPUHexagonState *env, float32 R= xV, { float32 neg_RsV; arch_fpop_start(env); - neg_RsV =3D float32_sub(float32_zero, RsV, &env->fp_status); + neg_RsV =3D float32_set_sign(RsV, float32_is_neg(RsV) ? 0 : 1); RxV =3D internal_fmafx(neg_RsV, RtV, RxV, 0, &env->fp_status); arch_fpop_end(env); return RxV; diff --git a/tests/tcg/hexagon/fpstuff.c b/tests/tcg/hexagon/fpstuff.c index 56bf562a40..90ce9a6ef3 100644 --- a/tests/tcg/hexagon/fpstuff.c +++ b/tests/tcg/hexagon/fpstuff.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2020-2022 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * Copyright(c) 2020-2023 Qualcomm Innovation Center, Inc. All Rights Res= erved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,7 @@ const int SF_HEX_NAN =3D 0xffffffff; const int SF_small_neg =3D 0xab98fba8; const int SF_denorm =3D 0x00000001; const int SF_random =3D 0x346001d6; +const int SF_neg_zero =3D 0x80000000; =20 const long long DF_QNaN =3D 0x7ff8000000000000ULL; const long long DF_SNaN =3D 0x7ff7000000000000ULL; @@ -536,6 +537,33 @@ static void check_sffixupd(void) check32(result, 0x146001d6); } =20 +static void check_sffms(void) +{ + int result; + + /* Check that sffms properly deals with -0 */ + result =3D SF_neg_zero; + asm ("%0 -=3D sfmpy(%1 , %2)\n\t" + : "+r"(result) + : "r"(SF_ZERO), "r"(SF_ZERO) + : "r12", "r8"); + check32(result, SF_neg_zero); + + result =3D SF_ZERO; + asm ("%0 -=3D sfmpy(%1 , %2)\n\t" + : "+r"(result) + : "r"(SF_neg_zero), "r"(SF_ZERO) + : "r12", "r8"); + check32(result, SF_ZERO); + + result =3D SF_ZERO; + asm ("%0 -=3D sfmpy(%1 , %2)\n\t" + : "+r"(result) + : "r"(SF_ZERO), "r"(SF_neg_zero) + : "r12", "r8"); + check32(result, SF_ZERO); +} + static void check_float2int_convs() { int res32; @@ -688,6 +716,7 @@ int main() check_invsqrta(); check_sffixupn(); check_sffixupd(); + check_sffms(); check_float2int_convs(); =20 puts(err ? "FAIL" : "PASS"); --=20 2.17.1