From patchwork Wed Feb 21 11:05:01 2018 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: 129017 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp490381ljc; Wed, 21 Feb 2018 03:05:53 -0800 (PST) X-Google-Smtp-Source: AH8x2267LTTmNqstj4b0jDrHd7xM8bmJRtMTjX+b3rWEUUdAXnbKOqtji/abYAqiKch2xxQxrZYo X-Received: by 10.129.141.73 with SMTP id w9mr1893698ywj.211.1519211153815; Wed, 21 Feb 2018 03:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519211153; cv=none; d=google.com; s=arc-20160816; b=Qib6L/csn/cXUfhT1lXHgE9wtdskrvlch9hABfj0VWUtw7V1NtGgJBWt/YOJOl11eJ lNVWv2DRTlf3eHg81dmfK1tEU2VbtYnBC6NMRd+Ys4Y4UJSgWw5Ookc65Xis4VWCUNcQ uxPzcalN41+Mw1J88UeT314F6x3ObUVsiJId9p3Vv5JSRxFB6gLqd+71i3lgb7HxSyqB 5rgFxTAk1Nv8JMLNKkRATNxjBY3ZeMANymtFTfy5T41QCDkFGOX6mVUZUVAOulAFOM9H AmHir631om3J6XrApymYw7Wk/mghdOWcC6nGP/555D0crEH0dilIQvUvsmHJP7vwUo9V japA== 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=6fRZYTkBwQgN0XXVmqeZavsg0TW6RgcOAWFA1Pfoyk8=; b=wCq1hPkNtHkYhGrn/54cyv5p+q0oTe2c241h5PmV2vPd7sBrCqhatT/uUoPHHTSfTT yMQCYFnLMHTfuOM7s3rsdVKIx0YJYraTJToQGJf33A2QtC+Omc37ln1zlZEwCLBMTRl/ hsH+BekRB2opeAQ9Axijvq0sf5VuUcGIqhepf9iAw8z1l/z/HfYx3HfmDekKFl5bK24O bwRgktQsNjm+OLzwqlyDwMbZfwwit26Yi/f1+LWQQnx03FDLVVtYIay1vcHgdDWsikSu Gf5zQIMbfrGRXjAD0qFqgOXkMkGqGXNws7H8qdYv/aTfcsBYft4PlHW+EyuS7kTQIqdv sNag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iiyQUOU5; 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 j7si221611ywa.68.2018.02.21.03.05.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 21 Feb 2018 03:05:53 -0800 (PST) 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=iiyQUOU5; 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]:60035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoSDh-0003rq-3N for patch@linaro.org; Wed, 21 Feb 2018 06:05:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eoSDM-0003ra-5S for qemu-devel@nongnu.org; Wed, 21 Feb 2018 06:05:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eoSDH-0006aj-IO for qemu-devel@nongnu.org; Wed, 21 Feb 2018 06:05:32 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:34340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eoSDH-0006aU-6g for qemu-devel@nongnu.org; Wed, 21 Feb 2018 06:05:27 -0500 Received: by mail-wr0-x241.google.com with SMTP id m5so3299274wrg.1 for ; Wed, 21 Feb 2018 03:05:27 -0800 (PST) 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=6fRZYTkBwQgN0XXVmqeZavsg0TW6RgcOAWFA1Pfoyk8=; b=iiyQUOU56dsbC0rz9aUz26nCK+rSZu2kHunXXDHZH8mvlpMdGNygjI/LtUIE9OEYXc FgFT9SzhYJkUtOCXzyksSA7Uti4ozZQEvP/JzqP9JCg2fHOUXqImJHzOJaIkXr0ceoNx fxROpHPbBk+Yh3CMVYupPf+NfYYAD8USzbJ9w= 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=6fRZYTkBwQgN0XXVmqeZavsg0TW6RgcOAWFA1Pfoyk8=; b=TVaC3lzPhfusVj3uVQE7AJta7uTy0MmQ9zOAzhbuPKm8LsoRIlpqWWUbqoXVPN7u7L xeoZAQg5JwuUVu0SF/ioYOh4g3aNdwUq6WcTEB7oIU6ztyVxcz78QqMuaIcBJMt/kyGe BkITL7Ji3BiEMexN5LTiuC2ZbAzR61qSFaofJlMc4K/0Q5D+Fxyru0zVs4M1rM1Zt168 yN4VoIThLBO7w6dTk6TO/c9BDmYs4pJNOs3kwreWaglvuSd5DJYxk9e6PAoI75pDg1Lt /+3NFAVDotbNn4RFE4VJOqiZ78lav2N9vtQPEZhJy/aSVtnKte6SLgb0KsTVGvnR/qAB /vDQ== X-Gm-Message-State: APf1xPCSW0D9Y78KSma7FCh/vN1JJaTMTgro7TXyREexatY63DPPudVs /lF4HSu0Q6Uc4s/zZ8cXaUJqKw== X-Received: by 10.223.156.145 with SMTP id d17mr2662445wre.1.1519211125987; Wed, 21 Feb 2018 03:05:25 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y1sm5858662wrh.80.2018.02.21.03.05.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 03:05:23 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 249143E01B5; Wed, 21 Feb 2018 11:05:23 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 21 Feb 2018 11:05:01 +0000 Message-Id: <20180221110523.859-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180221110523.859-1-alex.bennee@linaro.org> References: <20180221110523.859-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::241 Subject: [Qemu-devel] [PULL 01/22] fpu/softfloat: implement float16_squash_input_denormal 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: =?utf-8?q?Alex_Benn=C3=A9e?= , 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 Reviewed-by: Richard Henderson Reviewed-by: Peter Maydell -- 2.15.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 433c5dad2d..3a4ab1355f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3488,6 +3488,21 @@ static float16 roundAndPackFloat16(flag zSign, int zExp, return packFloat16(zSign, zExp, zSig >> 13); } +/*---------------------------------------------------------------------------- +| If `a' is denormal and we are in flush-to-zero mode then set the +| input-denormal exception and return zero. Otherwise just return the value. +*----------------------------------------------------------------------------*/ +float16 float16_squash_input_denormal(float16 a, float_status *status) +{ + if (status->flush_inputs_to_zero) { + if (extractFloat16Exp(a) == 0 && extractFloat16Frac(a) != 0) { + float_raise(float_flag_input_denormal, status); + return make_float16(float16_val(a) & 0x8000); + } + } + return a; +} + static void normalizeFloat16Subnormal(uint32_t aSig, int *zExpPtr, uint32_t *zSigPtr) { diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 0f96a0edd1..d5e99667b6 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -277,6 +277,7 @@ void float_raise(uint8_t flags, float_status *status); | If `a' is denormal and we are in flush-to-zero mode then set the | input-denormal exception and return zero. Otherwise just return the value. *----------------------------------------------------------------------------*/ +float16 float16_squash_input_denormal(float16 a, float_status *status); float32 float32_squash_input_denormal(float32 a, float_status *status); float64 float64_squash_input_denormal(float64 a, float_status *status);