From patchwork Tue Jan 9 12:22:33 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: 123905 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3958631qgn; Tue, 9 Jan 2018 04:26:01 -0800 (PST) X-Google-Smtp-Source: ACJfBosDgt3ShvAcygBqUQ4EluoPo9wTk13Fl5izhAS28hf+1zc96trCC4ABvO9I4vIrTcTFgEfg X-Received: by 10.37.232.1 with SMTP id k1mr14175816ybd.178.1515500761854; Tue, 09 Jan 2018 04:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515500761; cv=none; d=google.com; s=arc-20160816; b=CBx0W5eumsx9JQkEWOhtPhphlBNMH/kwzx/PeMXKPVTgJiGnsc9UHKCw/0WUkXiZfv nNFwUOXZAxj5DfaOVG9Aq3rrkbxcEUtMCYkab7QDpauXYIO5MyJH6eHy+2DJgb0hnbfs 4BwPANLgqtVIQJr6FJTu3AI98eFo1Ta5KkIPh95S6fAF7Vu/1yGjaEtayLFxp0ZOHtu3 i5+TKMbXUTTDNMWB7JpRYTnb1WBELFYfoQ/OffGmEQ0AbEDAttHC8bQsaNydkZ8WQgsm I/jxpgWWiEr2uy71LILvhjV9/OVIM9cP3kIVcLfHy9MqzkXV1lD4RgcTDypMO2mr9xsu wVIw== 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=kFWWImcJFakK6Q/MS9IUPme+eMbtlWRk0/W9mj8nEvI=; b=SGgM0AnabDZmyDt4Q/muZLnjTCMU8IgO6bgHvYVvcZPd7bnssJ3nf/PYxgDytakk4V h+X9j1AIMDRVCFKMAuMWDWxjKGHk2mK8Tm3rqUyfRe0FOaiWJFUMJsvcmuIZYC2MTUxr 8JT9vrOR9UMkBqpHEINkauuYNFx0oR+hmMW+R8fEJdz/Rr6IkxKovUjxQo2Wo9Db8YX8 Y805iG34ZCqgmrfs8MhbRqDEgXH2kpHMcmNhYtZgfAmy0/KLVNzSjPl06KwGNWmQ/A3x xQ1+EuQn3PB0WEvgHbHCz27kE7b3WtBM/ynDhZCTxUY3XZC5x//Ue+XbSMDzdk2VOTjv XbvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LSBeNzBF; 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 p190si3035081ybg.723.2018.01.09.04.26.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 09 Jan 2018 04:26:01 -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=LSBeNzBF; 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]:49475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYsyf-0000Oq-Be for patch@linaro.org; Tue, 09 Jan 2018 07:26:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYsvj-0006ZE-TC for qemu-devel@nongnu.org; Tue, 09 Jan 2018 07:23:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYsvf-0006DC-RR for qemu-devel@nongnu.org; Tue, 09 Jan 2018 07:22:59 -0500 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:41542) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eYsvf-0006B4-Kc for qemu-devel@nongnu.org; Tue, 09 Jan 2018 07:22:55 -0500 Received: by mail-wm0-x242.google.com with SMTP id g75so20185512wme.0 for ; Tue, 09 Jan 2018 04:22:55 -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=kFWWImcJFakK6Q/MS9IUPme+eMbtlWRk0/W9mj8nEvI=; b=LSBeNzBFSMOkvg+uBD+QTIrE9f9f2kW1EviQ25+C134s6EBN/gZCNcoAse18rUqK8J nhzZ7l1H4XOhlB5z+uXOHesV6NQgJ90PHCOjNPLiEgroUBz4UVjYyFhQAW+uREAebxKX 5qv7NbXQ4IrY8pAHGGGOp4LNlEi/8rrA/9Bvg= 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=kFWWImcJFakK6Q/MS9IUPme+eMbtlWRk0/W9mj8nEvI=; b=f6RedqFVzPc8ucvwp6pyMuykm0iBhq+mQC9Wkm1fkYM7lCHij5w4V5/eYnjKSRlnqD V9yqlqVCT0Ue/d8darRu4V8pSgPPVis27AwTGN+Yt2d7GTca8ND8EGA1KB6BWkQ+9/ok Mjcz881eiwr6JdJ2LZfkquNVJcpucfJNHKtROhTAJe1PHLF7UotJjKCLFZne4EcCIi2L nXHZo/WaGOa9JO1V6L57caaVp+gvK4V3vyI3gRNl2zeAue23LwtHl2M2fzbAhBD80l/P AlvE2KUm4ZoelMhW0/7bKz7zNtAPMOlYzN7qD+jIUkWKOQxfhnu7++i0DP+JG8Tz9yjN qEYg== X-Gm-Message-State: AKGB3mK7sRWN6D1rk4fEMP+kjD7Rjf2yVY4xOvRB3QG7VvhXuj8eeHnX Me2qsdDgRhXHtvaABP48o4gzAA== X-Received: by 10.28.16.211 with SMTP id 202mr11602347wmq.49.1515500574330; Tue, 09 Jan 2018 04:22:54 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c19sm13595257wmd.5.2018.01.09.04.22.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 04:22:52 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 3DC173E02CB; Tue, 9 Jan 2018 12:22:52 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, bharata@linux.vnet.ibm.com, andrew@andrewdutcher.com Date: Tue, 9 Jan 2018 12:22:33 +0000 Message-Id: <20180109122252.17670-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180109122252.17670-1-alex.bennee@linaro.org> References: <20180109122252.17670-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::242 Subject: [Qemu-devel] [PATCH v2 01/20] 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 --- fpu/softfloat.c | 15 +++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 16 insertions(+) -- 2.15.1 Reviewed-by: Peter Maydell 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);