From patchwork Thu Jul 20 15:04:20 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: 108360 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2255912qge; Thu, 20 Jul 2017 08:08:45 -0700 (PDT) X-Received: by 10.55.16.94 with SMTP id a91mr5221319qkh.349.1500563325383; Thu, 20 Jul 2017 08:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500563325; cv=none; d=google.com; s=arc-20160816; b=yMF8d3xVkL+X2owrc8olOMl8EeBca2seVUaHYZ2xWlV8DzzkmwMNhDFe9hPxyOUiQj RREA8gnYMTp4JpU9mtvf+3SyJGAU3T0t7L8c86cCln1kqg2l5cQyMyy5RDc9h3kmKxPS Yyi+cyNsa1jqqNdH02+DYr23vBeklEKn+F6KtgW8VeQWux0+sPpWoWX0SFqjLqYWZPw1 ANuNLI8j59mKoHNnLuPQY8s1FL5ZupL7+lRvEwQI58glZpQ6Nze7RS71vRL9ENzfnPcV qa82SFDYRx0u2gvg6SBlhoHQssYojR/t9qT73xI3wW8GcF8oFNum95mwb8DUWHAE7jDH oQNg== 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=OsL8N8uKo45gjQi0mbsItUXe1koHb2xrTzUYV5XxC0Q=; b=nb4WUrQOBC9otbujaSKpK7wbNRzZXF4Yppd/dbTp2nl/ChEycIBDG0is+mOGyj1WKS 4HomVTb+W9iB7ZIsT2OdwVBld7Kpr0N52ghmwPRc2tYvrKncf2QizF/BRp2cig628fgk Zl8XJuVwzhepiqyrmbjRASPQV5VY4/vn3fUAtkqU3WmjtXvH13tEL6/CTrcjOFgEF1Bw JiOu6xzcYPIdrYoU+bXeOZX25Ob/4CbWKfnWsgiggVzEri5iipar2eKL3KJVXhzyWh/6 LAqQY3ipwRDfdGWnyAEmDC3kzJxUM/iQzFLS2aFDY6KWx5scqyGQgiyJbjoMUHU8y7fJ beeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=eenjbnU+; 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 z197si2040660qka.413.2017.07.20.08.08.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 20 Jul 2017 08:08:45 -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.b=eenjbnU+; 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]:38476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYD4E-0007Mw-I7 for patch@linaro.org; Thu, 20 Jul 2017 11:08:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYD0c-0004Yu-5L for qemu-devel@nongnu.org; Thu, 20 Jul 2017 11:05:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYD0Y-0007z3-Le for qemu-devel@nongnu.org; Thu, 20 Jul 2017 11:04:58 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:36747) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYD0Y-0007yK-ES for qemu-devel@nongnu.org; Thu, 20 Jul 2017 11:04:54 -0400 Received: by mail-wm0-x236.google.com with SMTP id k69so26976574wmc.1 for ; Thu, 20 Jul 2017 08:04:54 -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=OsL8N8uKo45gjQi0mbsItUXe1koHb2xrTzUYV5XxC0Q=; b=eenjbnU+6bnqCw1cvE41VW6HsALDSYOeKdJUEdDL79L/WrM7ofv2tBcbdOoo6Vi2ZO egzy2BBoDEV/S3SSh5m1OCaPy9Lqmhu8cNsvUm/2avYKSVqZbbNureymcUR/2Nyc23tN pIidoI7FSHR+UCRn1YEh5HP2ezRrlAOZvzMDM= 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=OsL8N8uKo45gjQi0mbsItUXe1koHb2xrTzUYV5XxC0Q=; b=l4WRA5wYHfBHU4nPTM3c8DuRiX+AyIKmrVFYSQSTgon8mTpt2UermVbS94JvBV3zfF ylAaNBofyWzXgWFMW/TLY9dbVqOb5PlbKWoyX+7q8zShBiE7iaMpa4MdXLxAuxOsC5vf bop85IXGcSNyyBBt0rV8mXzHrvUh5+N69hVcSB0p/fyJDs23DlkvQg/3xPODExN/Ow4T EX5mrsxuXy43Mz+n+3lsm8xKaNv+ZpIOf03lgJrBAMTnZxyk1E3KhnH8ZdvJjqgiPZPD wJUolEBwYCyhCj0NHekEkVQk1XRfjLpqhu4PX8XTubb3FQT9LS25AIk+yWQM/4I+eMJE PByA== X-Gm-Message-State: AIVw112/y53SWobBmNUzrGJ2NJK8Z9vow+9qdokO2TpxpkpUM5BEwhpc QSBCBPyuuakwgERY X-Received: by 10.28.26.5 with SMTP id a5mr1111078wma.80.1500563093428; Thu, 20 Jul 2017 08:04:53 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w30sm8725869wrb.49.2017.07.20.08.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jul 2017 08:04:51 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A704B3E0B09; Thu, 20 Jul 2017 16:04:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 20 Jul 2017 16:04:20 +0100 Message-Id: <20170720150426.12393-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170720150426.12393-1-alex.bennee@linaro.org> References: <20170720150426.12393-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:c09::236 Subject: [Qemu-devel] [RFC PATCH for 2.11 17/23] fpu/softfloat2a: 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: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno , rth@twiddle.net 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/softfloat2a/softfloat-specialize.h | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.13.0 diff --git a/fpu/softfloat2a/softfloat-specialize.h b/fpu/softfloat2a/softfloat-specialize.h index de2c5d5702..c8282b8bf7 100644 --- a/fpu/softfloat2a/softfloat-specialize.h +++ b/fpu/softfloat2a/softfloat-specialize.h @@ -686,6 +686,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 | signaling NaN, the invalid exception is raised.