From patchwork Tue Dec 31 13:35:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22844 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 54AA2218CC for ; Tue, 31 Dec 2013 13:36:46 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id e14sf61330565iej.4 for ; Tue, 31 Dec 2013 05:36:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=47+n7UWStEIjhMGN2nA7AmExDfSLspA3xjtXJrIVwJk=; b=EKUijUVuju8e1S2mefqpIzmN+Wq2SMYPuh6VDXqcUe11MiJACDegJDOsrXTBjrO0g9 PEB0dbaxJMGm1xfMQt2ivuTP0ITsD/vlradkEyQQ086E+qrZClQfFBk1UzOKiOp58Le1 crtWD7Eiv+K0E0FosgvQmlh21i9oGiDCbkdVTfmU8iJfLI1e9dPyx3zaDGegPR10BVuM iEnlRkuJcExae8v1hyX6fpICIKOvlZGvHDRW2zq9zDs/mxm5eBiCgQL9Zf51vEsCAq5E FzprkIj2+2BmP4LtZYYYTyGZL0Bsv3eIj6SbHdLGgpxxx+TVrQ0/WO7aR2CzcQmRqDzt HwMg== X-Gm-Message-State: ALoCoQn1ZA0ycJb+cmi/BazA7+HVr2Yqruav3wf7NECJ1Fi+4GjqzYHGWV7JtwTbuTaCTrhLxw5Y X-Received: by 10.182.158.4 with SMTP id wq4mr29941929obb.18.1388497005620; Tue, 31 Dec 2013 05:36:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.41.66 with SMTP id d2ls3759758qel.10.gmail; Tue, 31 Dec 2013 05:36:45 -0800 (PST) X-Received: by 10.58.187.129 with SMTP id fs1mr238680vec.45.1388497005515; Tue, 31 Dec 2013 05:36:45 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id vq3si19109405veb.103.2013.12.31.05.36.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 31 Dec 2013 05:36:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so6581575veb.35 for ; Tue, 31 Dec 2013 05:36:45 -0800 (PST) X-Received: by 10.52.33.178 with SMTP id s18mr5025972vdi.39.1388497005418; Tue, 31 Dec 2013 05:36:45 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp664851ved; Tue, 31 Dec 2013 05:36:44 -0800 (PST) X-Received: by 10.205.36.81 with SMTP id sz17mr13564471bkb.29.1388497004509; Tue, 31 Dec 2013 05:36:44 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id tn6si15776789bkb.68.2013.12.31.05.36.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 31 Dec 2013 05:36:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VxzUE-0000w9-Kn; Tue, 31 Dec 2013 13:35:58 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Michael Matz , Claudio Fontana , Dirk Mueller , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Will Newton , Peter Crosthwaite , Tom Musta , Aurelien Jarno Subject: [PATCH 08/22] softfloat: Fix float64_to_uint64_round_to_zero Date: Tue, 31 Dec 2013 13:35:44 +0000 Message-Id: <1388496958-3542-9-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1388496958-3542-1-git-send-email-peter.maydell@linaro.org> References: <1388496958-3542-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tom Musta The float64_to_uint64_round_to_zero routine is incorrect. For example, the following test pattern: 46697351FF4AEC29 / 0x1.97351ff4aec29p+103 currently produces 8000000000000000 instead of FFFFFFFFFFFFFFFF. This patch re-implements the routine to temporarily force the rounding mode and use the float64_to_uint64 routine. This contribution can be licensed under either the softfloat-2a or -2b license. Signed-off-by: Tom Musta Message-id: 1387397961-4894-4-git-send-email-tommusta@gmail.com Signed-off-by: Peter Maydell --- fpu/softfloat.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index af37164..8e536ad 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -6786,13 +6786,11 @@ uint64_t float64_to_uint64(float64 a STATUS_PARAM) uint64_t float64_to_uint64_round_to_zero (float64 a STATUS_PARAM) { - int64_t v; - - v = float64_val(int64_to_float64(INT64_MIN STATUS_VAR)); - v += float64_val(a); - v = float64_to_int64_round_to_zero(make_float64(v) STATUS_VAR); - - return v - INT64_MIN; + signed char current_rounding_mode = STATUS(float_rounding_mode); + set_float_rounding_mode(float_round_to_zero STATUS_VAR); + int64_t v = float64_to_uint64(a STATUS_VAR); + set_float_rounding_mode(current_rounding_mode STATUS_VAR); + return v; } #define COMPARE(s, nan_exp) \