From patchwork Sun Feb 4 04:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126794 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp923322ljc; Sat, 3 Feb 2018 20:12:15 -0800 (PST) X-Google-Smtp-Source: AH8x225vYhFXKsrCJyOoKADLcFdJNi7krWfGzytPlpZqfsCFoxyNPHs7t9QpoUMcPF44+KB8X3C6 X-Received: by 10.37.113.8 with SMTP id m8mr29729374ybc.56.1517717535382; Sat, 03 Feb 2018 20:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517717535; cv=none; d=google.com; s=arc-20160816; b=DEZsU3uuS4RGlu4wtdHZAvfJ+DpZwn4rKOcBrPMlrRztdRCTkUUQSaebTRS77AYBl8 FVZtHhHldRJ8Ug44Xo2iAV6WteklE4DDhUadSsRY7kXFQGrKeWb+bQDmznhtlm5qYyiu 6/wxX2MEOlEwndAtFYu3uFvY/7UhEMkJGuTDNEwP26sqK6rLD4f08pl0Bc8doWp0rc0t z54+yQxxuop3BlesPURivxsW46Laeo7guefJdu9f8w4uegc15AwY+OAv/hSnQRyjLQzS I2T3GfwVNkpluU8TVNyH047WOCVAJQ1Ex4NWxEeIf551RMkf2kv2MB+5DKTUVgVoRsgD wGSw== 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=mChd7TEwq3ZdrA6gGr+Hje5KtLZ1BEWCJIdlh6JiFBM=; b=pUAK3x8kIgbdjxr4vLViak0DPEcuxkDtIJYrDH4AT/efv+sEAD6TQQRxiHl+8sFaKQ UL/1yY8StneUYz8bNZSqmrTM0kmY4NyT/3UPGJl2v/SkAEpR1Vds3QBsg3exG4Dn+A7F 7RSBdGJ0Hw9NdULWNQepRlPC8EK6ka8MdL5txwF8CSeB6mZCf7IFKivjMfd8xhBL6/FD 0mRyb6Y9GZeekyhdoWSyUY5qpSoMeNZSRsMcytzBlUayw4djDlVRt1UKvoau3c7Ryh6k vpxGMlYdd9hmAWIBeMKqxsJMq5K8/KNtEW1Oxc/K4vrpifclTMHD5sRkObnlIvncfN79 oDgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gb9Mo6Em; 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 d36si491109ybe.750.2018.02.03.20.12.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 03 Feb 2018 20:12:15 -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=gb9Mo6Em; 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]:58236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBf4-0004Vb-NV for patch@linaro.org; Sat, 03 Feb 2018 23:12:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBed-0004UD-1o for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:11:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiBeY-0004od-Vg for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:11:47 -0500 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:42782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiBeY-0004oV-Pt for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:11:42 -0500 Received: by mail-pf0-x244.google.com with SMTP id b25so19452745pfd.9 for ; Sat, 03 Feb 2018 20:11:42 -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=mChd7TEwq3ZdrA6gGr+Hje5KtLZ1BEWCJIdlh6JiFBM=; b=gb9Mo6EmmYrXEihtLOxQVULIiwo60nI7Hxrs5XGmYO3DDkrill0R1hFcBV0a1qi11s tBwciWvwKNwQJINp2g5igiHS0mSiFsKDCEd9Z0XBs5VWLFQLEVI5CGnUYlnJsb0xFNXS 4Q9202RKD4XVgPzOTziK+FLk9IWyG8YQSAzCI= 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=mChd7TEwq3ZdrA6gGr+Hje5KtLZ1BEWCJIdlh6JiFBM=; b=FX+IPX+cKPN1F5fMCUSmKFxie4w4dudzkXJJca4G5L0rUdxSJf/tsQPF7D+pLMzR1y UcTafgztmGGMbufGiex5R15uUfVX4j+eZ/mEdCZ5r542s1HpboaWhKpauLFtrD8wgEfz DVQNvxRlyYC1o6sKrnZiGDVvY36FZFJX7S4IM4humu39NWy8EX589d6YvTYG8K3fGCw0 BADTl1lp4XoXQpvm4+7Ox8uJ8Jpz/Tz52sUcKbnptJphtzNFkS9kBpZjGPUJuaCuthU8 mrQlg8f0FQu7BzSzzQc9BBs2DGpWj//GB5aldKqwM10bgVBWNKV88J4hnkJwrkYdTN30 0jxQ== X-Gm-Message-State: AKwxytcf3ly5ragMELBvI8DyJc9AahNVnmEojyaPjcR6H434lhehNHup 33FmhxhfRyjLsceU6qJKLX2NjaRTC88= X-Received: by 10.98.31.131 with SMTP id l3mr45360146pfj.116.1517717501378; Sat, 03 Feb 2018 20:11:41 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id k3sm1399425pgr.12.2018.02.03.20.11.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Feb 2018 20:11:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Feb 2018 20:11:13 -0800 Message-Id: <20180204041136.17525-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180204041136.17525-1-richard.henderson@linaro.org> References: <20180204041136.17525-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH 01/24] 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, cota@braap.org, alex.bennee@linaro.org, hsp.cat7@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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 --- include/fpu/softfloat.h | 1 + fpu/softfloat.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) -- 2.14.3 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); 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) {