From patchwork Fri Oct 13 16:24:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 115795 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp925935qgn; Fri, 13 Oct 2017 09:33:35 -0700 (PDT) X-Received: by 10.200.8.239 with SMTP id y44mr2951576qth.341.1507912414839; Fri, 13 Oct 2017 09:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507912414; cv=none; d=google.com; s=arc-20160816; b=02H2TBBkvFrYGfT6M0ybikR2thlAZlcKv/VCaOPLylTHycAvfSQcRzExQKpLz5WPwS OlxX83T/rQvPkoX2Z8NTtt0Bb2g4N68jcpuVypXwOc0QCXt63YjWoc2zMO2CgJs5/TdZ RlX8eDCVxrOcZOvFyN31cG1zeKzlGMkbnUDi9PQN6EFtMrv8vvsrrUsRQATV9J8Tpi2s EqvclxkoUtVLsuXR7lwWUwsAQdzsNH1m12+XTbxR6He2mMJCN556FsKhPQyzldZRJcxq kCmGZkivwUeaRaodChqjlLYLZEsEiZIYCFmgk1AD3BH9sCyBh60S4mWYp4FpoznqQW/I 0j3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=lDCNBjVmHi7RrINXB4MDqtNFEFsBh3bb00DT6pG3DGE=; b=ARe9GuhbXYnUqUAIKdlOH3lSlmNkqxW5/YOC6ebvxQnzqZGt4+yrgpEk0pGKnUyddn +rw3tABOPEgvrd56kgYG3wsMDktKJ3d954Kd+XmLCKJQIiIZYRmQq1pwk+A4/umoAGL8 xmKrsOzskkybaQMMzVhBSTX2g7twPjeMKfjHCgn7w1kW9yNQAX5qP8sS6Db5cJt9LSJX M0nE172vvaZypr7KW4dh8Thb0Gs4BfcbndDGf6A+/fuI0RBsX4sreHy7FKzffNUm/aVp kXVtWxrYYnADnMmBRQX4El5g/lyawmmfVUVT/3y1+H9tg9N0NEUM6SDoW6y8xebBKuK/ 4t0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=efsvOfao; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a86si1161390qkh.46.2017.10.13.09.33.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Oct 2017 09:33:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=efsvOfao; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32tw-0001UD-Kj for patch@linaro.org; Fri, 13 Oct 2017 12:33:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32lX-0002V4-0a for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e32lW-0006ZS-1u for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:50 -0400 Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:51101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e32lV-0006Yg-Mq for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:49 -0400 Received: by mail-wr0-x22f.google.com with SMTP id q42so1429685wrb.7 for ; Fri, 13 Oct 2017 09:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lDCNBjVmHi7RrINXB4MDqtNFEFsBh3bb00DT6pG3DGE=; b=efsvOfaoq6Nx+EDizrB3gRfKThl52reokxIsfX4fi1SinR8d7TF80clPOnkwh3m2ZZ /4QH8iECScZmMRLkUyAHOSPImqIHbQbRdBDoLWAyRXV6IVUi2GE7JDWKwWmp2HTKzyW0 jyhwZIygCVCUc5Faiugcj5ddyhQ0D4p/JYnEA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lDCNBjVmHi7RrINXB4MDqtNFEFsBh3bb00DT6pG3DGE=; b=IokKFhKPO+S6CstmlBH7g1n5iK7hmP8vxEG/jZjQNnTmbUJY1WW+wbIMeJWQ7qFNTJ SHfWlLzK/sTv1+gALzUJozDGmwaTCXP8eJYrwIjI9TM9PpLF28U6y73ezLRloHEqyMWK QOYtZZaLS8EJwAxlwW2fnrB14++Y4ciEJ1JYurZ9hWj4nMv75Cf1W6Wg1jdWvdxkBoe4 6r7JvYagSHmJx4rUi6prdJ6L+6dpu7lCoHTKLBGH4l4QVMp7pNZnaXK2NuEffM41UvHp 1WoC6C2fR/EGJZjl5jbceNhj08sno9my1cv56xdEa34utKiPnuI1rOVvDy0hHkA0/xpB derg== X-Gm-Message-State: AMCzsaV/u0sHiuDkCO1CF61ySYIvq0djsK8Lu2APpjeJ8iPh45F067UN h+aEP4Yruo1/0mVx2+keBiD++w== X-Google-Smtp-Source: AOwi7QDTVgbIn175kKXa+16yKSe0oCddxPoVBeqHzpj6fGAhzSWh5iac5bvvtD4HIJ+lEuHyHvtF4Q== X-Received: by 10.223.151.143 with SMTP id s15mr2107494wrb.7.1507911888546; Fri, 13 Oct 2017 09:24:48 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w126sm1302265wme.25.2017.10.13.09.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 09:24:42 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id BFE8B3E0755; Fri, 13 Oct 2017 17:24:38 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org Date: Fri, 13 Oct 2017 17:24:13 +0100 Message-Id: <20171013162438.32458-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013162438.32458-1-alex.bennee@linaro.org> References: <20171013162438.32458-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22f Subject: [Qemu-devel] [RFC PATCH 05/30] softfloat: implement propagateFloat16NaN 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, qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will be required when expanding the MINMAX() macro for 16 bit/half-precision operations. Signed-off-by: Alex Bennée --- fpu/softfloat-specialize.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.14.1 Reviewed-by: Richard Henderson diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index de2c5d5702..c8282b8bf7 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -685,6 +685,49 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, } #endif +/*---------------------------------------------------------------------------- +| Takes two half-precision floating-point values `a' and `b', one of which +| is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a +| signaling NaN, the invalid exception is raised. +*----------------------------------------------------------------------------*/ + +static float16 propagateFloat16NaN(float16 a, float16 b, float_status *status) +{ + flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; + flag aIsLargerSignificand; + uint16_t av, bv; + + aIsQuietNaN = float16_is_quiet_nan(a, status); + aIsSignalingNaN = float16_is_signaling_nan(a, status); + bIsQuietNaN = float16_is_quiet_nan(b, status); + bIsSignalingNaN = float16_is_signaling_nan(b, status); + av = float16_val(a); + bv = float16_val(b); + + if (aIsSignalingNaN | bIsSignalingNaN) { + float_raise(float_flag_invalid, status); + } + + if (status->default_nan_mode) { + return float16_default_nan(status); + } + + if ((uint16_t)(av << 1) < (uint16_t)(bv << 1)) { + aIsLargerSignificand = 0; + } else if ((uint16_t)(bv << 1) < (uint16_t)(av << 1)) { + aIsLargerSignificand = 1; + } else { + aIsLargerSignificand = (av < bv) ? 1 : 0; + } + + if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, + aIsLargerSignificand)) { + return float16_maybe_silence_nan(b, status); + } else { + return float16_maybe_silence_nan(a, status); + } +} + /*---------------------------------------------------------------------------- | Takes two single-precision floating-point values `a' and `b', one of which | is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a