From patchwork Fri Jan 27 08:03:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 9540657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4111360415 for ; Fri, 27 Jan 2017 08:05:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30B8127F85 for ; Fri, 27 Jan 2017 08:05:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24E3B27FC0; Fri, 27 Jan 2017 08:05:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A62A627F85 for ; Fri, 27 Jan 2017 08:05:18 +0000 (UTC) Received: from localhost ([::1]:43555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX1X3-0006Ih-Fr for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 Jan 2017 03:05:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cX1WU-0006HJ-TP for qemu-devel@nongnu.org; Fri, 27 Jan 2017 03:04:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cX1WR-0001Tz-Pq for qemu-devel@nongnu.org; Fri, 27 Jan 2017 03:04:42 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35875) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cX1WR-0001TR-HK for qemu-devel@nongnu.org; Fri, 27 Jan 2017 03:04:39 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v0R7x2KH057746 for ; Fri, 27 Jan 2017 03:04:38 -0500 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 287va9b1b8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 27 Jan 2017 03:04:38 -0500 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Jan 2017 18:04:36 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 27 Jan 2017 18:04:33 +1000 Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 4A7ED2CE8054; Fri, 27 Jan 2017 19:04:33 +1100 (EST) Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v0R84P9F25559180; Fri, 27 Jan 2017 19:04:33 +1100 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v0R840Nb006599; Fri, 27 Jan 2017 19:04:00 +1100 Received: from bharata.in.ibm.com ([9.79.191.70]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v0R83rNl006093; Fri, 27 Jan 2017 19:03:57 +1100 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Fri, 27 Jan 2017 13:33:32 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485504213-21632-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1485504213-21632-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17012708-0052-0000-0000-000002108B06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17012708-0053-0000-0000-000007AE5D4D Message-Id: <1485504213-21632-2-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-27_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701270085 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [RFC PATCH v2 1/2] softfloat: Handle float64 rounding properly for underflow case 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: peter.maydell@linaro.org, nikunj@linux.vnet.ibm.com, qemu-ppc@nongnu.org, Bharata B Rao , david@gibson.dropbear.id.au, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When rounding a floating point result to float64 precision, the existing code doesn't re-calculate the required round increment for the underflow case. Fix this. Signed-off-by: Bharata B Rao --- fpu/softfloat.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index c295f31..b04699c 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -651,6 +651,23 @@ static float64 roundAndPackFloat64(flag zSign, int zExp, uint64_t zSig, if (isTiny && roundBits) { float_raise(float_flag_underflow, status); } + switch (roundingMode) { + case float_round_nearest_even: + case float_round_ties_away: + roundIncrement = 0x200; + break; + case float_round_to_zero: + roundIncrement = 0; + break; + case float_round_up: + roundIncrement = zSign ? 0 : 0x3ff; + break; + case float_round_down: + roundIncrement = zSign ? 0x3ff : 0; + break; + default: + abort(); + } } } if (roundBits) {