From patchwork Fri Oct 13 16:24:14 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: 825582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="RLPZZY0c"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yDCqN4n21z9sxR for ; Sat, 14 Oct 2017 03:29:51 +1100 (AEDT) Received: from localhost ([::1]:51042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32qK-0006LJ-NL for incoming@patchwork.ozlabs.org; Fri, 13 Oct 2017 12:29:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32lU-0002Qq-8J for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e32lT-0006Wp-6u for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:48 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:53996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e32lS-0006VQ-RZ for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:46 -0400 Received: by mail-wr0-x22e.google.com with SMTP id y44so1424697wry.10 for ; Fri, 13 Oct 2017 09:24:46 -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=/ILSMgJPmHL8NTcJ6LKg/3Dh7htBXoyvVG+Xzv5BpWM=; b=RLPZZY0cNtkqpNTUREEa1RZ8I4sYgOmXXuMZrRYWPrM4WxK+Er2+tBXcjSPiieHXTl Qi4Qu6JK5GC/iYPcZoO7lgQbuZzDRjnFZu0jCrjMYg6XW+nQs62QdsHoiMmeEChZehkY ctL4wCXEuBlWeC+Bam+Y4k+Jy/gpxx74eViIA= 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=/ILSMgJPmHL8NTcJ6LKg/3Dh7htBXoyvVG+Xzv5BpWM=; b=p6slkQtVCFWMZHOqODnhATBOa2ylE/72T9qmzUyD/O8wmj4p3WkXQkByKow4o0uP6W jZEc+orowABQILOIA/1uDBGgXq4A4aN29HLgERp+0yw8Iv+0sAsgGlvg0M7u72ecYXua EK+QAeh8RlEGtNNixjdkqt8ZOAQ45VZwacEnXpdVwTkYtrrxhsuCppdUygHfB+j0C6bu 67JLe/N5rMQCV9yFzlaa8V7Ey1DXWFcVD/e8zkkyfi1+9yhFvL9yuuH3Z+f/tvIZtspS RSSrBNx1mebMnWeTqGex2r99FsjRBOwwzYVMODDNtnAOjTTRLnspZLwL41Nni/AyCKh9 y/Lg== X-Gm-Message-State: AMCzsaUqN+CP2kjVjaqQhdyIklfLg3U3xsQ4WtwGD9n9c2kAlKKzcsaw hobgh05mw2bJlZzq0UOwHlS6gQ== X-Google-Smtp-Source: AOwi7QAcSTGMPGxi/Lw5yRBCFPKOK4B89G/TG5E2IOxQSKJ0L7L6NyDNvuO7kldLs8tZN4xo8KQebQ== X-Received: by 10.223.169.33 with SMTP id u30mr1820536wrc.205.1507911885779; Fri, 13 Oct 2017 09:24:45 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e132sm1404279wmd.42.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 D243C3E0756; 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:14 +0100 Message-Id: <20171013162438.32458-7-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::22e Subject: [Qemu-devel] [RFC PATCH 06/30] 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: 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+incoming=patchwork.ozlabs.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 --- fpu/softfloat.c | 15 +++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 16 insertions(+) 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);