From nobody Tue Nov 11 21:04:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=us.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1566254021; cv=none; d=zoho.com; s=zohoarc; b=kFcgxa26UdPk/iOkzeWbYh3SCGy1LWuZ2CLMprotq7ntj/E+u9D+TqFaNlXywlW4VtiWOS8TLP7ki7GW/kvvyXanfBjfWl/AcLpjkrpe7J4hD+Z183AH9PTvE44HFjVec2asps5fg0IRmpRZCvhcnhdIYMenaPlx2toHoCUfFcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566254021; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=fW2s8HVGUTz4dSUhjRUPcXZ+xIwsGmi+KQFPVqGAoeU=; b=l4d6Z5mSAahZr9b9v+wjL6pDTXAENhOhJq9keLVV3W1ht8ilqC/YyW0a0RMWW8CEAsPk+O2XJQaYU2bh2IdklZFQ8Nw8g/a8R4Z65LHzKxLlRmzt/vbOdZPbigxb4L4LLlT4uspcFn4pohNAFWx0lZ56WoRj+qi+hU+JQ7AqE+Y= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566254021909203.41841084401426; Mon, 19 Aug 2019 15:33:41 -0700 (PDT) Received: from localhost ([::1]:60154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzqDc-0002aO-R3 for importer@patchew.org; Mon, 19 Aug 2019 18:33:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60668) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpQ1-0007KW-M9 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:42:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzpPy-00085o-SS for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:42:23 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:29392 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzpPy-00085h-NU for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:42:22 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7JLbAon066698 for ; Mon, 19 Aug 2019 17:42:22 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ug0xx6ryj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Aug 2019 17:42:21 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Aug 2019 22:42:20 +0100 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 19 Aug 2019 22:42:18 +0100 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7JLgHWi51118516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Aug 2019 21:42:17 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE61078063; Mon, 19 Aug 2019 21:42:17 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 826D07805E; Mon, 19 Aug 2019 21:42:17 +0000 (GMT) Received: from localhost (unknown [9.80.202.43]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 19 Aug 2019 21:42:17 +0000 (GMT) From: "Paul A. Clarke" To: david@gibson.dropbear.id.au Date: Mon, 19 Aug 2019 16:42:16 -0500 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 19081921-0004-0000-0000-000015370615 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011620; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01249231; UDB=6.00659450; IPR=6.01030767; MB=3.00028239; MTD=3.00000008; XFM=3.00000015; UTC=2019-08-19 21:42:20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19081921-0005-0000-0000-00008CF13ACC Message-Id: <1566250936-14538-1-git-send-email-pc@us.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-08-19_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=752 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908190217 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2] ppc: Fix emulated single to double denormalized conversions 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: richard.henderson@linaro.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Paul A. Clarke" helper_todouble() was not properly converting any denormalized 32 bit float to 64 bit double. Fix-suggested-by: Richard Henderson Signed-off-by: Paul A. Clarke v2: - Splitting patch "ppc: Three floating point fixes"; this is just one part. - Original suggested "fix" was likely flawed. v2 is rewritten by Richard Henderson (Thanks, Richard!); I reformatted the comments in a couple of places, compiled, and tested. --- target/ppc/fpu_helper.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 52bcda2..07bc905 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -73,11 +73,20 @@ uint64_t helper_todouble(uint32_t arg) /* Zero or Denormalized operand. */ ret =3D (uint64_t)extract32(arg, 31, 1) << 63; if (unlikely(abs_arg !=3D 0)) { - /* Denormalized operand. */ - int shift =3D clz32(abs_arg) - 9; - int exp =3D -126 - shift + 1023; + /* + * Denormalized operand. + * Shift fraction so that the msb is in the implicit bit posit= ion. + * Thus, shift is in the range [1:23]. + */ + int shift =3D clz32(abs_arg) - 8; + /* + * The first 3 terms compute the float64 exponent. We then bi= as + * this result by -1 so that we can swallow the implicit bit b= elow. + */ + int exp =3D -126 - shift + 1023 - 1; + ret |=3D (uint64_t)exp << 52; - ret |=3D abs_arg << (shift + 29); + ret +=3D (uint64_t)abs_arg << (52 - 23 + shift); } } return ret; --=20 1.8.3.1