From patchwork Tue Dec 31 13:35:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22833 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C8378218CC for ; Tue, 31 Dec 2013 13:36:16 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf39900837pab.7 for ; Tue, 31 Dec 2013 05:36:16 -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=uqciN9sEYXL7oHushu+hSiu2QKb2ediwRjP+bKDyzKs=; b=lEe18ZEzUaRDqMOOk4uLPhZz/NrDgzF8kP4r3FAJsEeJAfAfOxTwouyH56tzTh7zR+ 5Aac/OvMpRI1f0XqXrXLQopEGH4SfPe9l0z+oeHsgcZiGPDtucCtlXbWlxsHbjifTxwH wza3eqYH3sbjLb5DKaZhrkRcZgsuGvubZyuDjypaqguyK+kQV5LVTPZvB9DES0C1gKxY 45pxUrlrcYERpTEAPqHKg5M5kQaNJL4dxNXjrD2Dv63xMZyjZjcx54r0n9xrJwAnvn/K qZYlimf697bSNHDvAxT+av8bcRgRrOAXgzVGEV3E4OVLrPJniZaMxvjtqeWBXAgrSAiu Q+cw== X-Gm-Message-State: ALoCoQmpJKJu+wnr9ILc1I9AUh4OAHFDx0+Sl4Alfy5TX+IoJ2tpyjOKcDi1bLRsojDej3bzyPeR X-Received: by 10.66.218.70 with SMTP id pe6mr2697132pac.33.1388496976128; Tue, 31 Dec 2013 05:36:16 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.108 with SMTP id g12ls4005288qej.81.gmail; Tue, 31 Dec 2013 05:36:16 -0800 (PST) X-Received: by 10.58.181.165 with SMTP id dx5mr2743880vec.19.1388496976020; Tue, 31 Dec 2013 05:36:16 -0800 (PST) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id s4si19111643vcy.61.2013.12.31.05.36.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 31 Dec 2013 05:36:16 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.177 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.177; Received: by mail-ve0-f177.google.com with SMTP id db12so6502557veb.36 for ; Tue, 31 Dec 2013 05:36:15 -0800 (PST) X-Received: by 10.52.27.170 with SMTP id u10mr154840vdg.74.1388496975917; Tue, 31 Dec 2013 05:36:15 -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 ey3csp664815ved; Tue, 31 Dec 2013 05:36:15 -0800 (PST) X-Received: by 10.112.167.228 with SMTP id zr4mr11867935lbb.56.1388496971013; Tue, 31 Dec 2013 05:36:11 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id x7si24873154lag.21.2013.12.31.05.36.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 31 Dec 2013 05:36:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VxzUF-0000wm-3m; Tue, 31 Dec 2013 13:35:59 +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 17/22] target-arm: Ignore most exceptions from scalbn when doing fixpoint conversion Date: Tue, 31 Dec 2013 13:35:53 +0000 Message-Id: <1388496958-3542-18-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.177 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: , The VFP fixed point conversion helpers first call float_scalbn and then convert the result to an integer. This scalbn operation may set floating point exception flags for: * overflow & inexact (if it overflows to infinity) * input denormal squashed to zero * output denormal squashed to zero Of these, we only care about the input-denormal flag, since the output of the whole scale-and-convert operation will be an integer (so squashed-output-denormal and overflow don't apply). Suppress the others by saving the pre-scalb exception flags and only copying across a potential input-denormal flag. Signed-off-by: Peter Maydell --- target-arm/helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index a9b0927..67dc212 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -3994,18 +3994,27 @@ float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ return float##fsz##_scalbn(tmp, -(int)shift, fpst); \ } +/* Notice that we want only input-denormal exception flags from the + * scalbn operation: the other possible flags (overflow+inexact if + * we overflow to infinity, output-denormal) aren't correct for the + * complete scale-and-convert operation. + */ #define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, round) \ uint##isz##_t HELPER(vfp_to##name##p##round)(float##fsz x, \ uint32_t shift, \ void *fpstp) \ { \ float_status *fpst = fpstp; \ + int old_exc_flags = get_float_exception_flags(fpst); \ float##fsz tmp; \ if (float##fsz##_is_any_nan(x)) { \ float_raise(float_flag_invalid, fpst); \ return 0; \ } \ tmp = float##fsz##_scalbn(x, shift, fpst); \ + old_exc_flags |= get_float_exception_flags(fpst) \ + & float_flag_input_denormal; \ + set_float_exception_flags(old_exc_flags, fpst); \ return float##fsz##_to_##itype##round(tmp, fpst); \ }