From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486111657456.6803692391469; Wed, 16 May 2018 08:55:11 -0700 (PDT) Received: from localhost ([::1]:52992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIylf-0005W3-JZ for importer@patchew.org; Wed, 16 May 2018 11:55:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjT-0004DR-G3 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjR-0004z1-3l for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:51 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:37526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjQ-0004yZ-V9 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:49 -0400 Received: by mail-pf0-x242.google.com with SMTP id e9-v6so570980pfi.4 for ; Wed, 16 May 2018 08:52:48 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52: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=jDhX1u7/y5BhcUMp6xkxadIqpIgioPiIemVTRTRzYQI=; b=ADNI65T0aKuwQtlj8bzlSekCiuX+79HeGbZOYfDqL5she3ZwYM+92GDRumRWf5hISH 88zROVImcAP08RyWANytVPctaSyFEBwg/fuD42J92EoQbzzeCC0kvATD35wJfL0teEOo xZ0sj4Lj3fxLs3UbbsExXmZvxFVx4YoO4lq14= 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=jDhX1u7/y5BhcUMp6xkxadIqpIgioPiIemVTRTRzYQI=; b=pErn5T7RaGR9Mh4Wu/MRzfcTHbNEA5iYZhmFME9+KvZ1yf03RoO+k9HOwoUVH5tjH/ ZaJ5UMSGuibXkxpeQDx6YSXyw5blFPsbNma8q9lgA7rzqYo4c2PNvJzPkfykmymcaU70 7Qy0N5FZTlk9WSnlLR2PA1Qu0VXCOZxbincvm9smDUw/G8gSWDN9CVPGbxhHfDoOJOQq UhkdURjXBKMoBvYjUun2gVOaMHkg7hMSPTFvuJ/uvF8QRVKBOG6+1O7Yqc2QNO2ZnC+A Yq2JZUCbBRtdNF1WMKsIi/qq2BpQHvI+rXtHLBmILUHGfOocitEJlPkJo71CWxbXojcI ekIQ== X-Gm-Message-State: ALKqPwcrwE3JgYigySO47/nDCM1Ry8Lu9SVsYakuurguHVE5a0VODgea x7W8C5ky/kQ/xxEkjKBkPklwCaxRsS8= X-Google-Smtp-Source: AB8JxZoKpi8aFqyGrft4BY8hhA2ijrNbFvMao1rBbB8XYpI6qEG9FgQZJINZx6rrhmxe5+k5FPTpBQ== X-Received: by 2002:a65:4b8d:: with SMTP id t13-v6mr1163075pgq.53.1526485967571; Wed, 16 May 2018 08:52:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:16 -0700 Message-Id: <20180516155243.16937-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 01/28] fpu/softfloat: Fix conversion from uint64 to float128 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-stable@nongnu.org, Petr Tesarik Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Petr Tesarik The significand is passed to normalizeRoundAndPackFloat128() as high first, low second. The current code passes the integer first, so the result is incorrectly shifted left by 64 bits. This bug affects the emulation of s390x instruction CXLGBR (convert from logical 64-bit binary-integer operand to extended BFP result). Cc: qemu-stable@nongnu.org Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Petr Tesarik Message-Id: <20180511071052.1443-1-ptesarik@suse.com> Signed-off-by: Richard Henderson --- fpu/softfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index bc0f52fa54..d07419324a 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3147,7 +3147,7 @@ float128 uint64_to_float128(uint64_t a, float_status = *status) if (a =3D=3D 0) { return float128_zero; } - return normalizeRoundAndPackFloat128(0, 0x406E, a, 0, status); + return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status); } =20 =20 --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486112594223.74871776531302; Wed, 16 May 2018 08:55:12 -0700 (PDT) Received: from localhost ([::1]:52993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyli-0005YD-O2 for importer@patchew.org; Wed, 16 May 2018 11:55:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjU-0004Ds-9k for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjS-0004zP-Oo for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:52 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:37211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjS-0004zE-G6 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:50 -0400 Received: by mail-pg0-x242.google.com with SMTP id a13-v6so470525pgu.4 for ; Wed, 16 May 2018 08:52:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:47 -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=vUbiquEpPpv1Jwk4MPNGVRk9CWrHz238T8o7L7traPo=; b=XBjyuNtwYvVpOImn8Zo0lD0f0mKBasAo0UT8kFk1+27krC7/WxQB45K+2KJcxZ4dEI lCodXaq3hz98FI+ax+MEyi8SKMlKpL3ueAkZlRi+FJcFqIvS84bEfrW2b2guU1L2RvGT 4whUQ2WmrvSX5RG7lwQzQmO/8Zw7MlLqSTVA8= 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=vUbiquEpPpv1Jwk4MPNGVRk9CWrHz238T8o7L7traPo=; b=V54lM+1aheHTgUPGlWYBxXWXJsmrIM/uAsNLHOiOKn/OGNw37cRtZyiVqF/mnjt6Um hcBSDpVeaT8EjXoCkHI7kbaWTH7zcm62UhsnYsSmx7rIkg8f8qyToas4vUXncEcTUrI/ RQteyhsyeYSjetz2aWHUDpvyifTK/bK8SKcqXPSmVW0qFcUJri5d5OCcXl7OjBvq5UhZ RltNtzF92OxYgbd0h8yAj55pWZpCmVFwj0x0qKlEyghfA3ae/kw0zTX8TSgOM88Y6xOf u6WFcngbVPrzS20V2paccXiAt068fxvWeUp5Ne9K7sZCQHR5FR4WBICovSgSm8J6L3Co X8vg== X-Gm-Message-State: ALKqPwd3VPWBGBC1lWHc+C91w7zb0YONnP25m3hGMa8mkJlkTQWWCeR/ /FwEzvcJA09SZ24HXlNneUDO9lsVoQI= X-Google-Smtp-Source: AB8JxZp8qLBzY2eoyR+S3lRjf7sECaUMEPXH0F7lBFlmhp5bgKrsmQkBITfdgFIU9OA3uamzNcVthg== X-Received: by 2002:a62:991:: with SMTP id 17-v6mr1532338pfj.34.1526485968983; Wed, 16 May 2018 08:52:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:17 -0700 Message-Id: <20180516155243.16937-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PULL 02/28] fpu/softfloat: Merge NO_SIGNALING_NANS definitions 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Move the ifdef inside the relevant functions instead of duplicating the function declarations. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 100 +++++++++++++++---------------------- 1 file changed, 40 insertions(+), 60 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 27834af0de..58b05718c8 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -233,17 +233,6 @@ typedef struct { uint64_t high, low; } commonNaNT; =20 -#ifdef NO_SIGNALING_NANS -int float16_is_quiet_nan(float16 a_, float_status *status) -{ - return float16_is_any_nan(a_); -} - -int float16_is_signaling_nan(float16 a_, float_status *status) -{ - return 0; -} -#else /*------------------------------------------------------------------------= ---- | Returns 1 if the half-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -251,12 +240,16 @@ int float16_is_signaling_nan(float16 a_, float_status= *status) =20 int float16_is_quiet_nan(float16 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float16_is_any_nan(a_); +#else uint16_t a =3D float16_val(a_); if (status->snan_bit_is_one) { return (((a >> 9) & 0x3F) =3D=3D 0x3E) && (a & 0x1FF); } else { return ((a & ~0x8000) >=3D 0x7C80); } +#endif } =20 /*------------------------------------------------------------------------= ---- @@ -266,14 +259,17 @@ int float16_is_quiet_nan(float16 a_, float_status *st= atus) =20 int float16_is_signaling_nan(float16 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else uint16_t a =3D float16_val(a_); if (status->snan_bit_is_one) { return ((a & ~0x8000) >=3D 0x7C80); } else { return (((a >> 9) & 0x3F) =3D=3D 0x3E) && (a & 0x1FF); } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the half-precision floating point value `a' is a @@ -333,17 +329,6 @@ static float16 commonNaNToFloat16(commonNaNT a, float_= status *status) } } =20 -#ifdef NO_SIGNALING_NANS -int float32_is_quiet_nan(float32 a_, float_status *status) -{ - return float32_is_any_nan(a_); -} - -int float32_is_signaling_nan(float32 a_, float_status *status) -{ - return 0; -} -#else /*------------------------------------------------------------------------= ---- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -351,12 +336,16 @@ int float32_is_signaling_nan(float32 a_, float_status= *status) =20 int float32_is_quiet_nan(float32 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float32_is_any_nan(a_); +#else uint32_t a =3D float32_val(a_); if (status->snan_bit_is_one) { return (((a >> 22) & 0x1FF) =3D=3D 0x1FE) && (a & 0x003FFFFF); } else { return ((uint32_t)(a << 1) >=3D 0xFF800000); } +#endif } =20 /*------------------------------------------------------------------------= ---- @@ -366,14 +355,17 @@ int float32_is_quiet_nan(float32 a_, float_status *st= atus) =20 int float32_is_signaling_nan(float32 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else uint32_t a =3D float32_val(a_); if (status->snan_bit_is_one) { return ((uint32_t)(a << 1) >=3D 0xFF800000); } else { return (((a >> 22) & 0x1FF) =3D=3D 0x1FE) && (a & 0x003FFFFF); } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the single-precision floating point value `a' is a @@ -744,17 +736,6 @@ static float32 propagateFloat32NaN(float32 a, float32 = b, float_status *status) } } =20 -#ifdef NO_SIGNALING_NANS -int float64_is_quiet_nan(float64 a_, float_status *status) -{ - return float64_is_any_nan(a_); -} - -int float64_is_signaling_nan(float64 a_, float_status *status) -{ - return 0; -} -#else /*------------------------------------------------------------------------= ---- | Returns 1 if the double-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -762,6 +743,9 @@ int float64_is_signaling_nan(float64 a_, float_status *= status) =20 int float64_is_quiet_nan(float64 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float64_is_any_nan(a_); +#else uint64_t a =3D float64_val(a_); if (status->snan_bit_is_one) { return (((a >> 51) & 0xFFF) =3D=3D 0xFFE) @@ -769,6 +753,7 @@ int float64_is_quiet_nan(float64 a_, float_status *stat= us) } else { return ((a << 1) >=3D 0xFFF0000000000000ULL); } +#endif } =20 /*------------------------------------------------------------------------= ---- @@ -778,6 +763,9 @@ int float64_is_quiet_nan(float64 a_, float_status *stat= us) =20 int float64_is_signaling_nan(float64 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else uint64_t a =3D float64_val(a_); if (status->snan_bit_is_one) { return ((a << 1) >=3D 0xFFF0000000000000ULL); @@ -785,8 +773,8 @@ int float64_is_signaling_nan(float64 a_, float_status *= status) return (((a >> 51) & 0xFFF) =3D=3D 0xFFE) && (a & LIT64(0x0007FFFFFFFFFFFF)); } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the double-precision floating point value `a' is a @@ -899,17 +887,6 @@ static float64 propagateFloat64NaN(float64 a, float64 = b, float_status *status) } } =20 -#ifdef NO_SIGNALING_NANS -int floatx80_is_quiet_nan(floatx80 a_, float_status *status) -{ - return floatx80_is_any_nan(a_); -} - -int floatx80_is_signaling_nan(floatx80 a_, float_status *status) -{ - return 0; -} -#else /*------------------------------------------------------------------------= ---- | Returns 1 if the extended double-precision floating-point value `a' is a | quiet NaN; otherwise returns 0. This slightly differs from the same @@ -918,6 +895,9 @@ int floatx80_is_signaling_nan(floatx80 a_, float_status= *status) =20 int floatx80_is_quiet_nan(floatx80 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return floatx80_is_any_nan(a); +#else if (status->snan_bit_is_one) { uint64_t aLow; =20 @@ -929,6 +909,7 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *sta= tus) return ((a.high & 0x7FFF) =3D=3D 0x7FFF) && (LIT64(0x8000000000000000) <=3D ((uint64_t)(a.low << 1))); } +#endif } =20 /*------------------------------------------------------------------------= ---- @@ -939,6 +920,9 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *sta= tus) =20 int floatx80_is_signaling_nan(floatx80 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else if (status->snan_bit_is_one) { return ((a.high & 0x7FFF) =3D=3D 0x7FFF) && ((a.low << 1) >=3D 0x8000000000000000ULL); @@ -950,8 +934,8 @@ int floatx80_is_signaling_nan(floatx80 a, float_status = *status) && (uint64_t)(aLow << 1) && (a.low =3D=3D aLow); } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the extended double-precision floating point value @@ -1060,17 +1044,6 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b= , float_status *status) } } =20 -#ifdef NO_SIGNALING_NANS -int float128_is_quiet_nan(float128 a_, float_status *status) -{ - return float128_is_any_nan(a_); -} - -int float128_is_signaling_nan(float128 a_, float_status *status) -{ - return 0; -} -#else /*------------------------------------------------------------------------= ---- | Returns 1 if the quadruple-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -1078,6 +1051,9 @@ int float128_is_signaling_nan(float128 a_, float_stat= us *status) =20 int float128_is_quiet_nan(float128 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float128_is_any_nan(a); +#else if (status->snan_bit_is_one) { return (((a.high >> 47) & 0xFFFF) =3D=3D 0xFFFE) && (a.low || (a.high & 0x00007FFFFFFFFFFFULL)); @@ -1085,6 +1061,7 @@ int float128_is_quiet_nan(float128 a, float_status *s= tatus) return ((a.high << 1) >=3D 0xFFFF000000000000ULL) && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL)); } +#endif } =20 /*------------------------------------------------------------------------= ---- @@ -1094,6 +1071,9 @@ int float128_is_quiet_nan(float128 a, float_status *s= tatus) =20 int float128_is_signaling_nan(float128 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else if (status->snan_bit_is_one) { return ((a.high << 1) >=3D 0xFFFF000000000000ULL) && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL)); @@ -1101,8 +1081,8 @@ int float128_is_signaling_nan(float128 a, float_statu= s *status) return (((a.high >> 47) & 0xFFFF) =3D=3D 0xFFFE) && (a.low || (a.high & LIT64(0x00007FFFFFFFFFFF))); } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the quadruple-precision floating point value `a' = is --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486366535160.83794975757155; Wed, 16 May 2018 08:59:26 -0700 (PDT) Received: from localhost ([::1]:53018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIypp-0000Tl-Ls for importer@patchew.org; Wed, 16 May 2018 11:59:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjV-0004EA-O6 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjU-000503-6T for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:53 -0400 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]:33232) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjT-0004zf-Tx for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:52 -0400 Received: by mail-pg0-x230.google.com with SMTP id v7-v6so491136pgs.0 for ; Wed, 16 May 2018 08:52:51 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:49 -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=aWGAG4VepTBKKjzXJ8krtoY3A2cSRVVZvpCgb6Q0Vj8=; b=Zzi4zAMCS6bGbwbX3T731+Zb4VySI90cDJhyHediPP5TMOmQexwaOak0AQlT4WxBDK +FYnHHNWfd32nkrV6yIQmQ8CE+uiCu4vPLlhY+TxlprTbpQwEexMGgYdA1gXRBZyYLJ7 5o6LcXFLC29f3WMaZLwbvMkrowJ8qVE/wkLCk= 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=aWGAG4VepTBKKjzXJ8krtoY3A2cSRVVZvpCgb6Q0Vj8=; b=K9OsCrZdCzglgLIZSYJdznjeJgTv330dQ6WIQnagLMTopsHsSb8TR+3coj6qVF9xN4 jObpm+7EH8r8e6sj4/PTSZ1OsjdlqZRkgYfwtmRl49PXbQADrrhJ9xdyvYlHsHmh9xNu vw1S/isK7uD6tx/605pWmppGn90FNXFD0wzL8PxxMESoQ94A4QSqf2HqYcG8curdUDlN LvyJ2fKcQdu/yefc8CSsvKC3D3H8koseBPn7jC3o7TOdeP2axUl8dToRkFYftKCXuwxl LKAHVZoXOdsiMf/Zwksd6Qk9tDJyrlBDFqe9eUboJs/6baQWtCmkmFi9kt4ezqDNPIgU zwkA== X-Gm-Message-State: ALKqPwcocgyU2P/VmEIOpq47Nc8aiiQ1fv5ynKMcS8kTR/oy8KN+ik1c CTonT1Y/mhK6oRPcWm74S3YgxZR/TfA= X-Google-Smtp-Source: AB8JxZpWfMuwnp1RDy337Zx7jegR3r7j7eXOImIflTxmAJIsu2yDU3O23skNEwXxt+GIJFYDbjHVUA== X-Received: by 2002:a62:4f0c:: with SMTP id d12-v6mr1489871pfb.220.1526485970333; Wed, 16 May 2018 08:52:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:18 -0700 Message-Id: <20180516155243.16937-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::230 Subject: [Qemu-devel] [PULL 03/28] fpu/softfloat: Split floatXX_silence_nan from floatXX_maybe_silence_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The new function assumes that the input is an SNaN and does not double-check. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 174 +++++++++++++++++++++++++------------ include/fpu/softfloat.h | 5 ++ 2 files changed, 123 insertions(+), 56 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 58b05718c8..4fc9ea4ac0 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -271,22 +271,35 @@ int float16_is_signaling_nan(float16 a_, float_status= *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the half-precision +| floating point value `a'. +*-------------------------------------------------------------------------= ---*/ + +float16 float16_silence_nan(float16 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { + return float16_default_nan(status); + } else { + return a | (1 << 9); + } +#endif +} + /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the half-precision floating point value `a' is a | signaling NaN; otherwise returns `a'. *-------------------------------------------------------------------------= ---*/ -float16 float16_maybe_silence_nan(float16 a_, float_status *status) + +float16 float16_maybe_silence_nan(float16 a, float_status *status) { - if (float16_is_signaling_nan(a_, status)) { - if (status->snan_bit_is_one) { - return float16_default_nan(status); - } else { - uint16_t a =3D float16_val(a_); - a |=3D (1 << 9); - return make_float16(a); - } + if (float16_is_signaling_nan(a, status)) { + return float16_silence_nan(a, status); } - return a_; + return a; } =20 /*------------------------------------------------------------------------= ---- @@ -367,30 +380,40 @@ int float32_is_signaling_nan(float32 a_, float_status= *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the single-precision +| floating point value `a'. +*-------------------------------------------------------------------------= ---*/ + +float32 float32_silence_nan(float32 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { +# ifdef TARGET_HPPA + a &=3D ~0x00400000; + a |=3D 0x00200000; + return a; +# else + return float32_default_nan(status); +# endif + } else { + return a | (1 << 22); + } +#endif +} /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the single-precision floating point value `a' is a | signaling NaN; otherwise returns `a'. *-------------------------------------------------------------------------= ---*/ =20 -float32 float32_maybe_silence_nan(float32 a_, float_status *status) +float32 float32_maybe_silence_nan(float32 a, float_status *status) { - if (float32_is_signaling_nan(a_, status)) { - if (status->snan_bit_is_one) { -#ifdef TARGET_HPPA - uint32_t a =3D float32_val(a_); - a &=3D ~0x00400000; - a |=3D 0x00200000; - return make_float32(a); -#else - return float32_default_nan(status); -#endif - } else { - uint32_t a =3D float32_val(a_); - a |=3D (1 << 22); - return make_float32(a); - } + if (float32_is_signaling_nan(a, status)) { + return float32_silence_nan(a, status); } - return a_; + return a; } =20 /*------------------------------------------------------------------------= ---- @@ -776,30 +799,41 @@ int float64_is_signaling_nan(float64 a_, float_status= *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the double-precision +| floating point value `a'. +*-------------------------------------------------------------------------= ---*/ + +float64 float64_silence_nan(float64 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { +# ifdef TARGET_HPPA + a &=3D ~0x0008000000000000ULL; + a |=3D 0x0004000000000000ULL; + return a; +# else + return float64_default_nan(status); +# endif + } else { + return a | LIT64(0x0008000000000000); + } +#endif +} + /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the double-precision floating point value `a' is a | signaling NaN; otherwise returns `a'. *-------------------------------------------------------------------------= ---*/ =20 -float64 float64_maybe_silence_nan(float64 a_, float_status *status) +float64 float64_maybe_silence_nan(float64 a, float_status *status) { - if (float64_is_signaling_nan(a_, status)) { - if (status->snan_bit_is_one) { -#ifdef TARGET_HPPA - uint64_t a =3D float64_val(a_); - a &=3D ~0x0008000000000000ULL; - a |=3D 0x0004000000000000ULL; - return make_float64(a); -#else - return float64_default_nan(status); -#endif - } else { - uint64_t a =3D float64_val(a_); - a |=3D LIT64(0x0008000000000000); - return make_float64(a); - } + if (float64_is_signaling_nan(a, status)) { + return float64_silence_nan(a, status); } - return a_; + return a; } =20 /*------------------------------------------------------------------------= ---- @@ -937,6 +971,25 @@ int floatx80_is_signaling_nan(floatx80 a, float_status= *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the extended double-precis= ion +| floating point value `a'. +*-------------------------------------------------------------------------= ---*/ + +floatx80 floatx80_silence_nan(floatx80 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { + return floatx80_default_nan(status); + } else { + a.low |=3D LIT64(0xC000000000000000); + return a; + } +#endif +} + /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the extended double-precision floating point value | `a' is a signaling NaN; otherwise returns `a'. @@ -945,12 +998,7 @@ int floatx80_is_signaling_nan(floatx80 a, float_status= *status) floatx80 floatx80_maybe_silence_nan(floatx80 a, float_status *status) { if (floatx80_is_signaling_nan(a, status)) { - if (status->snan_bit_is_one) { - a =3D floatx80_default_nan(status); - } else { - a.low |=3D LIT64(0xC000000000000000); - return a; - } + return floatx80_silence_nan(a, status); } return a; } @@ -1084,6 +1132,25 @@ int float128_is_signaling_nan(float128 a, float_stat= us *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the quadruple-precision +| floating point value `a'. +*-------------------------------------------------------------------------= ---*/ + +float128 float128_silence_nan(float128 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { + return float128_default_nan(status); + } else { + a.high |=3D LIT64(0x0000800000000000); + return a; + } +#endif +} + /*------------------------------------------------------------------------= ---- | Returns a quiet NaN if the quadruple-precision floating point value `a' = is | a signaling NaN; otherwise returns `a'. @@ -1092,12 +1159,7 @@ int float128_is_signaling_nan(float128 a, float_stat= us *status) float128 float128_maybe_silence_nan(float128 a, float_status *status) { if (float128_is_signaling_nan(a, status)) { - if (status->snan_bit_is_one) { - a =3D float128_default_nan(status); - } else { - a.high |=3D LIT64(0x0000800000000000); - return a; - } + return float128_silence_nan(a, status); } return a; } diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 36626a501b..43962dc3f5 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -257,6 +257,7 @@ int float16_compare_quiet(float16, float16, float_statu= s *status); =20 int float16_is_quiet_nan(float16, float_status *status); int float16_is_signaling_nan(float16, float_status *status); +float16 float16_silence_nan(float16, float_status *status); float16 float16_maybe_silence_nan(float16, float_status *status); =20 static inline int float16_is_any_nan(float16 a) @@ -368,6 +369,7 @@ float32 float32_minnummag(float32, float32, float_statu= s *status); float32 float32_maxnummag(float32, float32, float_status *status); int float32_is_quiet_nan(float32, float_status *status); int float32_is_signaling_nan(float32, float_status *status); +float32 float32_silence_nan(float32, float_status *status); float32 float32_maybe_silence_nan(float32, float_status *status); float32 float32_scalbn(float32, int, float_status *status); =20 @@ -497,6 +499,7 @@ float64 float64_minnummag(float64, float64, float_statu= s *status); float64 float64_maxnummag(float64, float64, float_status *status); int float64_is_quiet_nan(float64 a, float_status *status); int float64_is_signaling_nan(float64, float_status *status); +float64 float64_silence_nan(float64, float_status *status); float64 float64_maybe_silence_nan(float64, float_status *status); float64 float64_scalbn(float64, int, float_status *status); =20 @@ -600,6 +603,7 @@ int floatx80_compare(floatx80, floatx80, float_status *= status); int floatx80_compare_quiet(floatx80, floatx80, float_status *status); int floatx80_is_quiet_nan(floatx80, float_status *status); int floatx80_is_signaling_nan(floatx80, float_status *status); +floatx80 floatx80_silence_nan(floatx80, float_status *status); floatx80 floatx80_maybe_silence_nan(floatx80, float_status *status); floatx80 floatx80_scalbn(floatx80, int, float_status *status); =20 @@ -811,6 +815,7 @@ int float128_compare(float128, float128, float_status *= status); int float128_compare_quiet(float128, float128, float_status *status); int float128_is_quiet_nan(float128, float_status *status); int float128_is_signaling_nan(float128, float_status *status); +float128 float128_silence_nan(float128, float_status *status); float128 float128_maybe_silence_nan(float128, float_status *status); float128 float128_scalbn(float128, int, float_status *status); =20 --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486492230873.0139441778343; Wed, 16 May 2018 09:01:32 -0700 (PDT) Received: from localhost ([::1]:53059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyrh-00023G-Gy for importer@patchew.org; Wed, 16 May 2018 12:01:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjb-0004II-29 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjV-00050X-Cb for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:59 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39673) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjV-00050K-6R for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:53 -0400 Received: by mail-pg0-x244.google.com with SMTP id e1-v6so468848pga.6 for ; Wed, 16 May 2018 08:52:53 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:50 -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=X0O0oscg2DXfZxWsZs+cPbi2oDfigSQN1qMljqBQmYE=; b=OTO4YGvAbBxE/XUUdMgeAorHczs/uvLYI+4I2m1pFT2QWbhwgXLAbYFnLmG0x/mwxt +9Hp0jK1ktvGxPu+xkUl0RWzr50DbA92QdhMIT8iAL5SKvb7sou91QnI2PwULrqcVg3D 7U6o1YQxDDSKaSoZBZReAADIu/9Hitm7wvQ/c= 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=X0O0oscg2DXfZxWsZs+cPbi2oDfigSQN1qMljqBQmYE=; b=KH2xaqK9Mqr6DatSAbi+HT5aG0M9I6J7ZLlyioMa5Vk8BLI79QFT1L4hN41dDn9y8j 8zpQBZ7uRkLSNPfL3d1xH8evrWaND0WWf6nFHGUaKVMy3Vv6x+KUDP0ON/AV9+9wUhjq A3k8VpSccE84DgF5N1UTxZHw9Z8tFQgOjk6MoxWbCjFphIDUmFNTk/Yr5WXronr7B5iu YaPXO+0qOH0hckc+0ApmDmFcim5bFih35wWkNEfoLgzIovhpAn5/7MDMUHoCjCA0Tvcb OYGSqK7NfWKEwpuUIQBTSWVLK228dLYQohMlYoE+1YvUvFPjfLoyQBkB6M59gwaXe4g6 qM+A== X-Gm-Message-State: ALKqPwcv8+n4VH4CgXvGE9SWBCpoGnJRX7jt0cJTa8UplbfHd3+GgRtn XozrBR+key/KrNbO/D68XJE3YdWrWvI= X-Google-Smtp-Source: AB8JxZrSIJKjzZsc/HYuF/qM9/uvB/gBCWAobrTeNFRNZOIs6MMKXyC/8ZFF38ptnpRurGnLfvThIQ== X-Received: by 2002:a62:3f81:: with SMTP id z1-v6mr1502225pfj.216.1526485971768; Wed, 16 May 2018 08:52:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:19 -0700 Message-Id: <20180516155243.16937-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PULL 04/28] fpu/softfloat: Move softfloat-specialize.h below FloatParts definition 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 We want to be able to specialize on the canonical representation. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index d07419324a..0d17027379 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -95,16 +95,6 @@ this code that are retained. *-------------------------------------------------------------------------= ---*/ #include "fpu/softfloat-macros.h" =20 -/*------------------------------------------------------------------------= ---- -| Functions and definitions to determine: (1) whether tininess for underf= low -| is detected before or after rounding by default, (2) what (if anything) -| happens when exceptions are raised, (3) how signaling NaNs are distingui= shed -| from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs -| are propagated from function inputs to output. These details are target- -| specific. -*-------------------------------------------------------------------------= ---*/ -#include "softfloat-specialize.h" - /*------------------------------------------------------------------------= ---- | Returns the fraction bits of the half-precision floating-point value `a'. *-------------------------------------------------------------------------= ---*/ @@ -322,6 +312,16 @@ static inline float64 float64_pack_raw(FloatParts p) return make_float64(pack_raw(float64_params, p)); } =20 +/*------------------------------------------------------------------------= ---- +| Functions and definitions to determine: (1) whether tininess for underf= low +| is detected before or after rounding by default, (2) what (if anything) +| happens when exceptions are raised, (3) how signaling NaNs are distingui= shed +| from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs +| are propagated from function inputs to output. These details are target- +| specific. +*-------------------------------------------------------------------------= ---*/ +#include "softfloat-specialize.h" + /* Canonicalize EXP and FRAC, setting CLS. */ static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, float_status *status) --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486295666316.0520080037128; Wed, 16 May 2018 08:58:15 -0700 (PDT) Received: from localhost ([::1]:53016 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyog-0007yF-Iv for importer@patchew.org; Wed, 16 May 2018 11:58:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjX-0004EQ-IS for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjW-00051K-MZ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:55 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:40989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjW-00050u-Hu for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:54 -0400 Received: by mail-pf0-x241.google.com with SMTP id v63-v6so563115pfk.8 for ; Wed, 16 May 2018 08:52:54 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:52 -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=/xl8f2zQlEINP9lneuf7ucQwkBVVFUmq+tNHsXqCle4=; b=X5MWqfYRq3lyYNEvIkPJQyygoChOnQSLzWXGX5Cqyiyl65HpkbWBti7D8CopmhgtLR sZPsVsYOHM43jpRVWk0PaFkA+MOYEHv0Gt5UJBvXb6Pt3CIifzBoxWvLzBzcY2qDg/2S FOq2hkcgzP+XYCiJdNnOKdfthjkUsaEViGr/4= 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=/xl8f2zQlEINP9lneuf7ucQwkBVVFUmq+tNHsXqCle4=; b=k7eFINcU4/zM4WLO/SxcfktXXLAQQYIkUwmwsX9Hl50vt2nLI+BpeCxObE+rUC/QiH +dtEn7uAfEHstBERSQH9v/Fgve/5g7+f4TST6FxZh+rC41NyymevQNCtbX3f07ZWq9nE kD1ZP5OFJ8cO8PC7rkjJ80O9st3Ps1B59wI2ZkX1yDV9jt5+aDPBRnsoPyG2hwZER3RU KS2eUM4LID8cBHAD7La6GKUlauoIZjOk7W4kgQRW2Ik9R88lVLKKtQZPgeu4Bw0/WV7H odjnLFlm1j+S6A3d5aczPZwu2o+GNZrKs3MLv++e+h9hJTjAqAM/wF3oOfq7J5W1zrxC Q6Rw== X-Gm-Message-State: ALKqPwdehvOEnTwoR2KuzNBm6Se5YJh3jINhMrwMdrlTfURV1BqrY2VQ aNDgKuiImEQKXsj5VrF+JzKDU0/eN4M= X-Google-Smtp-Source: AB8JxZrUSD0fZTmyRKXbSUNDfUnLxAduPI9YvYzQHQiaMtSg7f1bU4LmfKmmJH7Wn6WSZzx1RkabVg== X-Received: by 2002:a62:4c53:: with SMTP id z80-v6mr1484056pfa.181.1526485973237; Wed, 16 May 2018 08:52:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:20 -0700 Message-Id: <20180516155243.16937-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PULL 05/28] fpu/softfloat: Canonicalize NaN fraction 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Shift the NaN fraction to a canonical position, much like we do for the fraction of normal numbers. This will facilitate manipulation of NaNs within the shared code paths. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 0d17027379..607c4a78d5 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -330,10 +330,11 @@ static FloatParts canonicalize(FloatParts part, const= FloatFmt *parm, if (part.frac =3D=3D 0) { part.cls =3D float_class_inf; } else { + part.frac <<=3D parm->frac_shift; #ifdef NO_SIGNALING_NANS part.cls =3D float_class_qnan; #else - int64_t msb =3D part.frac << (parm->frac_shift + 2); + int64_t msb =3D part.frac << 2; if ((msb < 0) =3D=3D status->snan_bit_is_one) { part.cls =3D float_class_snan; } else { @@ -480,6 +481,7 @@ static FloatParts round_canonical(FloatParts p, float_s= tatus *s, case float_class_qnan: case float_class_snan: exp =3D exp_max; + frac >>=3D parm->frac_shift; break; =20 default: @@ -503,6 +505,7 @@ static float16 float16_round_pack_canonical(FloatParts = p, float_status *s) case float_class_dnan: return float16_default_nan(s); case float_class_msnan: + p.frac >>=3D float16_params.frac_shift; return float16_maybe_silence_nan(float16_pack_raw(p), s); default: p =3D round_canonical(p, s, &float16_params); @@ -521,6 +524,7 @@ static float32 float32_round_pack_canonical(FloatParts = p, float_status *s) case float_class_dnan: return float32_default_nan(s); case float_class_msnan: + p.frac >>=3D float32_params.frac_shift; return float32_maybe_silence_nan(float32_pack_raw(p), s); default: p =3D round_canonical(p, s, &float32_params); @@ -539,6 +543,7 @@ static float64 float64_round_pack_canonical(FloatParts = p, float_status *s) case float_class_dnan: return float64_default_nan(s); case float_class_msnan: + p.frac >>=3D float64_params.frac_shift; return float64_maybe_silence_nan(float64_pack_raw(p), s); default: p =3D round_canonical(p, s, &float64_params); --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486590694414.5306718505792; Wed, 16 May 2018 09:03:10 -0700 (PDT) Received: from localhost ([::1]:53067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIytR-0003Ek-VA for importer@patchew.org; Wed, 16 May 2018 12:03:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjZ-0004GY-Gf for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjY-00051x-Lt for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:57 -0400 Received: from mail-pl0-x22f.google.com ([2607:f8b0:400e:c01::22f]:46633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjY-00051g-GQ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:56 -0400 Received: by mail-pl0-x22f.google.com with SMTP id 30-v6so658864pld.13 for ; Wed, 16 May 2018 08:52:56 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52: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=LQoF9e5L3ALMayOgvkerESyi2UVKdvRwamrm6aU1hPU=; b=QM4Qg8bXWNTgm4uQ5fsbDrbrATrAiqUVLWRxsAwQG+vHxB/ivBccUENHeg2NNrSH5r JNhcN7EXK0SmDLLpyCq8kgcfLi5ukH9vbVb2tosHO/A5GR5SfVhE78YO/S0DG3/KFvV2 ZbaJVrVbHiRBriWIe/QIc0mKIfz+oD8b4mMv4= 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=LQoF9e5L3ALMayOgvkerESyi2UVKdvRwamrm6aU1hPU=; b=EB50sOsXqCpHzfAlsGMv3sgoiO+SL6a3PDWpcIANblp63qWhTaqIJElqJHGMuQpugI +qGrvSr4tLrS+cjBSyV6j3ZBquv7BxZWUnDgu2HBoWXYRkt0qwLX6RBH/nw4H0hW5v8k vqzFqgpW4k5U/yy/Mx1FGGsiLtyzvGCZwb/un1F5ZVnVbG/d1UfsHK27rCpgjkv1eWJf X9aQUrO6EOZWVZFC0khywZa6FW1kJivIhLmo8rGz4MiYF9eeMNh4HdLOtAmcrHkpH5QF bAzopUd/puFYtVv+LCJvDjD1omCKBVOiFizwtWhc7oqKcX59Kk6ODN6yimtPM1kNEVMb 5m5A== X-Gm-Message-State: ALKqPwdY+cFrGmTse7FnLrV7ZNMPFVKJVrsnanMacVKEGyTPSRHrHjYL k3F4HxZzV2W1D2RAlRJZxMBLAQFsIh8= X-Google-Smtp-Source: AB8JxZpVQRQxW+0LDstFdGg9uTK2YzRknDI4UNXiwfo0h8fawIQXcKaC9KcKnp8eLiqWvAS10+Nm9A== X-Received: by 2002:a17:902:aa94:: with SMTP id d20-v6mr1475103plr.323.1526485975043; Wed, 16 May 2018 08:52:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:21 -0700 Message-Id: <20180516155243.16937-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22f Subject: [Qemu-devel] [PULL 06/28] fpu/softfloat: Introduce parts_is_snan_frac 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 15 +++++++++++++++ fpu/softfloat.c | 12 ++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 4fc9ea4ac0..515cb12cfa 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -86,6 +86,21 @@ this code that are retained. #define NO_SIGNALING_NANS 1 #endif =20 +/*------------------------------------------------------------------------= ---- +| For the deconstructed floating-point with fraction FRAC, return true +| if the fraction represents a signalling NaN; otherwise false. +*-------------------------------------------------------------------------= ---*/ + +static bool parts_is_snan_frac(uint64_t frac, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + return false; +#else + flag msb =3D extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1); + return msb =3D=3D status->snan_bit_is_one; +#endif +} + /*------------------------------------------------------------------------= ---- | The pattern for a default generated half-precision NaN. *-------------------------------------------------------------------------= ---*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 607c4a78d5..19f40d6932 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -331,16 +331,8 @@ static FloatParts canonicalize(FloatParts part, const = FloatFmt *parm, part.cls =3D float_class_inf; } else { part.frac <<=3D parm->frac_shift; -#ifdef NO_SIGNALING_NANS - part.cls =3D float_class_qnan; -#else - int64_t msb =3D part.frac << 2; - if ((msb < 0) =3D=3D status->snan_bit_is_one) { - part.cls =3D float_class_snan; - } else { - part.cls =3D float_class_qnan; - } -#endif + part.cls =3D (parts_is_snan_frac(part.frac, status) + ? float_class_snan : float_class_qnan); } } else if (part.exp =3D=3D 0) { if (likely(part.frac =3D=3D 0)) { --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486817303103.96933282436896; Wed, 16 May 2018 09:06:57 -0700 (PDT) Received: from localhost ([::1]:53110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIywx-00069i-HL for importer@patchew.org; Wed, 16 May 2018 12:06:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjc-0004Kb-Sc for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyja-00052S-4P for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:00 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:33215) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjZ-00052C-TF for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:58 -0400 Received: by mail-pg0-x243.google.com with SMTP id v7-v6so491264pgs.0 for ; Wed, 16 May 2018 08:52:57 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:55 -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=lJnCZDN0PRg9xnf5HrS6QJvF08nF0qG9pJRnCl2JME0=; b=F3/x8SmQmND6YkT7Y+fqSeIDby4vGRFJmLb6bjcqSVeYXMRrZHIFTWpsb1wf1aJE0t GnhOixFwiIU75M0zD5du000tTqqxBbTneb8ovzxfXa1F9CMh2v3OSVrSt4j4ZjK3+38n DJVF3SzqFivz5oqoK0rtflmKUn4pzvTwam838= 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=lJnCZDN0PRg9xnf5HrS6QJvF08nF0qG9pJRnCl2JME0=; b=F+AqGvN63BjsANL9ELgWcu1il9uIwVazJCI0UuQiswEfApGfuc0LJzCt57yVB4lwUm JAPjEMSbbDpKJFkJG/ugn6vyL6v9oALmZW9uklZ9DOrvcEuUR2tefzHeoyjf+Iu4LXV3 F8Oa/tq6YqWPn9jjHLIt6YhKvSqeY+YEvP+Jdrrgn/K+TBaUVd9RpdSPH5eyHYmx7Ayj xwHLi+T6ly+LEIHtO3WhF6dmNc4sWXDNYV7PAFvvbAKY3TlA2vgUAeJoFcU+uPxkTVuz cg5z880euessKbwgoGnHQvqiIGf21ueBdd2808+uaE06wPdI2tsxPiFMkeoAU8OZ6usn 5OXg== X-Gm-Message-State: ALKqPweGA3Km3ndJ1rJEQENPWgU+HwPwJphLUpkmXr5gMQkMYI2+PS6T 1OjZ048bDhjtZqTJBBHAhIFKRwdSISo= X-Google-Smtp-Source: AB8JxZqmCaV2DtvQk5zyhgfaih4DTrWiB4hf6yOIN1OcLyMbq7XZq2QtOrb52TWqJMa1OOJiAGgqsQ== X-Received: by 2002:a65:63c1:: with SMTP id n1-v6mr1098819pgv.399.1526485976406; Wed, 16 May 2018 08:52:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:22 -0700 Message-Id: <20180516155243.16937-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PULL 07/28] fpu/softfloat: Replace float_class_dnan with parts_default_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 With a canonical representation of NaNs, we can return the default nan directly rather than delay the expansion until the final format is known. Note one case where we uselessly assigned to a.sign, which was overwritten/ignored later when expanding float_class_dnan. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 37 +++++++++++++++++++++++++++++++++++++ fpu/softfloat.c | 38 +++++++++++--------------------------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 515cb12cfa..0d3d81a52b 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -101,6 +101,43 @@ static bool parts_is_snan_frac(uint64_t frac, float_st= atus *status) #endif } =20 +/*------------------------------------------------------------------------= ---- +| The pattern for a default generated deconstructed floating-point NaN. +*-------------------------------------------------------------------------= ---*/ + +static FloatParts parts_default_nan(float_status *status) +{ + bool sign =3D 0; + uint64_t frac; + +#if defined(TARGET_SPARC) || defined(TARGET_M68K) + frac =3D (1ULL << DECOMPOSED_BINARY_POINT) - 1; +#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) = || \ + defined(TARGET_S390X) || defined(TARGET_RISCV) + frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); +#elif defined(TARGET_HPPA) + frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#else + if (status->snan_bit_is_one) { + frac =3D (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; + } else { +#if defined(TARGET_MIPS) + frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); +#else + frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); + sign =3D 1; +#endif + } +#endif + + return (FloatParts) { + .cls =3D float_class_qnan, + .sign =3D sign, + .exp =3D INT_MAX, + .frac =3D frac + }; +} + /*------------------------------------------------------------------------= ---- | The pattern for a default generated half-precision NaN. *-------------------------------------------------------------------------= ---*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 19f40d6932..51780b718f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -188,7 +188,6 @@ typedef enum __attribute__ ((__packed__)) { float_class_inf, float_class_qnan, /* all NaNs from here */ float_class_snan, - float_class_dnan, float_class_msnan, /* maybe silenced */ } FloatClass; =20 @@ -494,8 +493,6 @@ static FloatParts float16_unpack_canonical(float16 f, f= loat_status *s) static float16 float16_round_pack_canonical(FloatParts p, float_status *s) { switch (p.cls) { - case float_class_dnan: - return float16_default_nan(s); case float_class_msnan: p.frac >>=3D float16_params.frac_shift; return float16_maybe_silence_nan(float16_pack_raw(p), s); @@ -513,8 +510,6 @@ static FloatParts float32_unpack_canonical(float32 f, f= loat_status *s) static float32 float32_round_pack_canonical(FloatParts p, float_status *s) { switch (p.cls) { - case float_class_dnan: - return float32_default_nan(s); case float_class_msnan: p.frac >>=3D float32_params.frac_shift; return float32_maybe_silence_nan(float32_pack_raw(p), s); @@ -532,8 +527,6 @@ static FloatParts float64_unpack_canonical(float64 f, f= loat_status *s) static float64 float64_round_pack_canonical(FloatParts p, float_status *s) { switch (p.cls) { - case float_class_dnan: - return float64_default_nan(s); case float_class_msnan: p.frac >>=3D float64_params.frac_shift; return float64_maybe_silence_nan(float64_pack_raw(p), s); @@ -566,7 +559,7 @@ static FloatParts return_nan(FloatParts a, float_status= *s) /* fall through */ case float_class_qnan: if (s->default_nan_mode) { - a.cls =3D float_class_dnan; + return parts_default_nan(s); } break; =20 @@ -583,7 +576,7 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, = float_status *s) } =20 if (s->default_nan_mode) { - a.cls =3D float_class_dnan; + return parts_default_nan(s); } else { if (pickNaN(is_qnan(a.cls), is_snan(a.cls), is_qnan(b.cls), is_snan(b.cls), @@ -614,8 +607,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatPa= rts b, FloatParts c, /* Note that this check is after pickNaNMulAdd so that function * has an opportunity to set the Invalid flag. */ - a.cls =3D float_class_dnan; - return a; + which =3D 3; } =20 switch (which) { @@ -628,8 +620,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatPa= rts b, FloatParts c, a =3D c; break; case 3: - a.cls =3D float_class_dnan; - return a; + return parts_default_nan(s); default: g_assert_not_reached(); } @@ -682,7 +673,7 @@ static FloatParts addsub_floats(FloatParts a, FloatPart= s b, bool subtract, if (a.cls =3D=3D float_class_inf) { if (b.cls =3D=3D float_class_inf) { float_raise(float_flag_invalid, s); - a.cls =3D float_class_dnan; + return parts_default_nan(s); } return a; } @@ -828,9 +819,7 @@ static FloatParts mul_floats(FloatParts a, FloatParts b= , float_status *s) if ((a.cls =3D=3D float_class_inf && b.cls =3D=3D float_class_zero) || (a.cls =3D=3D float_class_zero && b.cls =3D=3D float_class_inf)) { s->float_exception_flags |=3D float_flag_invalid; - a.cls =3D float_class_dnan; - a.sign =3D sign; - return a; + return parts_default_nan(s); } /* Multiply by 0 or Inf */ if (a.cls =3D=3D float_class_inf || a.cls =3D=3D float_class_zero) { @@ -908,8 +897,7 @@ static FloatParts muladd_floats(FloatParts a, FloatPart= s b, FloatParts c, =20 if (inf_zero) { s->float_exception_flags |=3D float_flag_invalid; - a.cls =3D float_class_dnan; - return a; + return parts_default_nan(s); } =20 if (flags & float_muladd_negate_c) { @@ -933,12 +921,12 @@ static FloatParts muladd_floats(FloatParts a, FloatPa= rts b, FloatParts c, if (c.cls =3D=3D float_class_inf) { if (p_class =3D=3D float_class_inf && p_sign !=3D c.sign) { s->float_exception_flags |=3D float_flag_invalid; - a.cls =3D float_class_dnan; + return parts_default_nan(s); } else { a.cls =3D float_class_inf; a.sign =3D c.sign ^ sign_flip; + return a; } - return a; } =20 if (p_class =3D=3D float_class_inf) { @@ -1148,8 +1136,7 @@ static FloatParts div_floats(FloatParts a, FloatParts= b, float_status *s) && (a.cls =3D=3D float_class_inf || a.cls =3D=3D float_class_zero)) { s->float_exception_flags |=3D float_flag_invalid; - a.cls =3D float_class_dnan; - return a; + return parts_default_nan(s); } /* Inf / x or 0 / x */ if (a.cls =3D=3D float_class_inf || a.cls =3D=3D float_class_zero) { @@ -1347,7 +1334,6 @@ static int64_t round_to_int_and_pack(FloatParts in, i= nt rmode, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_dnan: case float_class_msnan: s->float_exception_flags =3D orig_flags | float_flag_invalid; return max; @@ -1439,7 +1425,6 @@ static uint64_t round_to_uint_and_pack(FloatParts in,= int rmode, uint64_t max, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_dnan: case float_class_msnan: s->float_exception_flags =3D orig_flags | float_flag_invalid; return max; @@ -1940,8 +1925,7 @@ static FloatParts sqrt_float(FloatParts a, float_stat= us *s, const FloatFmt *p) } if (a.sign) { s->float_exception_flags |=3D float_flag_invalid; - a.cls =3D float_class_dnan; - return a; + return parts_default_nan(s); } if (a.cls =3D=3D float_class_inf) { return a; /* sqrt(+inf) =3D +inf */ --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486709077739.1460773685043; Wed, 16 May 2018 09:05:09 -0700 (PDT) Received: from localhost ([::1]:53100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyvM-0004e3-67 for importer@patchew.org; Wed, 16 May 2018 12:05:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjc-0004Ka-SM for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjb-00052l-CU for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:00 -0400 Received: from mail-pl0-x22e.google.com ([2607:f8b0:400e:c01::22e]:44324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjb-00052X-40 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:52:59 -0400 Received: by mail-pl0-x22e.google.com with SMTP id e6-v6so658999plt.11 for ; Wed, 16 May 2018 08:52:58 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:56 -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=n043IcTuWLeJOrF4bZrWAR222qKx5CvPEizqYpyknu8=; b=fsy97QGdzh7OGcyhk6PTc/aDP4j3qrd/BaioQf1VQUtk2CqneM081t2FjJMVrNElB4 PYHRo0V12AzR302LVl1w4xqFC2i2hOnEgt4/kPiHZBfiuNiceFjyzzi0f08nCTO8LEGw 3N3xDhFyljNkhiAiiRX7MKxJKlBfPTYDCDaJ8= 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=n043IcTuWLeJOrF4bZrWAR222qKx5CvPEizqYpyknu8=; b=ckXnMQZOs/nFGoHJOUzXUVcakKiz7atWUtgaltH4tA6B/Pqk4P7PT0VmoYJTPSDxVQ H40Z4k+daCH3bLbR9mJ3Qymk8D63i1Uy60xG4eTNBtTN1YUWkf8OJ4k0dENQh9yNjDCu rna3LUVZOqJkuSST3wVEewToQM1XrWDW6Woq/Y90I/Gdf2D1lWK0zbqMaTXvNWqNl6ss g6/PSPy/puWcg+ocI+nujGAR2Gzd63dk0NfGemn8X38RzhLKpdykU+GC9XFLc6PXQroN U6m4tsvJv5K59TuXavFupq/gPyqZvpPj60fzbb6kVbSTnZV76pTVLhwGlmcNaTjLLzex y4Hw== X-Gm-Message-State: ALKqPwe5xmPKiQDz5PD5XTBlVI5onpwXzBtXv9hUJlLqoX/Ajt7HuaFZ ciZoNIexQAXXmpGX0tYvrXSeCSjBPcE= X-Google-Smtp-Source: AB8JxZrK907/xIwX3NJCj3dqdeDxI2AbpZKWc1NdDxROYKOy6daFzUFjc2nHGvha3b7qmkdSCh/uyQ== X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr1494881plv.176.1526485977677; Wed, 16 May 2018 08:52:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:23 -0700 Message-Id: <20180516155243.16937-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22e Subject: [Qemu-devel] [PULL 08/28] fpu/softfloat: Replace float_class_msnan with parts_silence_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 With a canonical representation of NaNs, we can silence an SNaN immediately rather than delay until the final format is known. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 23 ++++++++++++++++++++++ fpu/softfloat.c | 40 ++++++++++---------------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 0d3d81a52b..571d1df378 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -138,6 +138,29 @@ static FloatParts parts_default_nan(float_status *stat= us) }; } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the deconstructed +| floating-point parts. +*-------------------------------------------------------------------------= ---*/ + +static FloatParts parts_silence_nan(FloatParts a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#elif defined(TARGET_HPPA) + a.frac &=3D ~(1ULL << (DECOMPOSED_BINARY_POINT - 1)); + a.frac |=3D 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#else + if (status->snan_bit_is_one) { + return parts_default_nan(status); + } else { + a.frac |=3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); + } +#endif + a.cls =3D float_class_qnan; + return a; +} + /*------------------------------------------------------------------------= ---- | The pattern for a default generated half-precision NaN. *-------------------------------------------------------------------------= ---*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 51780b718f..41253c6749 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -188,7 +188,6 @@ typedef enum __attribute__ ((__packed__)) { float_class_inf, float_class_qnan, /* all NaNs from here */ float_class_snan, - float_class_msnan, /* maybe silenced */ } FloatClass; =20 /* @@ -492,14 +491,7 @@ static FloatParts float16_unpack_canonical(float16 f, = float_status *s) =20 static float16 float16_round_pack_canonical(FloatParts p, float_status *s) { - switch (p.cls) { - case float_class_msnan: - p.frac >>=3D float16_params.frac_shift; - return float16_maybe_silence_nan(float16_pack_raw(p), s); - default: - p =3D round_canonical(p, s, &float16_params); - return float16_pack_raw(p); - } + return float16_pack_raw(round_canonical(p, s, &float16_params)); } =20 static FloatParts float32_unpack_canonical(float32 f, float_status *s) @@ -509,14 +501,7 @@ static FloatParts float32_unpack_canonical(float32 f, = float_status *s) =20 static float32 float32_round_pack_canonical(FloatParts p, float_status *s) { - switch (p.cls) { - case float_class_msnan: - p.frac >>=3D float32_params.frac_shift; - return float32_maybe_silence_nan(float32_pack_raw(p), s); - default: - p =3D round_canonical(p, s, &float32_params); - return float32_pack_raw(p); - } + return float32_pack_raw(round_canonical(p, s, &float32_params)); } =20 static FloatParts float64_unpack_canonical(float64 f, float_status *s) @@ -526,14 +511,7 @@ static FloatParts float64_unpack_canonical(float64 f, = float_status *s) =20 static float64 float64_round_pack_canonical(FloatParts p, float_status *s) { - switch (p.cls) { - case float_class_msnan: - p.frac >>=3D float64_params.frac_shift; - return float64_maybe_silence_nan(float64_pack_raw(p), s); - default: - p =3D round_canonical(p, s, &float64_params); - return float64_pack_raw(p); - } + return float64_pack_raw(round_canonical(p, s, &float64_params)); } =20 /* Simple helpers for checking if what NaN we have */ @@ -555,7 +533,7 @@ static FloatParts return_nan(FloatParts a, float_status= *s) switch (a.cls) { case float_class_snan: s->float_exception_flags |=3D float_flag_invalid; - a.cls =3D float_class_msnan; + a =3D parts_silence_nan(a, s); /* fall through */ case float_class_qnan: if (s->default_nan_mode) { @@ -584,7 +562,9 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, = float_status *s) (a.frac =3D=3D b.frac && a.sign < b.sign))) { a =3D b; } - a.cls =3D float_class_msnan; + if (is_snan(a.cls)) { + return parts_silence_nan(a, s); + } } return a; } @@ -624,8 +604,10 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatP= arts b, FloatParts c, default: g_assert_not_reached(); } - a.cls =3D float_class_msnan; =20 + if (is_snan(a.cls)) { + return parts_silence_nan(a, s); + } return a; } =20 @@ -1334,7 +1316,6 @@ static int64_t round_to_int_and_pack(FloatParts in, i= nt rmode, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_msnan: s->float_exception_flags =3D orig_flags | float_flag_invalid; return max; case float_class_inf: @@ -1425,7 +1406,6 @@ static uint64_t round_to_uint_and_pack(FloatParts in,= int rmode, uint64_t max, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_msnan: s->float_exception_flags =3D orig_flags | float_flag_invalid; return max; case float_class_inf: --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486915650186.4368715330794; Wed, 16 May 2018 09:08:35 -0700 (PDT) Received: from localhost ([::1]:53197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyyg-0007ww-KM for importer@patchew.org; Wed, 16 May 2018 12:08:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyje-0004On-V1 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjd-000536-0i for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:03 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:40636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjc-00052v-Ns for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:00 -0400 Received: by mail-pg0-x22c.google.com with SMTP id l2-v6so468127pgc.7 for ; Wed, 16 May 2018 08:53:00 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:58 -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=lNYTEpPImDNUnUfC5REzH47EpfQy5tZj72C4uJ3GNHM=; b=EJwmaA2dhgf9NSTL6NgElOZ2YaiArjTePLnCojug2UAApteIUwVh6nWSNukLYsuFiH wV0csC3wdy6E56P0swzYBPFkWTlGYZv8/CrKH0mLHm3m21ODhFkWo7vf3vpnkEMOP+BC l3nO7vj9mLovdBOoaIv+hDsMq0WJg/Q0uM//w= 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=lNYTEpPImDNUnUfC5REzH47EpfQy5tZj72C4uJ3GNHM=; b=I0uvdgz2vQaEm4HSco/PbeZjcj4UA97bkk9nSjlT2WxBkv7i8yoZvcMZHyZJ4wK9Td n+LV4VMUftm80jaNu0PGA1mgJgY8aocaTTCxwQasjvu3AigHplyFgy8K841K3GMSJCel Z+JjfHAsMNcHq4olEPrPIhikHxuX7y2mP1ohWS346hFz/z818Yyqtu484WoJo0iTtqEj KyXopXly+tGUgKXcICoBuCyTxi64SegzB4A1CSLAsVf6KDCbxZfBZ/XapNcuetwNJ/lr n2dMgDk5H+ME88EWnXXU8SPpCjE9Gbs2576zxJLyQMmXx2uWhih3vzcHjJouGjzgBH/R feUQ== X-Gm-Message-State: ALKqPwdXpM3TyZq7kWMw3OKkzE/5MtCodJI9T/Ndjf10ACs5Frvo3GLs nXgCYMJ/rn8v8FcQv66MDDOdyZtzNuU= X-Google-Smtp-Source: AB8JxZpK6mmN/y01hLJ+UFx4O6fE/vXXcJRkFp9imyYzKXU5eq4x88omuj9yNrPavhf28le7xCtrnw== X-Received: by 2002:a63:8c5e:: with SMTP id q30-v6mr1167293pgn.160.1526485979180; Wed, 16 May 2018 08:52:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:24 -0700 Message-Id: <20180516155243.16937-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22c Subject: [Qemu-devel] [PULL 09/28] target/arm: convert conversion helpers to fpst/ahp_flag 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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e Instead of passing env and leaving it up to the helper to get the right fpstatus we pass it explicitly. There was already a get_fpstatus helper for neon for the 32 bit code. We also add an get_ahp_flag() for passing the state of the alternative FP16 format flag. This leaves scope for later tracking the AHP state in translation flags. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.h | 10 +++--- target/arm/translate.h | 12 +++++++ target/arm/helper.c | 56 +++++------------------------ target/arm/translate-a64.c | 37 +++++++++++++++---- target/arm/translate.c | 74 +++++++++++++++++++++++++++++--------- 5 files changed, 112 insertions(+), 77 deletions(-) diff --git a/target/arm/helper.h b/target/arm/helper.h index ce89968b2d..047f3bc1ca 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -187,12 +187,10 @@ DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) =20 -DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env) -DEF_HELPER_2(vfp_fcvt_f32_to_f16, i32, f32, env) -DEF_HELPER_2(neon_fcvt_f16_to_f32, f32, i32, env) -DEF_HELPER_2(neon_fcvt_f32_to_f16, i32, f32, env) -DEF_HELPER_FLAGS_2(vfp_fcvt_f16_to_f64, TCG_CALL_NO_RWG, f64, i32, env) -DEF_HELPER_FLAGS_2(vfp_fcvt_f64_to_f16, TCG_CALL_NO_RWG, i32, f64, env) +DEF_HELPER_FLAGS_3(vfp_fcvt_f16_to_f32, TCG_CALL_NO_RWG, f32, f16, ptr, i3= 2) +DEF_HELPER_FLAGS_3(vfp_fcvt_f32_to_f16, TCG_CALL_NO_RWG, f16, f32, ptr, i3= 2) +DEF_HELPER_FLAGS_3(vfp_fcvt_f16_to_f64, TCG_CALL_NO_RWG, f64, f16, ptr, i3= 2) +DEF_HELPER_FLAGS_3(vfp_fcvt_f64_to_f16, TCG_CALL_NO_RWG, f16, f64, ptr, i3= 2) =20 DEF_HELPER_4(vfp_muladdd, f64, f64, f64, f64, ptr) DEF_HELPER_4(vfp_muladds, f32, f32, f32, f32, ptr) diff --git a/target/arm/translate.h b/target/arm/translate.h index 37a1bba056..45f04244be 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -177,4 +177,16 @@ void arm_free_cc(DisasCompare *cmp); void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); void arm_gen_test_cc(int cc, TCGLabel *label); =20 +/* Return state of Alternate Half-precision flag, caller frees result */ +static inline TCGv_i32 get_ahp_flag(void) +{ + TCGv_i32 ret =3D tcg_temp_new_i32(); + + tcg_gen_ld_i32(ret, cpu_env, + offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPSCR])); + tcg_gen_extract_i32(ret, ret, 26, 1); + + return ret; +} + #endif /* TARGET_ARM_TRANSLATE_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index c6fd7f9479..1762042fc7 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11540,64 +11540,24 @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, C= PUARMState *env) } =20 /* Half precision conversions. */ -static float32 do_fcvt_f16_to_f32(uint32_t a, CPUARMState *env, float_stat= us *s) +float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_m= ode) { - int ieee =3D (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) =3D=3D 0; - float32 r =3D float16_to_float32(make_float16(a), ieee, s); - if (ieee) { - return float32_maybe_silence_nan(r, s); - } - return r; + return float16_to_float32(a, !ahp_mode, fpstp); } =20 -static uint32_t do_fcvt_f32_to_f16(float32 a, CPUARMState *env, float_stat= us *s) +float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_m= ode) { - int ieee =3D (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) =3D=3D 0; - float16 r =3D float32_to_float16(a, ieee, s); - if (ieee) { - r =3D float16_maybe_silence_nan(r, s); - } - return float16_val(r); + return float32_to_float16(a, !ahp_mode, fpstp); } =20 -float32 HELPER(neon_fcvt_f16_to_f32)(uint32_t a, CPUARMState *env) +float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_m= ode) { - return do_fcvt_f16_to_f32(a, env, &env->vfp.standard_fp_status); + return float16_to_float64(a, !ahp_mode, fpstp); } =20 -uint32_t HELPER(neon_fcvt_f32_to_f16)(float32 a, CPUARMState *env) +float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_m= ode) { - return do_fcvt_f32_to_f16(a, env, &env->vfp.standard_fp_status); -} - -float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, CPUARMState *env) -{ - return do_fcvt_f16_to_f32(a, env, &env->vfp.fp_status); -} - -uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, CPUARMState *env) -{ - return do_fcvt_f32_to_f16(a, env, &env->vfp.fp_status); -} - -float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, CPUARMState *env) -{ - int ieee =3D (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) =3D=3D 0; - float64 r =3D float16_to_float64(make_float16(a), ieee, &env->vfp.fp_s= tatus); - if (ieee) { - return float64_maybe_silence_nan(r, &env->vfp.fp_status); - } - return r; -} - -uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, CPUARMState *env) -{ - int ieee =3D (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) =3D=3D 0; - float16 r =3D float64_to_float16(a, ieee, &env->vfp.fp_status); - if (ieee) { - r =3D float16_maybe_silence_nan(r, &env->vfp.fp_status); - } - return float16_val(r); + return float64_to_float16(a, !ahp_mode, fpstp); } =20 #define float32_two make_float32(0x40000000) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a0b0c43d12..d8284678f7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5147,10 +5147,15 @@ static void handle_fp_fcvt(DisasContext *s, int opc= ode, } else { /* Single to half */ TCGv_i32 tcg_rd =3D tcg_temp_new_i32(); - gen_helper_vfp_fcvt_f32_to_f16(tcg_rd, tcg_rn, cpu_env); + TCGv_i32 ahp =3D get_ahp_flag(); + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + + gen_helper_vfp_fcvt_f32_to_f16(tcg_rd, tcg_rn, fpst, ahp); /* write_fp_sreg is OK here because top half of tcg_rd is zero= */ write_fp_sreg(s, rd, tcg_rd); tcg_temp_free_i32(tcg_rd); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); } tcg_temp_free_i32(tcg_rn); break; @@ -5163,9 +5168,13 @@ static void handle_fp_fcvt(DisasContext *s, int opco= de, /* Double to single */ gen_helper_vfp_fcvtsd(tcg_rd, tcg_rn, cpu_env); } else { + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp =3D get_ahp_flag(); /* Double to half */ - gen_helper_vfp_fcvt_f64_to_f16(tcg_rd, tcg_rn, cpu_env); + gen_helper_vfp_fcvt_f64_to_f16(tcg_rd, tcg_rn, fpst, ahp); /* write_fp_sreg is OK here because top half of tcg_rd is zero= */ + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(ahp); } write_fp_sreg(s, rd, tcg_rd); tcg_temp_free_i32(tcg_rd); @@ -5175,17 +5184,21 @@ static void handle_fp_fcvt(DisasContext *s, int opc= ode, case 0x3: { TCGv_i32 tcg_rn =3D read_fp_sreg(s, rn); + TCGv_ptr tcg_fpst =3D get_fpstatus_ptr(false); + TCGv_i32 tcg_ahp =3D get_ahp_flag(); tcg_gen_ext16u_i32(tcg_rn, tcg_rn); if (dtype =3D=3D 0) { /* Half to single */ TCGv_i32 tcg_rd =3D tcg_temp_new_i32(); - gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, cpu_env); + gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, tcg_fpst, tcg_a= hp); write_fp_sreg(s, rd, tcg_rd); + tcg_temp_free_ptr(tcg_fpst); + tcg_temp_free_i32(tcg_ahp); tcg_temp_free_i32(tcg_rd); } else { /* Half to double */ TCGv_i64 tcg_rd =3D tcg_temp_new_i64(); - gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, cpu_env); + gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, tcg_fpst, tcg_a= hp); write_fp_dreg(s, rd, tcg_rd); tcg_temp_free_i64(tcg_rd); } @@ -9053,12 +9066,17 @@ static void handle_2misc_narrow(DisasContext *s, bo= ol scalar, } else { TCGv_i32 tcg_lo =3D tcg_temp_new_i32(); TCGv_i32 tcg_hi =3D tcg_temp_new_i32(); + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp =3D get_ahp_flag(); + tcg_gen_extr_i64_i32(tcg_lo, tcg_hi, tcg_op); - gen_helper_vfp_fcvt_f32_to_f16(tcg_lo, tcg_lo, cpu_env); - gen_helper_vfp_fcvt_f32_to_f16(tcg_hi, tcg_hi, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tcg_lo, tcg_lo, fpst, ahp); + gen_helper_vfp_fcvt_f32_to_f16(tcg_hi, tcg_hi, fpst, ahp); tcg_gen_deposit_i32(tcg_res[pass], tcg_lo, tcg_hi, 16, 16); tcg_temp_free_i32(tcg_lo); tcg_temp_free_i32(tcg_hi); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(ahp); } break; case 0x56: /* FCVTXN, FCVTXN2 */ @@ -11532,18 +11550,23 @@ static void handle_2misc_widening(DisasContext *s= , int opcode, bool is_q, /* 16 -> 32 bit fp conversion */ int srcelt =3D is_q ? 4 : 0; TCGv_i32 tcg_res[4]; + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp =3D get_ahp_flag(); =20 for (pass =3D 0; pass < 4; pass++) { tcg_res[pass] =3D tcg_temp_new_i32(); =20 read_vec_element_i32(s, tcg_res[pass], rn, srcelt + pass, MO_1= 6); gen_helper_vfp_fcvt_f16_to_f32(tcg_res[pass], tcg_res[pass], - cpu_env); + fpst, ahp); } for (pass =3D 0; pass < 4; pass++) { write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_32); tcg_temp_free_i32(tcg_res[pass]); } + + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(ahp); } } =20 diff --git a/target/arm/translate.c b/target/arm/translate.c index 731cf327a1..613598d090 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3824,38 +3824,56 @@ static int disas_vfp_insn(DisasContext *s, uint32_t= insn) gen_vfp_sqrt(dp); break; case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ + { + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp_mode =3D get_ahp_flag(); tmp =3D gen_vfp_mrs(); tcg_gen_ext16u_i32(tmp, tmp); if (dp) { gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - cpu_env); + fpst, ahp_mode); } else { gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - cpu_env); + fpst, ahp_mode); } + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); tcg_temp_free_i32(tmp); break; + } case 5: /* vcvtt.f32.f16, vcvtt.f64.f16 */ + { + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp =3D get_ahp_flag(); tmp =3D gen_vfp_mrs(); tcg_gen_shri_i32(tmp, tmp, 16); if (dp) { gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - cpu_env); + fpst, ahp); } else { gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - cpu_env); + fpst, ahp); } tcg_temp_free_i32(tmp); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); break; + } case 6: /* vcvtb.f16.f32, vcvtb.f16.f64 */ + { + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp =3D get_ahp_flag(); tmp =3D tcg_temp_new_i32(); + if (dp) { gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - cpu_env); + fpst, ahp); } else { gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - cpu_env); + fpst, ahp); } + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); gen_mov_F0_vreg(0, rd); tmp2 =3D gen_vfp_mrs(); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); @@ -3863,15 +3881,21 @@ static int disas_vfp_insn(DisasContext *s, uint32_t= insn) tcg_temp_free_i32(tmp2); gen_vfp_msr(tmp); break; + } case 7: /* vcvtt.f16.f32, vcvtt.f16.f64 */ + { + TCGv_ptr fpst =3D get_fpstatus_ptr(false); + TCGv_i32 ahp =3D get_ahp_flag(); tmp =3D tcg_temp_new_i32(); if (dp) { gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - cpu_env); + fpst, ahp); } else { gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - cpu_env); + fpst, ahp); } + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); tcg_gen_shli_i32(tmp, tmp, 16); gen_mov_F0_vreg(0, rd); tmp2 =3D gen_vfp_mrs(); @@ -3880,6 +3904,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t i= nsn) tcg_temp_free_i32(tmp2); gen_vfp_msr(tmp); break; + } case 8: /* cmp */ gen_vfp_cmp(dp); break; @@ -7222,53 +7247,70 @@ static int disas_neon_data_insn(DisasContext *s, ui= nt32_t insn) } break; case NEON_2RM_VCVT_F16_F32: + { + TCGv_ptr fpst; + TCGv_i32 ahp; + if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) || q || (rm & 1)) { return 1; } tmp =3D tcg_temp_new_i32(); tmp2 =3D tcg_temp_new_i32(); + fpst =3D get_fpstatus_ptr(false); + ahp =3D get_ahp_flag(); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 0= )); - gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, fpst, ahp= ); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 1= )); - gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env= ); + gen_helper_vfp_fcvt_f32_to_f16(tmp2, cpu_F0s, fpst, ah= p); tcg_gen_shli_i32(tmp2, tmp2, 16); tcg_gen_or_i32(tmp2, tmp2, tmp); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 2= )); - gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, fpst, ahp= ); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 3= )); neon_store_reg(rd, 0, tmp2); tmp2 =3D tcg_temp_new_i32(); - gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env= ); + gen_helper_vfp_fcvt_f32_to_f16(tmp2, cpu_F0s, fpst, ah= p); tcg_gen_shli_i32(tmp2, tmp2, 16); tcg_gen_or_i32(tmp2, tmp2, tmp); neon_store_reg(rd, 1, tmp2); tcg_temp_free_i32(tmp); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); break; + } case NEON_2RM_VCVT_F32_F16: + { + TCGv_ptr fpst; + TCGv_i32 ahp; if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) || q || (rd & 1)) { return 1; } + fpst =3D get_fpstatus_ptr(false); + ahp =3D get_ahp_flag(); tmp3 =3D tcg_temp_new_i32(); tmp =3D neon_load_reg(rm, 0); tmp2 =3D neon_load_reg(rm, 1); tcg_gen_ext16u_i32(tmp3, tmp); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env= ); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ah= p); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 0= )); tcg_gen_shri_i32(tmp3, tmp, 16); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env= ); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ah= p); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 1= )); tcg_temp_free_i32(tmp); tcg_gen_ext16u_i32(tmp3, tmp2); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env= ); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ah= p); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 2= )); tcg_gen_shri_i32(tmp3, tmp2, 16); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env= ); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ah= p); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 3= )); tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp3); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); break; + } case NEON_2RM_AESE: case NEON_2RM_AESMC: if (!arm_dc_feature(s, ARM_FEATURE_V8_AES) || ((rm | rd) & 1)) { --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486297222882.8449930271948; Wed, 16 May 2018 08:58:17 -0700 (PDT) Received: from localhost ([::1]:53017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyoi-00080e-Bx for importer@patchew.org; Wed, 16 May 2018 11:58:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyji-0004SQ-6q for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyje-00053g-8k for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:06 -0400 Received: from mail-pl0-x236.google.com ([2607:f8b0:400e:c01::236]:40732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyje-00053O-2g for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:02 -0400 Received: by mail-pl0-x236.google.com with SMTP id t12-v6so667281plo.7 for ; Wed, 16 May 2018 08:53:01 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.52.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:52:59 -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=AwjiM5r4GwDBOEYqDQfDwjPqxnxEcPVFlhKq+cNRwBA=; b=I1le5JaD0d7zxjiJ9JY3ZO6o/yyn1cYCUPNIL0aP4zD0fXVuYchru73hKxIk0a7OtB 66n9HZBtJnFtNwoX0d8cLdqGM6nO8RfnEktoSruesIaaiGkAiSh0eNoEZmZIAwijXmOh XbJcJpiFcwPDMio2wZahMlu+yz+9O+CKLhRi4= 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=AwjiM5r4GwDBOEYqDQfDwjPqxnxEcPVFlhKq+cNRwBA=; b=TDPnqceE8uUhEA7GJs1onwH7YPRe9OM7Sl5hvUZEqsYWXvdItPvfQeqJHcnlr6cbuT j0uN2QjHV6Aoq0tsFTQBhygVdE88TYdlD9kID0Geer69j6yubhQYVBF7ssD6ZUcYGiof iBYFKDTcFAygn/L/+FnJqBgEfSar+mZ3+KOT/GRsuTSYOfaVf0pfgGG84C56dSUn0+Hq Hvozbx7mcs+MwoAT5WlBc1ifckQ7iyzebzluruOn4w2Z6YqU4MC+dhXs5amaw0Dq0DWq +XGcqv7eme+mtJAezXfe5G04GLOExXToQVWnPkUZpMQvduBLRmb69Necg35MQBbtUgkG EQ/Q== X-Gm-Message-State: ALKqPweVNLJNmfNkF/5tZ+N/pL7/es53JI/k0LI7ZH4KgH7ZSFTuhzN4 eQUmSEPrahYga1o5OJ9Mc+tQ/eMG6Sw= X-Google-Smtp-Source: AB8JxZr/yRxkYSy3NBevWvRQnH5/Z36i1Kkhe1ui8lbwMFS5RykMOPXwwgBBdkIyEie3Vb5E5SN53w== X-Received: by 2002:a17:902:d681:: with SMTP id v1-v6mr1467232ply.16.1526485980638; Wed, 16 May 2018 08:53:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:25 -0700 Message-Id: <20180516155243.16937-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::236 Subject: [Qemu-devel] [PULL 10/28] target/arm: squash FZ16 behaviour for conversions 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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e The ARM ARM specifies FZ16 is suppressed for conversions. Rather than pushing this logic into the softfloat code we can simply save the FZ state and temporarily disable it for the softfloat call. Reviewed-by: Peter Maydell Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- target/arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 1762042fc7..238a3ceba8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11542,22 +11542,54 @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, C= PUARMState *env) /* Half precision conversions. */ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_m= ode) { - return float16_to_float32(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst =3D fpstp; + flag save =3D get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float32 r =3D float16_to_float32(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; } =20 float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_m= ode) { - return float32_to_float16(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst =3D fpstp; + flag save =3D get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r =3D float32_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; } =20 float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_m= ode) { - return float16_to_float64(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst =3D fpstp; + flag save =3D get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float64 r =3D float16_to_float64(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; } =20 float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_m= ode) { - return float64_to_float16(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst =3D fpstp; + flag save =3D get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r =3D float64_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; } =20 #define float32_two make_float32(0x40000000) --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152648709193955.89994291305413; Wed, 16 May 2018 09:11:31 -0700 (PDT) Received: from localhost ([::1]:53234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz1X-00029L-4t for importer@patchew.org; Wed, 16 May 2018 12:11:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjg-0004QK-GJ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjf-000543-Fq for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:04 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:39364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjf-00053u-9a for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:03 -0400 Received: by mail-pl0-x242.google.com with SMTP id c19-v6so668338pls.6 for ; Wed, 16 May 2018 08:53:03 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:00 -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=lRqGxJhzFUeyacxzleC4RhsXXY0zMiUoKTM/DfcJ4HY=; b=U0diJaEsVeqqZQGIRT7SSZ86E4EFLxgl+pVZKJ6CDJf/G7zTqdvv/e39Kv/hFKv4O9 am9Q8V+DWf3dvenlR3DGpVZhrfetGTGQbIrovPTCbiM8T6NZa4T/Avjiy/ma2YPdcAZ7 QsfhHyVYTj8Lm7El63C3I38E721Tzj1mqjIoA= 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=lRqGxJhzFUeyacxzleC4RhsXXY0zMiUoKTM/DfcJ4HY=; b=U7IqW7+co0MKn8VGLOeDlgl3cJVfkdSHoW+FucCu5BcdxXwTjJYvQJvWHnoHF7PTQ5 CVLEkBOer0VM3krI4Ed243qAS+QqcpbTkTyGypd6pjsx5q1jlItqQbr5wDGR3sG5+SvT 9K9bpRM2Y+KDpo7J54z0bs8NNpTsfUa9eRJH5otP6QVvNSjEsbfQ9JN83wqOR4Wqd7ry UCx/EJ5/+WaRgOPbM0sgUmU6rtFnTJQ1CpWpWoVRnyqy8pOmOX7rBBB6J5iY6jovGFVI pNpWICZe6Q8O+BbfwO04PwRgih/sR5ATFle7ZAyaFcMufY7q0t7U+9zr90JJWBaOMmF6 r3pw== X-Gm-Message-State: ALKqPwds11t8kINoMKdchr1hIBmL0BjwMAOTDoxg2/8ltBv0/+AOB8IY yRS1VD98tCTCdCdJDL5Wgze2Q6dxPGg= X-Google-Smtp-Source: AB8JxZoVScNN1zRJueG6wu+jA0KGMi+e8VCs07941Y+89jc+J2TxJqR/huxP9NDvSLS2WeztFuDJSQ== X-Received: by 2002:a17:902:6006:: with SMTP id r6-v6mr1463603plj.70.1526485981937; Wed, 16 May 2018 08:53:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:26 -0700 Message-Id: <20180516155243.16937-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL 11/28] fpu/softfloat: Partial support for ARM Alternative half-precision 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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e For float16 ARM supports an alternative half-precision format which sacrifices the ability to represent NaN/Inf in return for a higher dynamic range. The new FloatFmt flag, arm_althp, is then used to modify the behaviour of canonicalize and round_canonical with respect to representation and exception raising. Usage of this new flag waits until we re-factor float-to-float conversions. Reviewed-by: Peter Maydell Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- fpu/softfloat.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 41253c6749..64e1ad4f98 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -220,8 +220,10 @@ typedef struct { * frac_shift: shift to normalise the fraction with DECOMPOSED_BINARY_PO= INT * The following are computed based the size of fraction * frac_lsb: least significant bit of fraction - * fram_lsbm1: the bit bellow the least significant bit (for rounding) + * frac_lsbm1: the bit below the least significant bit (for rounding) * round_mask/roundeven_mask: masks used for rounding + * The following optional modifiers are available: + * arm_althp: handle ARM Alternative Half Precision */ typedef struct { int exp_size; @@ -233,6 +235,7 @@ typedef struct { uint64_t frac_lsbm1; uint64_t round_mask; uint64_t roundeven_mask; + bool arm_althp; } FloatFmt; =20 /* Expand fields based on the size of exponent and fraction */ @@ -324,7 +327,7 @@ static inline float64 float64_pack_raw(FloatParts p) static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, float_status *status) { - if (part.exp =3D=3D parm->exp_max) { + if (part.exp =3D=3D parm->exp_max && !parm->arm_althp) { if (part.frac =3D=3D 0) { part.cls =3D float_class_inf; } else { @@ -413,7 +416,15 @@ static FloatParts round_canonical(FloatParts p, float_= status *s, } frac >>=3D frac_shift; =20 - if (unlikely(exp >=3D exp_max)) { + if (parm->arm_althp) { + /* ARM Alt HP eschews Inf and NaN for a wider exponent. */ + if (unlikely(exp > exp_max)) { + /* Overflow. Return the maximum normal. */ + flags =3D float_flag_invalid; + exp =3D exp_max; + frac =3D -1; + } + } else if (unlikely(exp >=3D exp_max)) { flags |=3D float_flag_overflow | float_flag_inexact; if (overflow_norm) { exp =3D exp_max - 1; @@ -464,12 +475,14 @@ static FloatParts round_canonical(FloatParts p, float= _status *s, =20 case float_class_inf: do_inf: + assert(!parm->arm_althp); exp =3D exp_max; frac =3D 0; break; =20 case float_class_qnan: case float_class_snan: + assert(!parm->arm_althp); exp =3D exp_max; frac >>=3D parm->frac_shift; break; --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487274312108.5668747005011; Wed, 16 May 2018 09:14:34 -0700 (PDT) Received: from localhost ([::1]:53426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz4T-0004qH-DN for importer@patchew.org; Wed, 16 May 2018 12:14:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjk-0004Tq-1P for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjh-00054V-H8 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:08 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:39989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjh-00054H-6l for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:05 -0400 Received: by mail-pg0-x243.google.com with SMTP id l2-v6so468208pgc.7 for ; Wed, 16 May 2018 08:53:05 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:02 -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=NHK++rRcBK+nX1H3kfWQep2yH2z9rb0GTe6sEKFrKTM=; b=iOTaK3zaaavjnGFCtQg6xO+Bgb5+EOzd6BTA2QvavrZ8s6eNPMWpStFtemMCTZwguA wVPqe0U8NV+Cz89OS5X0OtAuIhFGahUvP/DM6sLAa9lotyRLg+lc7xl47iB8w180byF+ TATIK4YtgyCUBD06p8bD7gWLBphEn7AzxLF7g= 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=NHK++rRcBK+nX1H3kfWQep2yH2z9rb0GTe6sEKFrKTM=; b=nNaAm91hMpF/uy0AvQTE1LelWXJjNJ37e3KwnZiDE7XAKbfQWoeaiERltwE4LWbbLs p+ALIp/GhXEOONOiUEbALK62cavrMiHGoj51NwXLX83BFaZ+wSYFnfl/HMdDNEvniUcF Nvw+pFXkh2NrgM82ThHIdH/q//2ll3VhVXva6mcem00wWDe69Zp1vk+iMjCsQgagj8e3 ZCsScV5wd+YN4US01tIxXDqzIUl3GyuRry8wGZVrVNjzJKpCoWSyczgRj/1O5c+GET07 7Rbpc+1SKUGc6ptkL7wuzVwA6Nxf5wpl6cQMzHA4L/D5BLVHPlORTnN44RwFmBumjz3p v/ig== X-Gm-Message-State: ALKqPwfDpNOnR/0QrAc68Z6xyMCQyPautt0mQ2Y6Y977JtUK7kXMZkUC kxMOIgXau2jQJrSgiDthR8HQsDtDMTs= X-Google-Smtp-Source: AB8JxZqzSNm9iP1ygxaDqXkCBPPD5T1ko4HtEwhELoZzmiAP3aFG0/SY4uVE86HFrOPUPhCCX7C/xg== X-Received: by 2002:a63:9741:: with SMTP id d1-v6mr1140576pgo.447.1526485983369; Wed, 16 May 2018 08:53:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:27 -0700 Message-Id: <20180516155243.16937-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PULL 12/28] fpu/softfloat: re-factor float to float conversions 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, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Alex Benn=C3=A9e This allows us to delete a lot of additional boilerplate code which is no longer needed. Reviewed-by: Peter Maydell Signed-off-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 40 --- include/fpu/softfloat.h | 8 +- fpu/softfloat.c | 488 +++++++++---------------------------- 3 files changed, 122 insertions(+), 414 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 571d1df378..995a0132c6 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -377,46 +377,6 @@ float16 float16_maybe_silence_nan(float16 a, float_sta= tus *status) return a; } =20 -/*------------------------------------------------------------------------= ---- -| Returns the result of converting the half-precision floating-point NaN -| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -| exception is raised. -*-------------------------------------------------------------------------= ---*/ - -static commonNaNT float16ToCommonNaN(float16 a, float_status *status) -{ - commonNaNT z; - - if (float16_is_signaling_nan(a, status)) { - float_raise(float_flag_invalid, status); - } - z.sign =3D float16_val(a) >> 15; - z.low =3D 0; - z.high =3D ((uint64_t) float16_val(a)) << 54; - return z; -} - -/*------------------------------------------------------------------------= ---- -| Returns the result of converting the canonical NaN `a' to the half- -| precision floating-point format. -*-------------------------------------------------------------------------= ---*/ - -static float16 commonNaNToFloat16(commonNaNT a, float_status *status) -{ - uint16_t mantissa =3D a.high >> 54; - - if (status->default_nan_mode) { - return float16_default_nan(status); - } - - if (mantissa) { - return make_float16(((((uint16_t) a.sign) << 15) - | (0x1F << 10) | mantissa)); - } else { - return float16_default_nan(status); - } -} - /*------------------------------------------------------------------------= ---- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 43962dc3f5..a6860e858d 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -211,10 +211,10 @@ float128 uint64_to_float128(uint64_t, float_status *s= tatus); /*------------------------------------------------------------------------= ---- | Software half-precision conversion routines. *-------------------------------------------------------------------------= ---*/ -float16 float32_to_float16(float32, flag, float_status *status); -float32 float16_to_float32(float16, flag, float_status *status); -float16 float64_to_float16(float64 a, flag ieee, float_status *status); -float64 float16_to_float64(float16 a, flag ieee, float_status *status); +float16 float32_to_float16(float32, bool ieee, float_status *status); +float32 float16_to_float32(float16, bool ieee, float_status *status); +float16 float64_to_float16(float64 a, bool ieee, float_status *status); +float64 float16_to_float64(float16 a, bool ieee, float_status *status); int16_t float16_to_int16(float16, float_status *status); uint16_t float16_to_uint16(float16 a, float_status *status); int16_t float16_to_int16_round_to_zero(float16, float_status *status); diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 64e1ad4f98..55e6701f26 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -113,15 +113,6 @@ static inline int extractFloat16Exp(float16 a) return (float16_val(a) >> 10) & 0x1f; } =20 -/*------------------------------------------------------------------------= ---- -| Returns the sign bit of the single-precision floating-point value `a'. -*-------------------------------------------------------------------------= ---*/ - -static inline flag extractFloat16Sign(float16 a) -{ - return float16_val(a)>>15; -} - /*------------------------------------------------------------------------= ---- | Returns the fraction bits of the single-precision floating-point value `= a'. *-------------------------------------------------------------------------= ---*/ @@ -254,6 +245,11 @@ static const FloatFmt float16_params =3D { FLOAT_PARAMS(5, 10) }; =20 +static const FloatFmt float16_params_ahp =3D { + FLOAT_PARAMS(5, 10), + .arm_althp =3D true +}; + static const FloatFmt float32_params =3D { FLOAT_PARAMS(8, 23) }; @@ -497,14 +493,27 @@ static FloatParts round_canonical(FloatParts p, float= _status *s, return p; } =20 +/* Explicit FloatFmt version */ +static FloatParts float16a_unpack_canonical(float16 f, float_status *s, + const FloatFmt *params) +{ + return canonicalize(float16_unpack_raw(f), params, s); +} + static FloatParts float16_unpack_canonical(float16 f, float_status *s) { - return canonicalize(float16_unpack_raw(f), &float16_params, s); + return float16a_unpack_canonical(f, s, &float16_params); +} + +static float16 float16a_round_pack_canonical(FloatParts p, float_status *s, + const FloatFmt *params) +{ + return float16_pack_raw(round_canonical(p, s, params)); } =20 static float16 float16_round_pack_canonical(FloatParts p, float_status *s) { - return float16_pack_raw(round_canonical(p, s, &float16_params)); + return float16a_round_pack_canonical(p, s, &float16_params); } =20 static FloatParts float32_unpack_canonical(float32 f, float_status *s) @@ -1181,6 +1190,104 @@ float64 float64_div(float64 a, float64 b, float_sta= tus *status) return float64_round_pack_canonical(pr, status); } =20 +/* + * Float to Float conversions + * + * Returns the result of converting one float format to another. The + * conversion is performed according to the IEC/IEEE Standard for + * Binary Floating-Point Arithmetic. + * + * The float_to_float helper only needs to take care of raising + * invalid exceptions and handling the conversion on NaNs. + */ + +static FloatParts float_to_float(FloatParts a, const FloatFmt *dstf, + float_status *s) +{ + if (dstf->arm_althp) { + switch (a.cls) { + case float_class_qnan: + case float_class_snan: + /* There is no NaN in the destination format. Raise Invalid + * and return a zero with the sign of the input NaN. + */ + s->float_exception_flags |=3D float_flag_invalid; + a.cls =3D float_class_zero; + a.frac =3D 0; + a.exp =3D 0; + break; + + case float_class_inf: + /* There is no Inf in the destination format. Raise Invalid + * and return the maximum normal with the correct sign. + */ + s->float_exception_flags |=3D float_flag_invalid; + a.cls =3D float_class_normal; + a.exp =3D dstf->exp_max; + a.frac =3D ((1ull << dstf->frac_size) - 1) << dstf->frac_shift; + break; + + default: + break; + } + } else if (is_nan(a.cls)) { + if (is_snan(a.cls)) { + s->float_exception_flags |=3D float_flag_invalid; + a =3D parts_silence_nan(a, s); + } + if (s->default_nan_mode) { + return parts_default_nan(s); + } + } + return a; +} + +float32 float16_to_float32(float16 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 =3D ieee ? &float16_params : &float16_params_ahp; + FloatParts p =3D float16a_unpack_canonical(a, s, fmt16); + FloatParts pr =3D float_to_float(p, &float32_params, s); + return float32_round_pack_canonical(pr, s); +} + +float64 float16_to_float64(float16 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 =3D ieee ? &float16_params : &float16_params_ahp; + FloatParts p =3D float16a_unpack_canonical(a, s, fmt16); + FloatParts pr =3D float_to_float(p, &float64_params, s); + return float64_round_pack_canonical(pr, s); +} + +float16 float32_to_float16(float32 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 =3D ieee ? &float16_params : &float16_params_ahp; + FloatParts p =3D float32_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, fmt16, s); + return float16a_round_pack_canonical(pr, s, fmt16); +} + +float64 float32_to_float64(float32 a, float_status *s) +{ + FloatParts p =3D float32_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, &float64_params, s); + return float64_round_pack_canonical(pr, s); +} + +float16 float64_to_float16(float64 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 =3D ieee ? &float16_params : &float16_params_ahp; + FloatParts p =3D float64_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, fmt16, s); + return float16a_round_pack_canonical(pr, s, fmt16); +} + +float32 float64_to_float32(float64 a, float_status *s) +{ + FloatParts p =3D float64_unpack_canonical(a, s); + FloatParts pr =3D float_to_float(p, &float32_params, s); + return float32_round_pack_canonical(pr, s); +} + /* * Rounds the floating-point value `a' to an integer, and returns the * result as a floating-point value. The operation is performed @@ -3124,41 +3231,6 @@ float128 uint64_to_float128(uint64_t a, float_status= *status) return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status); } =20 - - - -/*------------------------------------------------------------------------= ---- -| Returns the result of converting the single-precision floating-point val= ue -| `a' to the double-precision floating-point format. The conversion is -| performed according to the IEC/IEEE Standard for Binary Floating-Point -| Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -float64 float32_to_float64(float32 a, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - a =3D float32_squash_input_denormal(a, status); - - aSig =3D extractFloat32Frac( a ); - aExp =3D extractFloat32Exp( a ); - aSign =3D extractFloat32Sign( a ); - if ( aExp =3D=3D 0xFF ) { - if (aSig) { - return commonNaNToFloat64(float32ToCommonNaN(a, status), statu= s); - } - return packFloat64( aSign, 0x7FF, 0 ); - } - if ( aExp =3D=3D 0 ) { - if ( aSig =3D=3D 0 ) return packFloat64( aSign, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - --aExp; - } - return packFloat64( aSign, aExp + 0x380, ( (uint64_t) aSig )<<29 ); - -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the single-precision floating-point val= ue | `a' to the extended double-precision floating-point format. The convers= ion @@ -3677,173 +3749,6 @@ int float32_unordered_quiet(float32 a, float32 b, f= loat_status *status) return 0; } =20 - -/*------------------------------------------------------------------------= ---- -| Returns the result of converting the double-precision floating-point val= ue -| `a' to the single-precision floating-point format. The conversion is -| performed according to the IEC/IEEE Standard for Binary Floating-Point -| Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -float32 float64_to_float32(float64 a, float_status *status) -{ - flag aSign; - int aExp; - uint64_t aSig; - uint32_t zSig; - a =3D float64_squash_input_denormal(a, status); - - aSig =3D extractFloat64Frac( a ); - aExp =3D extractFloat64Exp( a ); - aSign =3D extractFloat64Sign( a ); - if ( aExp =3D=3D 0x7FF ) { - if (aSig) { - return commonNaNToFloat32(float64ToCommonNaN(a, status), statu= s); - } - return packFloat32( aSign, 0xFF, 0 ); - } - shift64RightJamming( aSig, 22, &aSig ); - zSig =3D aSig; - if ( aExp || zSig ) { - zSig |=3D 0x40000000; - aExp -=3D 0x381; - } - return roundAndPackFloat32(aSign, aExp, zSig, status); - -} - - -/*------------------------------------------------------------------------= ---- -| Packs the sign `zSign', exponent `zExp', and significand `zSig' into a -| half-precision floating-point value, returning the result. After being -| shifted into the proper positions, the three fields are simply added -| together to form the result. This means that any integer portion of `zS= ig' -| will be added into the exponent. Since a properly normalized significand -| will have an integer portion equal to 1, the `zExp' input should be 1 le= ss -| than the desired result exponent whenever `zSig' is a complete, normaliz= ed -| significand. -*-------------------------------------------------------------------------= ---*/ -static float16 packFloat16(flag zSign, int zExp, uint16_t zSig) -{ - return make_float16( - (((uint32_t)zSign) << 15) + (((uint32_t)zExp) << 10) + zSig); -} - -/*------------------------------------------------------------------------= ---- -| Takes an abstract floating-point value having sign `zSign', exponent `zE= xp', -| and significand `zSig', and returns the proper half-precision floating- -| point value corresponding to the abstract input. Ordinarily, the abstra= ct -| value is simply rounded and packed into the half-precision format, with -| the inexact exception raised if the abstract input cannot be represented -| exactly. However, if the abstract value is too large, the overflow and -| inexact exceptions are raised and an infinity or maximal finite value is -| returned. If the abstract value is too small, the input value is rounde= d to -| a subnormal number, and the underflow and inexact exceptions are raised = if -| the abstract input cannot be represented exactly as a subnormal half- -| precision floating-point number. -| The `ieee' flag indicates whether to use IEEE standard half precision, or -| ARM-style "alternative representation", which omits the NaN and Inf -| encodings in order to raise the maximum representable exponent by one. -| The input significand `zSig' has its binary point between bits 22 -| and 23, which is 13 bits to the left of the usual location. This shifted -| significand must be normalized or smaller. If `zSig' is not normalized, -| `zExp' must be 0; in that case, the result returned is a subnormal numbe= r, -| and it must not require rounding. In the usual case that `zSig' is -| normalized, `zExp' must be 1 less than the ``true'' floating-point expon= ent. -| Note the slightly odd position of the binary point in zSig compared with= the -| other roundAndPackFloat functions. This should probably be fixed if we -| need to implement more float16 routines than just conversion. -| The handling of underflow and overflow follows the IEC/IEEE Standard for -| Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -static float16 roundAndPackFloat16(flag zSign, int zExp, - uint32_t zSig, flag ieee, - float_status *status) -{ - int maxexp =3D ieee ? 29 : 30; - uint32_t mask; - uint32_t increment; - bool rounding_bumps_exp; - bool is_tiny =3D false; - - /* Calculate the mask of bits of the mantissa which are not - * representable in half-precision and will be lost. - */ - if (zExp < 1) { - /* Will be denormal in halfprec */ - mask =3D 0x00ffffff; - if (zExp >=3D -11) { - mask >>=3D 11 + zExp; - } - } else { - /* Normal number in halfprec */ - mask =3D 0x00001fff; - } - - switch (status->float_rounding_mode) { - case float_round_nearest_even: - increment =3D (mask + 1) >> 1; - if ((zSig & mask) =3D=3D increment) { - increment =3D zSig & (increment << 1); - } - break; - case float_round_ties_away: - increment =3D (mask + 1) >> 1; - break; - case float_round_up: - increment =3D zSign ? 0 : mask; - break; - case float_round_down: - increment =3D zSign ? mask : 0; - break; - default: /* round_to_zero */ - increment =3D 0; - break; - } - - rounding_bumps_exp =3D (zSig + increment >=3D 0x01000000); - - if (zExp > maxexp || (zExp =3D=3D maxexp && rounding_bumps_exp)) { - if (ieee) { - float_raise(float_flag_overflow | float_flag_inexact, status); - return packFloat16(zSign, 0x1f, 0); - } else { - float_raise(float_flag_invalid, status); - return packFloat16(zSign, 0x1f, 0x3ff); - } - } - - if (zExp < 0) { - /* Note that flush-to-zero does not affect half-precision results = */ - is_tiny =3D - (status->float_detect_tininess =3D=3D float_tininess_before_ro= unding) - || (zExp < -1) - || (!rounding_bumps_exp); - } - if (zSig & mask) { - float_raise(float_flag_inexact, status); - if (is_tiny) { - float_raise(float_flag_underflow, status); - } - } - - zSig +=3D increment; - if (rounding_bumps_exp) { - zSig >>=3D 1; - zExp++; - } - - if (zExp < -10) { - return packFloat16(zSign, 0, 0); - } - if (zExp < 0) { - zSig >>=3D -zExp; - zExp =3D 0; - } - 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 valu= e. @@ -3859,163 +3764,6 @@ float16 float16_squash_input_denormal(float16 a, fl= oat_status *status) return a; } =20 -static void normalizeFloat16Subnormal(uint32_t aSig, int *zExpPtr, - uint32_t *zSigPtr) -{ - int8_t shiftCount =3D countLeadingZeros32(aSig) - 21; - *zSigPtr =3D aSig << shiftCount; - *zExpPtr =3D 1 - shiftCount; -} - -/* Half precision floats come in two formats: standard IEEE and "ARM" form= at. - The latter gains extra exponent range by omitting the NaN/Inf encodings= . */ - -float32 float16_to_float32(float16 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - - aSign =3D extractFloat16Sign(a); - aExp =3D extractFloat16Exp(a); - aSig =3D extractFloat16Frac(a); - - if (aExp =3D=3D 0x1f && ieee) { - if (aSig) { - return commonNaNToFloat32(float16ToCommonNaN(a, status), statu= s); - } - return packFloat32(aSign, 0xff, 0); - } - if (aExp =3D=3D 0) { - if (aSig =3D=3D 0) { - return packFloat32(aSign, 0, 0); - } - - normalizeFloat16Subnormal(aSig, &aExp, &aSig); - aExp--; - } - return packFloat32( aSign, aExp + 0x70, aSig << 13); -} - -float16 float32_to_float16(float32 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - - a =3D float32_squash_input_denormal(a, status); - - aSig =3D extractFloat32Frac( a ); - aExp =3D extractFloat32Exp( a ); - aSign =3D extractFloat32Sign( a ); - if ( aExp =3D=3D 0xFF ) { - if (aSig) { - /* Input is a NaN */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0, 0); - } - return commonNaNToFloat16( - float32ToCommonNaN(a, status), status); - } - /* Infinity */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0x1f, 0x3ff); - } - return packFloat16(aSign, 0x1f, 0); - } - if (aExp =3D=3D 0 && aSig =3D=3D 0) { - return packFloat16(aSign, 0, 0); - } - /* Decimal point between bits 22 and 23. Note that we add the 1 bit - * even if the input is denormal; however this is harmless because - * the largest possible single-precision denormal is still smaller - * than the smallest representable half-precision denormal, and so we - * will end up ignoring aSig and returning via the "always return zero" - * codepath. - */ - aSig |=3D 0x00800000; - aExp -=3D 0x71; - - return roundAndPackFloat16(aSign, aExp, aSig, ieee, status); -} - -float64 float16_to_float64(float16 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - - aSign =3D extractFloat16Sign(a); - aExp =3D extractFloat16Exp(a); - aSig =3D extractFloat16Frac(a); - - if (aExp =3D=3D 0x1f && ieee) { - if (aSig) { - return commonNaNToFloat64( - float16ToCommonNaN(a, status), status); - } - return packFloat64(aSign, 0x7ff, 0); - } - if (aExp =3D=3D 0) { - if (aSig =3D=3D 0) { - return packFloat64(aSign, 0, 0); - } - - normalizeFloat16Subnormal(aSig, &aExp, &aSig); - aExp--; - } - return packFloat64(aSign, aExp + 0x3f0, ((uint64_t)aSig) << 42); -} - -float16 float64_to_float16(float64 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint64_t aSig; - uint32_t zSig; - - a =3D float64_squash_input_denormal(a, status); - - aSig =3D extractFloat64Frac(a); - aExp =3D extractFloat64Exp(a); - aSign =3D extractFloat64Sign(a); - if (aExp =3D=3D 0x7FF) { - if (aSig) { - /* Input is a NaN */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0, 0); - } - return commonNaNToFloat16( - float64ToCommonNaN(a, status), status); - } - /* Infinity */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0x1f, 0x3ff); - } - return packFloat16(aSign, 0x1f, 0); - } - shift64RightJamming(aSig, 29, &aSig); - zSig =3D aSig; - if (aExp =3D=3D 0 && zSig =3D=3D 0) { - return packFloat16(aSign, 0, 0); - } - /* Decimal point between bits 22 and 23. Note that we add the 1 bit - * even if the input is denormal; however this is harmless because - * the largest possible single-precision denormal is still smaller - * than the smallest representable half-precision denormal, and so we - * will end up ignoring aSig and returning via the "always return zero" - * codepath. - */ - zSig |=3D 0x00800000; - aExp -=3D 0x3F1; - - return roundAndPackFloat16(aSign, aExp, zSig, ieee, status); -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the double-precision floating-point val= ue | `a' to the extended double-precision floating-point format. The convers= ion --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487172113671.3494878501392; Wed, 16 May 2018 09:12:52 -0700 (PDT) Received: from localhost ([::1]:53335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz2g-0003Hh-Ok for importer@patchew.org; Wed, 16 May 2018 12:12:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjl-0004Tt-E9 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyji-00054k-7d for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:09 -0400 Received: from mail-pl0-x229.google.com ([2607:f8b0:400e:c01::229]:37295) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyji-00054U-1c for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:06 -0400 Received: by mail-pl0-x229.google.com with SMTP id w19-v6so672076plq.4 for ; Wed, 16 May 2018 08:53:05 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:03 -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=HCzhOWHu2+7g6xUjsUPmKAtx3rgdm8J3LWpkOAk/KmQ=; b=NkVg6V9kJXUH3/S4HEj1rAxuzDY2tnpE+ZNrsb2r3TNe2a/wJ4LAmLuOG0X/PRDnhy 0AEzsEfe1vFm4rvDOvUopZwTl3V/xzHxmMuY+dy6ATTvG8SSDL+Uymtma8zkY04i8vlj n/lo5bcYt7qKg9DUz2zbmssl/Os91fr+FuLDM= 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=HCzhOWHu2+7g6xUjsUPmKAtx3rgdm8J3LWpkOAk/KmQ=; b=PfRgPb9DxifTKS/fHVq6a03g6xTZ5q+IO7ml8FNY9dvoKeh+Wn5pHiPC/4XY/9t8ie 9raUUh1Q/CY5c841ZB+bKMt5lJZgLiX7OrjkPYHj2hzM/e0/flpYG59i/0lHQnVd6pd/ 2GCGKiE8/jOp/Z9qT3cN3rYue6TN5jll6YiItJ1x+4KqjD0xS+2DoWbEAf4KakaFox+1 eZ/xwkrnprvuluX6u62q4+SEaMxxggWZWPxUArgDT+bq/mqL8kyiF0eGuybv08Y4jlMA 8z7Oz82nhYRX7ejliAj3YWTBXUCMiNlvAAC85fgv9Q1wDrijG2kHy3XwhLQx4bHQChPW 6f0w== X-Gm-Message-State: ALKqPwe+ybZmhpB8bNoLPbNJToz34usDIj/WdXNoq5w1Z7VzRe6y0LdT sniO5TYoCZtPl6ps/FmMZVmHYDjNo5w= X-Google-Smtp-Source: AB8JxZpsRmFU6u6tB1q+VJNm5lZ1T1CATGRBrIQtncBcI1x65ZkTU2aP6UhpBQ726GZisGIBzZXyKg== X-Received: by 2002:a17:902:321:: with SMTP id 30-v6mr1482304pld.122.1526485984676; Wed, 16 May 2018 08:53:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:28 -0700 Message-Id: <20180516155243.16937-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::229 Subject: [Qemu-devel] [PULL 13/28] target/arm: Use floatX_silence_nan when we have already checked for SNaN 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 6 +++--- target/arm/helper.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 4f8034c513..6f0eb83661 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -376,7 +376,7 @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp) float16 nan =3D a; if (float16_is_signaling_nan(a, fpst)) { float_raise(float_flag_invalid, fpst); - nan =3D float16_maybe_silence_nan(a, fpst); + nan =3D float16_silence_nan(a, fpst); } if (fpst->default_nan_mode) { nan =3D float16_default_nan(fpst); @@ -405,7 +405,7 @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) float32 nan =3D a; if (float32_is_signaling_nan(a, fpst)) { float_raise(float_flag_invalid, fpst); - nan =3D float32_maybe_silence_nan(a, fpst); + nan =3D float32_silence_nan(a, fpst); } if (fpst->default_nan_mode) { nan =3D float32_default_nan(fpst); @@ -434,7 +434,7 @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) float64 nan =3D a; if (float64_is_signaling_nan(a, fpst)) { float_raise(float_flag_invalid, fpst); - nan =3D float64_maybe_silence_nan(a, fpst); + nan =3D float64_silence_nan(a, fpst); } if (fpst->default_nan_mode) { nan =3D float64_default_nan(fpst); diff --git a/target/arm/helper.c b/target/arm/helper.c index 238a3ceba8..e05c7230d4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11731,7 +11731,7 @@ float16 HELPER(recpe_f16)(float16 input, void *fpst= p) float16 nan =3D f16; if (float16_is_signaling_nan(f16, fpst)) { float_raise(float_flag_invalid, fpst); - nan =3D float16_maybe_silence_nan(f16, fpst); + nan =3D float16_silence_nan(f16, fpst); } if (fpst->default_nan_mode) { nan =3D float16_default_nan(fpst); @@ -11779,7 +11779,7 @@ float32 HELPER(recpe_f32)(float32 input, void *fpst= p) float32 nan =3D f32; if (float32_is_signaling_nan(f32, fpst)) { float_raise(float_flag_invalid, fpst); - nan =3D float32_maybe_silence_nan(f32, fpst); + nan =3D float32_silence_nan(f32, fpst); } if (fpst->default_nan_mode) { nan =3D float32_default_nan(fpst); @@ -11827,7 +11827,7 @@ float64 HELPER(recpe_f64)(float64 input, void *fpst= p) float64 nan =3D f64; if (float64_is_signaling_nan(f64, fpst)) { float_raise(float_flag_invalid, fpst); - nan =3D float64_maybe_silence_nan(f64, fpst); + nan =3D float64_silence_nan(f64, fpst); } if (fpst->default_nan_mode) { nan =3D float64_default_nan(fpst); @@ -11926,7 +11926,7 @@ float16 HELPER(rsqrte_f16)(float16 input, void *fps= tp) float16 nan =3D f16; if (float16_is_signaling_nan(f16, s)) { float_raise(float_flag_invalid, s); - nan =3D float16_maybe_silence_nan(f16, s); + nan =3D float16_silence_nan(f16, s); } if (s->default_nan_mode) { nan =3D float16_default_nan(s); @@ -11970,7 +11970,7 @@ float32 HELPER(rsqrte_f32)(float32 input, void *fps= tp) float32 nan =3D f32; if (float32_is_signaling_nan(f32, s)) { float_raise(float_flag_invalid, s); - nan =3D float32_maybe_silence_nan(f32, s); + nan =3D float32_silence_nan(f32, s); } if (s->default_nan_mode) { nan =3D float32_default_nan(s); @@ -12013,7 +12013,7 @@ float64 HELPER(rsqrte_f64)(float64 input, void *fps= tp) float64 nan =3D f64; if (float64_is_signaling_nan(f64, s)) { float_raise(float_flag_invalid, s); - nan =3D float64_maybe_silence_nan(f64, s); + nan =3D float64_silence_nan(f64, s); } if (s->default_nan_mode) { nan =3D float64_default_nan(s); --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486990721111.04364980483501; Wed, 16 May 2018 09:09:50 -0700 (PDT) Received: from localhost ([::1]:53221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyzt-0000iW-U3 for importer@patchew.org; Wed, 16 May 2018 12:09:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjl-0004Tu-E7 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjj-000558-KC for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:09 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:40499) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjj-00054y-EW for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:07 -0400 Received: by mail-pl0-x242.google.com with SMTP id t12-v6so667440plo.7 for ; Wed, 16 May 2018 08:53:07 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:05 -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=cSZ33bwDEVkNnz6+2oRZOYUtCrbSKbPYkMTqNAn1iAA=; b=Dp1FFT4qSc3B7EMp27YGnq1ZkZeUIy92hBiIsTQ8bflVsS9UbdJWFb/KK1E7Es8HmB DaaseXVV9La+kGMtUuIr2y/u589M6FSFr0AZwGpFkInjlFRW5Nu0g1dzxyJHpBAaiaZv tkcvOK8kClfEuqjVfP+iBGxAY/pu58vI/t4mQ= 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=cSZ33bwDEVkNnz6+2oRZOYUtCrbSKbPYkMTqNAn1iAA=; b=dsFDmM+RU6c6guDsEVXnz+RwrXiwwvLdmSlote7WLiQ2E54Dlf/9sR7L3oU7uq57DZ QprliC2FR7L35/BS29N2USiUb19c6Z9p66+OZM/Z7gYrNy81tLauXB03eewX+1ry0FwK bgKMdfzNuXfHwvl1PT5drI0FaBB9XA5054ubr7yusGhgxkpJBsjuTNxkcLTNjhlKPpST KwlZu04/MxGx8eJI8Hoa7RJdfhbcK1f2ryQdN866yzlChoz7+vBykOYk6Zj4fU1jHAWB JC5DU2GFhNxhh11Tdl1ItkYshIvGx4QIxrZv9+7qTr2a8ZvKP8zKEYzjpK5/gkKigze2 lwhg== X-Gm-Message-State: ALKqPweA4blmXgc+wii/zjjknJO3FYBeoDeT4bmfvGojiy4831O9bUEj 3s5t1wYM8YjoqZGNsP3HeSde+00qoag= X-Google-Smtp-Source: AB8JxZrl9np5esjY1paNihWzb9Pc4bxgg7z4vapJYBCNqqOOzP3fnMdIlOdV6uOF+iJbTngfKbV0YA== X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr1498860pls.270.1526485986121; Wed, 16 May 2018 08:53:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:29 -0700 Message-Id: <20180516155243.16937-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL 14/28] target/arm: Remove floatX_maybe_silence_nan from conversions 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This is now handled properly by the generic softfloat code. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 1 - target/arm/helper.c | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 6f0eb83661..f92bdea732 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -466,7 +466,6 @@ float32 HELPER(fcvtx_f64_to_f32)(float64 a, CPUARMState= *env) set_float_rounding_mode(float_round_to_zero, &tstat); set_float_exception_flags(0, &tstat); r =3D float64_to_float32(a, &tstat); - r =3D float32_maybe_silence_nan(r, &tstat); exflags =3D get_float_exception_flags(&tstat); if (exflags & float_flag_inexact) { r =3D make_float32(float32_val(r) | 1); diff --git a/target/arm/helper.c b/target/arm/helper.c index e05c7230d4..db8bbe52a6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11348,20 +11348,12 @@ FLOAT_CONVS(ui, d, 64, u) /* floating point conversion */ float64 VFP_HELPER(fcvtd, s)(float32 x, CPUARMState *env) { - float64 r =3D float32_to_float64(x, &env->vfp.fp_status); - /* ARM requires that S<->D conversion of any kind of NaN generates - * a quiet NaN by forcing the most significant frac bit to 1. - */ - return float64_maybe_silence_nan(r, &env->vfp.fp_status); + return float32_to_float64(x, &env->vfp.fp_status); } =20 float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) { - float32 r =3D float64_to_float32(x, &env->vfp.fp_status); - /* ARM requires that S<->D conversion of any kind of NaN generates - * a quiet NaN by forcing the most significant frac bit to 1. - */ - return float32_maybe_silence_nan(r, &env->vfp.fp_status); + return float64_to_float32(x, &env->vfp.fp_status); } =20 /* VFP3 fixed point conversion. */ --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487452752512.9909010721482; Wed, 16 May 2018 09:17:32 -0700 (PDT) Received: from localhost ([::1]:53599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz7H-0007KM-Fv for importer@patchew.org; Wed, 16 May 2018 12:17:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjl-0004UP-Qx for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjl-00055p-43 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:09 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:45711) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjk-00055X-U7 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:09 -0400 Received: by mail-pl0-x242.google.com with SMTP id bi12-v6so661529plb.12 for ; Wed, 16 May 2018 08:53:08 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:06 -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=TD/lOXrmVofLedG4op9ymEqylnQt6zN7ClswSrkMaZc=; b=PkVGOgVDquUxQsvF+RvCCS9QnTU0kYwxAwazQgK2b4SAXZTK+mH/5tiXZmizujJJAG rZlG9o1ljpmq8eogrsjiCVIenn5XDvHQFYYfOIUEKgBi6ghOZMa4y2XIq7MrL5nDbfhU YD1Rao7pHyXx0cfmr1luVCfoyKD0uaIUeGGis= 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=TD/lOXrmVofLedG4op9ymEqylnQt6zN7ClswSrkMaZc=; b=qxk4lJx0/nxGFOqkEpTwLEGhPGh2a1g/hMZIC75YZKJpekrFTlCO7kIbn5p0a/kURc u4yW93mEcNBsSYgB1FmhTUhHwgFfTp2tCq3tVTWdrnwqKMZHgkEJEuEhnUHKN9UJTG89 D29XKnWEP5i0OYgMdEOjOmhc3fxRXITfZFIS/XMLNwGhLnZRNt8nAfJxtsOsf5V03eId tWzfSFjukdzz8onupB5SEDafap5+M6rrRVg6jWige58v97ZKoa3sggkfwiy8p+tC86SQ /2OHeoJ4w8bj2R9UyH/4acW63SrALv+5HuL9ZuCqK51vP05M42uvUGzz+8mRtQvOiBY7 OVzQ== X-Gm-Message-State: ALKqPwdbUl+K6d9M1G6q/J8zU1plCadrfl7QZ9Ds22D5zcmNwy+yrn8i SU1XAW86f1Y2IJ5SCQwrUzSi/6eh60c= X-Google-Smtp-Source: AB8JxZquR7l0KyWWSyO7ujaK+rN8GkDecylYllIjTFfKZtc7YvsYmHwUu0OKHesIpueDjV8f6Elnfg== X-Received: by 2002:a17:902:6041:: with SMTP id a1-v6mr1453598plt.59.1526485987594; Wed, 16 May 2018 08:53:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:30 -0700 Message-Id: <20180516155243.16937-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PULL 15/28] target/hppa: Remove floatX_maybe_silence_nan from conversions 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 This is now handled properly by the generic softfloat code. Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/hppa/op_helper.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index a3af62daf7..912e8d5be4 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -341,7 +341,6 @@ float64 HELPER(fdiv_d)(CPUHPPAState *env, float64 a, fl= oat64 b) float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg) { float64 ret =3D float32_to_float64(arg, &env->fp_status); - ret =3D float64_maybe_silence_nan(ret, &env->fp_status); update_fr0_op(env, GETPC()); return ret; } @@ -349,7 +348,6 @@ float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg) float32 HELPER(fcnv_d_s)(CPUHPPAState *env, float64 arg) { float32 ret =3D float64_to_float32(arg, &env->fp_status); - ret =3D float32_maybe_silence_nan(ret, &env->fp_status); update_fr0_op(env, GETPC()); return ret; } --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486525904262.8333225449177; Wed, 16 May 2018 09:02:05 -0700 (PDT) Received: from localhost ([::1]:53066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIysP-0002WH-38 for importer@patchew.org; Wed, 16 May 2018 12:02:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjn-0004Vs-7T for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjm-00056Q-CS for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:11 -0400 Received: from mail-pl0-x232.google.com ([2607:f8b0:400e:c01::232]:42634) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjm-00056C-6e for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:10 -0400 Received: by mail-pl0-x232.google.com with SMTP id u6-v6so664517pls.9 for ; Wed, 16 May 2018 08:53:10 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:07 -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; bh=SPBg1TyIEk4O+QgkODhyiPa2jhkA37Z3ZFJ5t7jC9gU=; b=kKMRlWGZ6eYi4vSWp1lP/3KGZL75+wAGFXYeB9+sGUXmP5fgpzTb1CQ+/dIG+KACZu fD4Im7IKD9ore4VhdmqwEj/Q+8/v4dNPe5jbEoh2Dk0DR7yZjrV6KdiC1oZGqtZvfDIy YMcR6E6CJLUeq6bUbit8tbg9WE6KL27SDoATU= 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; bh=SPBg1TyIEk4O+QgkODhyiPa2jhkA37Z3ZFJ5t7jC9gU=; b=G2B6vPj3Z88UW+MB6LTAj9E/egwrFGtKLlwS6ugsjq427zFcBCLCIYU4Gth1UAJhfJ lirR6P9wAM5xoBKRIE4c0BcWGqkok9oxpnuRIMKEe1kY6U9Ofyk5Yg7oVWeEOWgD5oTo EZS0wzhNIs2+sMUFbVnKHkgDVbC/58dATkajGHrbKcOJy7XSum2KCprnqBwQ/1N2FPAo 5W/Rk/heAAzlG38CqZ+N8NKCtasJB9CwTZoort2Sl+zXrTl24+2HXYwaEJW2EkYpXt2P ElgFFjOeP/56L0cNtL97kOYxGiZB1FjpNqQcmRRUxGFtQg/TtsQVqyuvRDAXYTqYzLCK yizw== X-Gm-Message-State: ALKqPwda803/Jis8NdtCTeC4eExDHz5gayLcguQRuxNM8ISaTcQKgAxZ s4OpN5MZYdscYf5HoQa28h4u1WCWTTU= X-Google-Smtp-Source: AB8JxZqzbDvFUVAZAtqU0gPucdeOu5frQdPSCKdbxsxBy6cuuxsHrVLCUDZTHxP/9IJEJIY9KBJw5Q== X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr1469044plg.393.1526485988836; Wed, 16 May 2018 08:53:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:31 -0700 Message-Id: <20180516155243.16937-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::232 Subject: [Qemu-devel] [PULL 16/28] target/m68k: Use floatX_silence_nan when we have already checked for SNaN 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- target/m68k/softfloat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/m68k/softfloat.c b/target/m68k/softfloat.c index d093997219..b45a5e8690 100644 --- a/target/m68k/softfloat.c +++ b/target/m68k/softfloat.c @@ -31,13 +31,14 @@ static floatx80 propagateFloatx80NaNOneArg(floatx80 a, = float_status *status) { if (floatx80_is_signaling_nan(a, status)) { float_raise(float_flag_invalid, status); + a =3D floatx80_silence_nan(a, status); } =20 if (status->default_nan_mode) { return floatx80_default_nan(status); } =20 - return floatx80_maybe_silence_nan(a, status); + return a; } =20 /*------------------------------------------------------------------------= ---- --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487638937997.9343315836943; Wed, 16 May 2018 09:20:38 -0700 (PDT) Received: from localhost ([::1]:53733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzAM-0001Jt-3i for importer@patchew.org; Wed, 16 May 2018 12:20:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjo-0004XR-Lp for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjn-000570-O4 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:12 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:46827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjn-00056d-Hu for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:11 -0400 Received: by mail-pl0-x243.google.com with SMTP id 30-v6so659297pld.13 for ; Wed, 16 May 2018 08:53:11 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:09 -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; bh=YG4WDuvg/nU14CtfIK1nI16sf1EHjyzdnNJh8QSrA1M=; b=ZX/fcsS79ugntUoW/pA5HIV3duT6gMqBogWaSz0IkXw+OdtVFKxc6Llv7ZSQ4zOnrh acjo0cRFc+tibVgcmt9qp3XzIO6sw7cUyji5Stl/HpPBWr2wx/zdSsrIBnzQUwC3dKU8 dwN5hvinAEdobwmu9D2oXbhi1Jc1dkdlfJeEU= 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; bh=YG4WDuvg/nU14CtfIK1nI16sf1EHjyzdnNJh8QSrA1M=; b=gGNenm3RFTu+VdsVZumeGw+Jr0s7bTO9KLr5xtNs3h9ws7HGLrf2v9c9LP/kfMEyLR YjlfIvsk1vTPPGj8p4GTxVqoi1E9k9jDwmi2kyPUgiREWiA3lM+Y4RyvyzMS4q0wIM40 v8qIwa8FclePUo7vHlgY++1leaE5G9Yi79E80XBuDCq9WujvSJlhBrGk+WkMxCDLqB5j GcTHup4QcPQWgrJ2LEpnKyg81ZDVXL4wex0XKSmjoFbI8vMbIN6ofdSNCupwIZcz7i2I 2UlmirhAK/wDTAXZuX0Tt6g5I1BwZiqPY+5dTJ9t4cD2X0JYNNat1QrMIkige/h6sADu OsaQ== X-Gm-Message-State: ALKqPwe6fRNiuCwq2fbulgZ7lFar6iPZs4PMz5Fk1ZhTlgc3IMNU/KlT gOrB12fXHoT/yPW4uE7rkdWeGKZAmQw= X-Google-Smtp-Source: AB8JxZoZXiaVV7siZNBZqVvJSAYuztbCu8BZhYiok1h9zRb8zeogh+21hzxD+Ah8bKwT/cGHWa40Mw== X-Received: by 2002:a17:902:9a8b:: with SMTP id w11-v6mr1461158plp.75.1526485990115; Wed, 16 May 2018 08:53:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:32 -0700 Message-Id: <20180516155243.16937-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PULL 17/28] target/mips: Remove floatX_maybe_silence_nan from conversions 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, Yongbok Kim , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is now handled properly by the generic softfloat code. Cc: Aurelien Jarno Cc: Yongbok Kim Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/mips/msa_helper.c | 4 ---- target/mips/op_helper.c | 2 -- 2 files changed, 6 deletions(-) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 8fb7a369ca..c74e3cdc65 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -1615,7 +1615,6 @@ static inline float16 float16_from_float32(int32_t a,= flag ieee, float16 f_val; =20 f_val =3D float32_to_float16((float32)a, ieee, status); - f_val =3D float16_maybe_silence_nan(f_val, status); =20 return a < 0 ? (f_val | (1 << 15)) : f_val; } @@ -1625,7 +1624,6 @@ static inline float32 float32_from_float64(int64_t a,= float_status *status) float32 f_val; =20 f_val =3D float64_to_float32((float64)a, status); - f_val =3D float32_maybe_silence_nan(f_val, status); =20 return a < 0 ? (f_val | (1 << 31)) : f_val; } @@ -1636,7 +1634,6 @@ static inline float32 float32_from_float16(int16_t a,= flag ieee, float32 f_val; =20 f_val =3D float16_to_float32((float16)a, ieee, status); - f_val =3D float32_maybe_silence_nan(f_val, status); =20 return a < 0 ? (f_val | (1 << 31)) : f_val; } @@ -1646,7 +1643,6 @@ static inline float64 float64_from_float32(int32_t a,= float_status *status) float64 f_val; =20 f_val =3D float32_to_float64((float64)a, status); - f_val =3D float64_maybe_silence_nan(f_val, status); =20 return a < 0 ? (f_val | (1ULL << 63)) : f_val; } diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 798cdad030..9025f42366 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -2700,7 +2700,6 @@ uint64_t helper_float_cvtd_s(CPUMIPSState *env, uint3= 2_t fst0) uint64_t fdt2; =20 fdt2 =3D float32_to_float64(fst0, &env->active_fpu.fp_status); - fdt2 =3D float64_maybe_silence_nan(fdt2, &env->active_fpu.fp_status); update_fcr31(env, GETPC()); return fdt2; } @@ -2790,7 +2789,6 @@ uint32_t helper_float_cvts_d(CPUMIPSState *env, uint6= 4_t fdt0) uint32_t fst2; =20 fst2 =3D float64_to_float32(fdt0, &env->active_fpu.fp_status); - fst2 =3D float32_maybe_silence_nan(fst2, &env->active_fpu.fp_status); update_fcr31(env, GETPC()); return fst2; } --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526486744736934.1050202038737; Wed, 16 May 2018 09:05:44 -0700 (PDT) Received: from localhost ([::1]:53103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyvv-000523-8k for importer@patchew.org; Wed, 16 May 2018 12:05:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjp-0004Z3-TB for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjp-00057E-0J for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:13 -0400 Received: from mail-pl0-x229.google.com ([2607:f8b0:400e:c01::229]:46628) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjo-000575-Qt for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:12 -0400 Received: by mail-pl0-x229.google.com with SMTP id 30-v6so659327pld.13 for ; Wed, 16 May 2018 08:53:12 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:10 -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; bh=lFbjHgIjVdntVwEG8TX8Zn/QYQH/a160DBSlPiGyBN4=; b=DSLRegSy4815clU7Yl3C7RG6zhcAIQ/7o51PiQjj2+qWdRaTd/ZCdsaGxJCBD5LKgZ 6lAkmE1J4JeUB/q6rMNi2D2OEVOllzDfUVwvMUiR0nQHMmzgHOqB1/bkhcT15kxJwSRL FjQOiv5aogU2yEPnKfFefggDeogPBsjlOlgBo= 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; bh=lFbjHgIjVdntVwEG8TX8Zn/QYQH/a160DBSlPiGyBN4=; b=UoFy0znhL1eL+neWXI9fu6C+Xb1onYE1khvyFJv9Rw1lY0YvT6VQN6KKZ6RTh4sStz mKLujrqKR+HXX/4+kGGSA9X7bkzcqzgVe/9xNxnXLwDLSrYBkhZRoOMAg5V1gBCFJgd2 WiqZJWv4HC1FP6IySHwPloMPEmumA5FYeaBp6vFafcLPH37ritiinB8q0+j5BP7O4ieb ET/n7mNyzrcq+Hf/U8Ctz/Z6DLrA9QhvRb+6FS4jE3bkjYdbrJRJ++58xungFUNBaN21 RUiOl2CwKDXyU6EP5YmBPARzB4yqd6ZmNDOUlcYvSc35Ax3AZktXzWHeyKkaKQJdSmp+ tufA== X-Gm-Message-State: ALKqPweJAAL3M7pp5UzGGZZZPS7oJAB7vssD78/84tnCOqMwjJMqE3rs BGBmjQCdHWq5BIjcAja5SExUWVBmT/k= X-Google-Smtp-Source: AB8JxZqbrpPaVm+PuWB/KrKh2LVSG7u73geQYA80UF+d7/524Ce8YA8ZqHUwP2xJxttgj/eAYVgUaw== X-Received: by 2002:a17:902:265:: with SMTP id 92-v6mr1436187plc.368.1526485991508; Wed, 16 May 2018 08:53:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:33 -0700 Message-Id: <20180516155243.16937-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::229 Subject: [Qemu-devel] [PULL 18/28] target/riscv: Remove floatX_maybe_silence_nan from conversions 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, Palmer Dabbelt , Sagar Karandikar , Bastian Koppelmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is now handled properly by the generic softfloat code. Cc: Palmer Dabbelt Cc: Sagar Karandikar Cc: Bastian Koppelmann Reviewed-by: Michael Clark Signed-off-by: Richard Henderson --- target/riscv/fpu_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index abbadead5c..fdb87d8d82 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -279,14 +279,12 @@ uint64_t helper_fmax_d(CPURISCVState *env, uint64_t f= rs1, uint64_t frs2) =20 uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t rs1) { - rs1 =3D float64_to_float32(rs1, &env->fp_status); - return float32_maybe_silence_nan(rs1, &env->fp_status); + return float64_to_float32(rs1, &env->fp_status); } =20 uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1) { - rs1 =3D float32_to_float64(rs1, &env->fp_status); - return float64_maybe_silence_nan(rs1, &env->fp_status); + return float32_to_float64(rs1, &env->fp_status); } =20 uint64_t helper_fsqrt_d(CPURISCVState *env, uint64_t frs1) --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15264869404581015.1092751345022; Wed, 16 May 2018 09:09:00 -0700 (PDT) Received: from localhost ([::1]:53220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyz5-0008LB-Im for importer@patchew.org; Wed, 16 May 2018 12:08:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjr-0004aY-E7 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjq-00057W-IJ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:15 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:42195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjq-00057K-CY for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:14 -0400 Received: by mail-pl0-x244.google.com with SMTP id u6-v6so664617pls.9 for ; Wed, 16 May 2018 08:53:14 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:12 -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; bh=N/MQDXmC5P0rKEPWLGL6olcs6gD/4PAiety6G0UTpec=; b=X+Dv0iLkdyk/7V0n+yqmKYYVHrDXpI0Q1yinXoHL7rpZPY230tpRnbysVsn0NpGYLf u4rkpcmA9sDpsI6iXbgI6wA57ASVlibYWIerVZQ4KZ7QXGmAf9MlFdBTXF5NzHDDmMn7 yWVLK0rm7CLNaKmQa3PdmKgP77Kqm37T+NnNw= 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; bh=N/MQDXmC5P0rKEPWLGL6olcs6gD/4PAiety6G0UTpec=; b=G1yUbW31rh37QarP9Mcc/idsBTpD/pXaaYLySsiukyh16+B92wKpmvixpEgagqAYgm vqxgp/VzMBwgz0GlEX8jeW9i0iWPMAYwHDjDUKBmgijFrYLf0Do9j1Qpk+cZx7vDTAQX jRYprYo311xOBPbZ2P1eyGlU+W2kjgQxeClmEANghQ2PUkmEZ6Aycy3WRXG3rpcflAr8 D0JEAPqBsLquPCJ7BgLtlfk7OX8sbJY+T88PQ8nVaHBzuB/lp5YO/TYR3LKskamaaKBe tLJOokqIpJZ8gHM2vnwqHgLLKFUapQtZ7Fs4Ksy5oXnr94JkJSGREYO9DgSARWgS02Xe kpwA== X-Gm-Message-State: ALKqPwdUI/H0OjYXyBmcoksCMgXlEi4Xa056Ssz1olnP+ZmjGJ0vQx0A e7QKMuf5jnDAizv2vxLS6gAEuWuTCaI= X-Google-Smtp-Source: AB8JxZo7ULA6HNDVcgrrPxbL4tbSofGywhH5gdakX9L7rzeT8DTWtRS0ImqQjpffL8UvN+GjmrZGIA== X-Received: by 2002:a17:902:bc84:: with SMTP id bb4-v6mr1459237plb.84.1526485992901; Wed, 16 May 2018 08:53:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:34 -0700 Message-Id: <20180516155243.16937-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PULL 19/28] target/s390x: Remove floatX_maybe_silence_nan from conversions 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, Alexander Graf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is now handled properly by the generic softfloat code. Cc: Alexander Graf Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/fpu_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c index 43f8bf1c94..5c5b451b3b 100644 --- a/target/s390x/fpu_helper.c +++ b/target/s390x/fpu_helper.c @@ -269,7 +269,7 @@ uint64_t HELPER(ldeb)(CPUS390XState *env, uint64_t f2) { float64 ret =3D float32_to_float64(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return float64_maybe_silence_nan(ret, &env->fpu_status); + return ret; } =20 /* convert 128-bit float to 64-bit float */ @@ -277,7 +277,7 @@ uint64_t HELPER(ldxb)(CPUS390XState *env, uint64_t ah, = uint64_t al) { float64 ret =3D float128_to_float64(make_float128(ah, al), &env->fpu_s= tatus); handle_exceptions(env, GETPC()); - return float64_maybe_silence_nan(ret, &env->fpu_status); + return ret; } =20 /* convert 64-bit float to 128-bit float */ @@ -285,7 +285,7 @@ uint64_t HELPER(lxdb)(CPUS390XState *env, uint64_t f2) { float128 ret =3D float64_to_float128(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return RET128(float128_maybe_silence_nan(ret, &env->fpu_status)); + return RET128(ret); } =20 /* convert 32-bit float to 128-bit float */ @@ -293,7 +293,7 @@ uint64_t HELPER(lxeb)(CPUS390XState *env, uint64_t f2) { float128 ret =3D float32_to_float128(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return RET128(float128_maybe_silence_nan(ret, &env->fpu_status)); + return RET128(ret); } =20 /* convert 64-bit float to 32-bit float */ @@ -301,7 +301,7 @@ uint64_t HELPER(ledb)(CPUS390XState *env, uint64_t f2) { float32 ret =3D float64_to_float32(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return float32_maybe_silence_nan(ret, &env->fpu_status); + return ret; } =20 /* convert 128-bit float to 32-bit float */ @@ -309,7 +309,7 @@ uint64_t HELPER(lexb)(CPUS390XState *env, uint64_t ah, = uint64_t al) { float32 ret =3D float128_to_float32(make_float128(ah, al), &env->fpu_s= tatus); handle_exceptions(env, GETPC()); - return float32_maybe_silence_nan(ret, &env->fpu_status); + return ret; } =20 /* 32-bit FP compare */ --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487799573221.83265609372575; Wed, 16 May 2018 09:23:19 -0700 (PDT) Received: from localhost ([::1]:53841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzCv-0003Rn-ME for importer@patchew.org; Wed, 16 May 2018 12:23:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyju-0004dx-PQ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjr-00057q-Rt for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:18 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:34317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjr-00057i-MJ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:15 -0400 Received: by mail-pl0-x243.google.com with SMTP id ay10-v6so676683plb.1 for ; Wed, 16 May 2018 08:53:15 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:13 -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=h62BzzH4LLhuXxYTEWEspmGWZCobGiYio26vYR2atOs=; b=BQTWQtjaUf5kK2HhyTo/A14UEc5Mlvx7r59SiOiI6cngY0KbUYzS/v2ISb+ObQYF27 0O3pAsD2gO6EdjMhAJvcH13UmNmY8LGJqlMuMm+4+qCJNhz2PpEtg7U1eMxhV6J7tbWR HxYpkbgJlOC8w7LZkF1Ppih1nK9XJfs9pstxo= 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=h62BzzH4LLhuXxYTEWEspmGWZCobGiYio26vYR2atOs=; b=HFDIgPtALb/oRYHeEJIS7pJOXfSH1AgXyddjnmofNJl+206lP2BZgGSz2KuTOmoNr7 72ut4c8SaZWNboTdYn2un7qEmiFgENPMDrp2ntZ/DTYTb2I9vBnqUb23+gX+2SNfYZwf WZynHB1NXqRh42wYcNRfYJzNGwvXpWXF0bynGuOcJ3JGtrXl1CKdJhEFMTSr7VOvEFIP mI2MsziAe9sVZ/KZ+vWZu2NzLRvR2UOPRaQMWnYbifFTDzSMHj797NdIrHayQ8LkRtUz 766gFv11FIgruF7jrAg7tB66vK46tcKTdtBlD+GdWXFUr7oY3qFNz9qJGn2ma6qzIORB +ZSw== X-Gm-Message-State: ALKqPwfzQ1cRCdGd32ZA6zvehtEG7/hVG/s0gYyfOrZvx30C8EnptKPU YdVGQPOTPg6MAyJUHJYuvHKDJdiimGI= X-Google-Smtp-Source: AB8JxZptLDFO7JBMFVB/XDpEePFMQ77xDplNMdG/2ThLqhQEJTbEb+JgPPaoVbfPfAQdKF+8Xy+U8g== X-Received: by 2002:a17:902:3c5:: with SMTP id d63-v6mr1415705pld.163.1526485994311; Wed, 16 May 2018 08:53:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:35 -0700 Message-Id: <20180516155243.16937-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PULL 20/28] fpu/softfloat: Use float*_silence_nan in propagateFloat*NaN 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 We have already checked the arguments for SNaN; we don't need to do it again. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 44 +++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 995a0132c6..4fa068a5dc 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -498,7 +498,7 @@ static float32 commonNaNToFloat32(commonNaNT a, float_s= tatus *status) | The routine is passed various bits of information about the | two NaNs and should return 0 to select NaN a and 1 for NaN b. | Note that signalling NaNs are always squashed to quiet NaNs -| by the caller, by calling floatXX_maybe_silence_nan() before +| by the caller, by calling floatXX_silence_nan() before | returning them. | | aIsLargerSignificand is only valid if both a and b are NaNs @@ -536,7 +536,7 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIs= QNaN, flag bIsSNaN, { /* According to MIPS specifications, if one of the two operands is * a sNaN, a new qNaN has to be generated. This is done in - * floatXX_maybe_silence_nan(). For qNaN inputs the specifications + * floatXX_silence_nan(). For qNaN inputs the specifications * says: "When possible, this QNaN result is one of the operand QNaN * values." In practice it seems that most implementations choose * the first operand if both operands are qNaN. In short this gives @@ -788,9 +788,15 @@ static float32 propagateFloat32NaN(float32 a, float32 = b, float_status *status) =20 if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return float32_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return float32_silence_nan(b, status); + } + return b; } else { - return float32_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return float32_silence_nan(a, status); + } + return a; } } =20 @@ -950,9 +956,15 @@ static float64 propagateFloat64NaN(float64 a, float64 = b, float_status *status) =20 if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return float64_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return float64_silence_nan(b, status); + } + return b; } else { - return float64_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return float64_silence_nan(a, status); + } + return a; } } =20 @@ -1121,9 +1133,15 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b= , float_status *status) =20 if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return floatx80_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return floatx80_silence_nan(b, status); + } + return b; } else { - return floatx80_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return floatx80_silence_nan(a, status); + } + return a; } } =20 @@ -1270,8 +1288,14 @@ static float128 propagateFloat128NaN(float128 a, flo= at128 b, =20 if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return float128_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return float128_silence_nan(b, status); + } + return b; } else { - return float128_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return float128_silence_nan(a, status); + } + return a; } } --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15264879551151008.7816456647989; Wed, 16 May 2018 09:25:55 -0700 (PDT) Received: from localhost ([::1]:53974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzFS-0005d4-8O for importer@patchew.org; Wed, 16 May 2018 12:25:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyju-0004dw-PQ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjt-00058G-B6 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:18 -0400 Received: from mail-pl0-x234.google.com ([2607:f8b0:400e:c01::234]:45782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjt-000580-2m for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:17 -0400 Received: by mail-pl0-x234.google.com with SMTP id bi12-v6so661735plb.12 for ; Wed, 16 May 2018 08:53:16 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:14 -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=RsqR6JXjuFwzF6uI5jtDfE8pIEemv36hmgqjkM16TQs=; b=CELl1lEod6YPPn0j2OdDVz++GtCw3nhjM8HBDebAzChyeBHrVP3EoYEmh86T0MONXt 4+TVtPqXkH1QT+XclmU0qxDfaAmf7gdt2J0MLMx+z8s2bPJDFaTW26fJQzI8dl0RocMG valB3eCqDT1budxEMo3x1dYIxiXl1fZYAbuvE= 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=RsqR6JXjuFwzF6uI5jtDfE8pIEemv36hmgqjkM16TQs=; b=UOLDrKAp+0JUOy7xH7pmGeR1QEIFjvsIvNJp+KNkB5lIhmyw0auh2WR0pIlnpEL7C2 3pAP5IH4TG9yyAUhWsY/fCEWsFlTYEzhs6n16LvuSq96I6jnQvt14vBaQG7ivcbDpYtE 9nJjUCSOwQurVzjYk/c9lg5+NEXpBi4SLNBnt2G7TO2I2grrlBlRJVS5ORIKGH7I2QYu URM2fydr1E7Nc8rE6tThmuZphS5Xeqw7yd0fA3eUfKclO9OQjFjPu2fv0EjEsl4yJbGB F/RAmTBjo2tNLvK8pXJs6c6YV5hd1ZP4keSPOARQtCkK/if0Mi7bpoa1C5dF0J6TTxQl EO+g== X-Gm-Message-State: ALKqPwcGoMDkwfavFOEb8HQSP/jHC/pOeUTd0n7hAo4lrQyyegnIUp2r ePG7MICKI9SsKCBcg4lzvFs2brscwZg= X-Google-Smtp-Source: AB8JxZrhDUmwgTj5aWkLT0ciSfnBIyGeKxF9+wriLXJMn2ihUGredIERW8mfAm9Q/1406UkqJk7+uQ== X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr1495750plv.176.1526485995603; Wed, 16 May 2018 08:53:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:36 -0700 Message-Id: <20180516155243.16937-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::234 Subject: [Qemu-devel] [PULL 21/28] fpu/softfloat: Remove floatX_maybe_silence_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 These functions are now unused. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 63 -------------------------------------- include/fpu/softfloat.h | 5 --- 2 files changed, 68 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 4fa068a5dc..d7033b7757 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -364,19 +364,6 @@ float16 float16_silence_nan(float16 a, float_status *s= tatus) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN if the half-precision floating point value `a' is a -| signaling NaN; otherwise returns `a'. -*-------------------------------------------------------------------------= ---*/ - -float16 float16_maybe_silence_nan(float16 a, float_status *status) -{ - if (float16_is_signaling_nan(a, status)) { - return float16_silence_nan(a, status); - } - return a; -} - /*------------------------------------------------------------------------= ---- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -438,18 +425,6 @@ float32 float32_silence_nan(float32 a, float_status *s= tatus) } #endif } -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN if the single-precision floating point value `a' is a -| signaling NaN; otherwise returns `a'. -*-------------------------------------------------------------------------= ---*/ - -float32 float32_maybe_silence_nan(float32 a, float_status *status) -{ - if (float32_is_signaling_nan(a, status)) { - return float32_silence_nan(a, status); - } - return a; -} =20 /*------------------------------------------------------------------------= ---- | Returns the result of converting the single-precision floating-point NaN @@ -864,18 +839,6 @@ float64 float64_silence_nan(float64 a, float_status *s= tatus) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN if the double-precision floating point value `a' is a -| signaling NaN; otherwise returns `a'. -*-------------------------------------------------------------------------= ---*/ - -float64 float64_maybe_silence_nan(float64 a, float_status *status) -{ - if (float64_is_signaling_nan(a, status)) { - return float64_silence_nan(a, status); - } - return a; -} =20 /*------------------------------------------------------------------------= ---- | Returns the result of converting the double-precision floating-point NaN @@ -1037,19 +1000,6 @@ floatx80 floatx80_silence_nan(floatx80 a, float_stat= us *status) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN if the extended double-precision floating point value -| `a' is a signaling NaN; otherwise returns `a'. -*-------------------------------------------------------------------------= ---*/ - -floatx80 floatx80_maybe_silence_nan(floatx80 a, float_status *status) -{ - if (floatx80_is_signaling_nan(a, status)) { - return floatx80_silence_nan(a, status); - } - return a; -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the extended double-precision floating- | point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, t= he @@ -1204,19 +1154,6 @@ float128 float128_silence_nan(float128 a, float_stat= us *status) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN if the quadruple-precision floating point value `a' = is -| a signaling NaN; otherwise returns `a'. -*-------------------------------------------------------------------------= ---*/ - -float128 float128_maybe_silence_nan(float128 a, float_status *status) -{ - if (float128_is_signaling_nan(a, status)) { - return float128_silence_nan(a, status); - } - return a; -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the quadruple-precision floating-point = NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index a6860e858d..69f4dbc4db 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -258,7 +258,6 @@ int float16_compare_quiet(float16, float16, float_statu= s *status); int float16_is_quiet_nan(float16, float_status *status); int float16_is_signaling_nan(float16, float_status *status); float16 float16_silence_nan(float16, float_status *status); -float16 float16_maybe_silence_nan(float16, float_status *status); =20 static inline int float16_is_any_nan(float16 a) { @@ -370,7 +369,6 @@ float32 float32_maxnummag(float32, float32, float_statu= s *status); int float32_is_quiet_nan(float32, float_status *status); int float32_is_signaling_nan(float32, float_status *status); float32 float32_silence_nan(float32, float_status *status); -float32 float32_maybe_silence_nan(float32, float_status *status); float32 float32_scalbn(float32, int, float_status *status); =20 static inline float32 float32_abs(float32 a) @@ -500,7 +498,6 @@ float64 float64_maxnummag(float64, float64, float_statu= s *status); int float64_is_quiet_nan(float64 a, float_status *status); int float64_is_signaling_nan(float64, float_status *status); float64 float64_silence_nan(float64, float_status *status); -float64 float64_maybe_silence_nan(float64, float_status *status); float64 float64_scalbn(float64, int, float_status *status); =20 static inline float64 float64_abs(float64 a) @@ -604,7 +601,6 @@ int floatx80_compare_quiet(floatx80, floatx80, float_st= atus *status); int floatx80_is_quiet_nan(floatx80, float_status *status); int floatx80_is_signaling_nan(floatx80, float_status *status); floatx80 floatx80_silence_nan(floatx80, float_status *status); -floatx80 floatx80_maybe_silence_nan(floatx80, float_status *status); floatx80 floatx80_scalbn(floatx80, int, float_status *status); =20 static inline floatx80 floatx80_abs(floatx80 a) @@ -816,7 +812,6 @@ int float128_compare_quiet(float128, float128, float_st= atus *status); int float128_is_quiet_nan(float128, float_status *status); int float128_is_signaling_nan(float128, float_status *status); float128 float128_silence_nan(float128, float_status *status); -float128 float128_maybe_silence_nan(float128, float_status *status); float128 float128_scalbn(float128, int, float_status *status); =20 static inline float128 float128_abs(float128 a) --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487784683545.7632111108684; Wed, 16 May 2018 09:23:04 -0700 (PDT) Received: from localhost ([::1]:53831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzCX-00037a-Qf for importer@patchew.org; Wed, 16 May 2018 12:22:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjz-0004gz-Q1 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyju-00058W-Qf for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:23 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:42195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyju-00058M-I5 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:18 -0400 Received: by mail-pl0-x243.google.com with SMTP id u6-v6so664711pls.9 for ; Wed, 16 May 2018 08:53:18 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:16 -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=qT+dcRle1BZEnASBKOdKNp0UGnIwNg5lHSBhmnCFOZ0=; b=WMtcwxjvuT6rHxcydmkOWCyjHvW8rKKVbUPc7p+C2hRi9OfPZJUwydrxs2xcpAa7QF 6x52Z3kyxt5ojwURnZzjTDSUEFgziTtbrpTUTmpUEM7O6Ugza3kif335yxZMJ/PZemOZ Po7yKtpUOihZME4VnOCgJSDTcgUpk2u3Ki/ok= 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=qT+dcRle1BZEnASBKOdKNp0UGnIwNg5lHSBhmnCFOZ0=; b=ruwSRBaUPsnTxIJNofNixu850MYCZGTQQ/u7pMhujq0r3mjRP1NpxgqFpBcfqm/r6L WpO4J425I0q/7J/izEXjMbzh/LVUd8Kd2r4ArN4p4A/88CooPXAVa7fUXuavvu3wDQmO /KOGe/qr/bY7uqUigj5tzZ41KQzVKpy/9ZH+msfYnBEZdwbU83OweOomObYavU8mQW1r aw9JSzCcQeNBZA0BGkNcqQhNI1/X5fePwyl1LH5oFaig5yIShViwGnU5kYQCho3nufKZ 8wEmG/ujAYY9PTfVQEUStdVF+tf9INvazahkelWU4oS549kkP78MeguJo5ZXL1iHazwJ IPOg== X-Gm-Message-State: ALKqPwcusl2tUORr+Tt8zze5Nve2Ijdr0zy3Qa7ZyZhAry1+ph1Z0tDD 4wFge9k6mE8BJBNpnHvZ57dUyS5vFis= X-Google-Smtp-Source: AB8JxZra9p1R+khpvWmEuZp4bAdpwnBZPZi90bGU5yHtQySy5YhxJzEvCit7bgLgaSCnirK4F3Kveg== X-Received: by 2002:a17:902:1004:: with SMTP id b4-v6mr1457221pla.82.1526485997174; Wed, 16 May 2018 08:53:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:37 -0700 Message-Id: <20180516155243.16937-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PULL 22/28] fpu/softfloat: Specialize on snan_bit_is_one 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, Alexander Graf , Guan Xuetao , Yongbok Kim , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Only MIPS requires snan_bit_is_one to be variable. While we are specializing softfloat behaviour, allow other targets to eliminate this runtime check. Cc: Aurelien Jarno Cc: Yongbok Kim Cc: David Gibson Cc: Alexander Graf Cc: Guan Xuetao Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 68 ++++++++++++++++++++++------------- include/fpu/softfloat-types.h | 1 + target/hppa/cpu.c | 1 - target/ppc/fpu_helper.c | 1 - target/sh4/cpu.c | 1 - target/unicore32/cpu.c | 2 -- 6 files changed, 44 insertions(+), 30 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index d7033b7757..d1e06da75b 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -79,13 +79,31 @@ this code that are retained. * version 2 or later. See the COPYING file in the top-level directory. */ =20 -#if defined(TARGET_XTENSA) /* Define for architectures which deviate from IEEE in not supporting * signaling NaNs (so all NaNs are treated as quiet). */ +#if defined(TARGET_XTENSA) #define NO_SIGNALING_NANS 1 #endif =20 +/* Define how the architecture discriminates signaling NaNs. + * This done with the most significant bit of the fraction. + * In IEEE 754-1985 this was implementation defined, but in IEEE 754-2008 + * the msb must be zero. MIPS is (so far) unique in supporting both the + * 2008 revision and backward compatibility with their original choice. + * Thus for MIPS we must make the choice at runtime. + */ +static inline flag snan_bit_is_one(float_status *status) +{ +#if defined(TARGET_MIPS) + return status->snan_bit_is_one; +#elif defined(TARGET_HPPA) || defined(TARGET_UNICORE32) || defined(TARGET_= SH4) + return 1; +#else + return 0; +#endif +} + /*------------------------------------------------------------------------= ---- | For the deconstructed floating-point with fraction FRAC, return true | if the fraction represents a signalling NaN; otherwise false. @@ -97,7 +115,7 @@ static bool parts_is_snan_frac(uint64_t frac, float_stat= us *status) return false; #else flag msb =3D extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1); - return msb =3D=3D status->snan_bit_is_one; + return msb =3D=3D snan_bit_is_one(status); #endif } =20 @@ -118,7 +136,7 @@ static FloatParts parts_default_nan(float_status *statu= s) #elif defined(TARGET_HPPA) frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 2); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { frac =3D (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; } else { #if defined(TARGET_MIPS) @@ -151,7 +169,7 @@ static FloatParts parts_silence_nan(FloatParts a, float= _status *status) a.frac &=3D ~(1ULL << (DECOMPOSED_BINARY_POINT - 1)); a.frac |=3D 1ULL << (DECOMPOSED_BINARY_POINT - 2); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return parts_default_nan(status); } else { a.frac |=3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); @@ -169,7 +187,7 @@ float16 float16_default_nan(float_status *status) #if defined(TARGET_ARM) return const_float16(0x7E00); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return const_float16(0x7DFF); } else { #if defined(TARGET_MIPS) @@ -195,7 +213,7 @@ float32 float32_default_nan(float_status *status) #elif defined(TARGET_HPPA) return const_float32(0x7FA00000); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return const_float32(0x7FBFFFFF); } else { #if defined(TARGET_MIPS) @@ -220,7 +238,7 @@ float64 float64_default_nan(float_status *status) #elif defined(TARGET_HPPA) return const_float64(LIT64(0x7FF4000000000000)); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return const_float64(LIT64(0x7FF7FFFFFFFFFFFF)); } else { #if defined(TARGET_MIPS) @@ -242,7 +260,7 @@ floatx80 floatx80_default_nan(float_status *status) r.low =3D LIT64(0xFFFFFFFFFFFFFFFF); r.high =3D 0x7FFF; #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { r.low =3D LIT64(0xBFFFFFFFFFFFFFFF); r.high =3D 0x7FFF; } else { @@ -274,7 +292,7 @@ float128 float128_default_nan(float_status *status) { float128 r; =20 - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { r.low =3D LIT64(0xFFFFFFFFFFFFFFFF); r.high =3D LIT64(0x7FFF7FFFFFFFFFFF); } else { @@ -319,7 +337,7 @@ int float16_is_quiet_nan(float16 a_, float_status *stat= us) return float16_is_any_nan(a_); #else uint16_t a =3D float16_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a >> 9) & 0x3F) =3D=3D 0x3E) && (a & 0x1FF); } else { return ((a & ~0x8000) >=3D 0x7C80); @@ -338,7 +356,7 @@ int float16_is_signaling_nan(float16 a_, float_status *= status) return 0; #else uint16_t a =3D float16_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a & ~0x8000) >=3D 0x7C80); } else { return (((a >> 9) & 0x3F) =3D=3D 0x3E) && (a & 0x1FF); @@ -356,7 +374,7 @@ float16 float16_silence_nan(float16 a, float_status *st= atus) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return float16_default_nan(status); } else { return a | (1 << 9); @@ -375,7 +393,7 @@ int float32_is_quiet_nan(float32 a_, float_status *stat= us) return float32_is_any_nan(a_); #else uint32_t a =3D float32_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a >> 22) & 0x1FF) =3D=3D 0x1FE) && (a & 0x003FFFFF); } else { return ((uint32_t)(a << 1) >=3D 0xFF800000); @@ -394,7 +412,7 @@ int float32_is_signaling_nan(float32 a_, float_status *= status) return 0; #else uint32_t a =3D float32_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((uint32_t)(a << 1) >=3D 0xFF800000); } else { return (((a >> 22) & 0x1FF) =3D=3D 0x1FE) && (a & 0x003FFFFF); @@ -412,7 +430,7 @@ float32 float32_silence_nan(float32 a, float_status *st= atus) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { # ifdef TARGET_HPPA a &=3D ~0x00400000; a |=3D 0x00200000; @@ -651,7 +669,7 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, fl= ag bIsQNaN, flag bIsSNaN, return 3; } =20 - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { /* Prefer sNaN over qNaN, in the a, b, c order. */ if (aIsSNaN) { return 0; @@ -786,7 +804,7 @@ int float64_is_quiet_nan(float64 a_, float_status *stat= us) return float64_is_any_nan(a_); #else uint64_t a =3D float64_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a >> 51) & 0xFFF) =3D=3D 0xFFE) && (a & 0x0007FFFFFFFFFFFFULL); } else { @@ -806,7 +824,7 @@ int float64_is_signaling_nan(float64 a_, float_status *= status) return 0; #else uint64_t a =3D float64_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a << 1) >=3D 0xFFF0000000000000ULL); } else { return (((a >> 51) & 0xFFF) =3D=3D 0xFFE) @@ -825,7 +843,7 @@ float64 float64_silence_nan(float64 a, float_status *st= atus) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { # ifdef TARGET_HPPA a &=3D ~0x0008000000000000ULL; a |=3D 0x0004000000000000ULL; @@ -942,7 +960,7 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *sta= tus) #ifdef NO_SIGNALING_NANS return floatx80_is_any_nan(a); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { uint64_t aLow; =20 aLow =3D a.low & ~0x4000000000000000ULL; @@ -967,7 +985,7 @@ int floatx80_is_signaling_nan(floatx80 a, float_status = *status) #ifdef NO_SIGNALING_NANS return 0; #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a.high & 0x7FFF) =3D=3D 0x7FFF) && ((a.low << 1) >=3D 0x8000000000000000ULL); } else { @@ -991,7 +1009,7 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status= *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return floatx80_default_nan(status); } else { a.low |=3D LIT64(0xC000000000000000); @@ -1105,7 +1123,7 @@ int float128_is_quiet_nan(float128 a, float_status *s= tatus) #ifdef NO_SIGNALING_NANS return float128_is_any_nan(a); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a.high >> 47) & 0xFFFF) =3D=3D 0xFFFE) && (a.low || (a.high & 0x00007FFFFFFFFFFFULL)); } else { @@ -1125,7 +1143,7 @@ int float128_is_signaling_nan(float128 a, float_statu= s *status) #ifdef NO_SIGNALING_NANS return 0; #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a.high << 1) >=3D 0xFFFF000000000000ULL) && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL)); } else { @@ -1145,7 +1163,7 @@ float128 float128_silence_nan(float128 a, float_statu= s *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return float128_default_nan(status); } else { a.high |=3D LIT64(0x0000800000000000); diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 4e378cb612..2aae6a89b1 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -173,6 +173,7 @@ typedef struct float_status { /* should denormalised inputs go to zero and set the input_denormal fl= ag? */ flag flush_inputs_to_zero; flag default_nan_mode; + /* not always used -- see snan_bit_is_one() in softfloat-specialize.h = */ flag snan_bit_is_one; } float_status; =20 diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index c261b6b090..00bf444620 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -141,7 +141,6 @@ static void hppa_cpu_initfn(Object *obj) cs->env_ptr =3D env; cs->exception_index =3D -1; cpu_hppa_loaded_fr0(env); - set_snan_bit_is_one(true, &env->fp_status); cpu_hppa_put_psw(env, PSW_W); } =20 diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 9ae418a577..d31a933cbb 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -3382,7 +3382,6 @@ void helper_xssqrtqp(CPUPPCState *env, uint32_t opcod= e) xt.f128 =3D xb.f128; } else if (float128_is_neg(xb.f128) && !float128_is_zero(xb.f128))= { float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1); - set_snan_bit_is_one(0, &env->fp_status); xt.f128 =3D float128_default_nan(&env->fp_status); } } diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 541ffc2d97..b9f393b7c7 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -71,7 +71,6 @@ static void superh_cpu_reset(CPUState *s) set_flush_to_zero(1, &env->fp_status); #endif set_default_nan_mode(1, &env->fp_status); - set_snan_bit_is_one(1, &env->fp_status); } =20 static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *inf= o) diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 29d160a88d..68f978d80b 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -70,7 +70,6 @@ static void unicore_ii_cpu_initfn(Object *obj) =20 set_feature(env, UC32_HWCAP_CMOV); set_feature(env, UC32_HWCAP_UCF64); - set_snan_bit_is_one(1, &env->ucf64.fp_status); } =20 static void uc32_any_cpu_initfn(Object *obj) @@ -83,7 +82,6 @@ static void uc32_any_cpu_initfn(Object *obj) =20 set_feature(env, UC32_HWCAP_CMOV); set_feature(env, UC32_HWCAP_UCF64); - set_snan_bit_is_one(1, &env->ucf64.fp_status); } =20 static void uc32_cpu_realizefn(DeviceState *dev, Error **errp) --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487116541354.2145219686382; Wed, 16 May 2018 09:11:56 -0700 (PDT) Received: from localhost ([::1]:53281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz1v-0002VC-Nt for importer@patchew.org; Wed, 16 May 2018 12:11:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjx-0004gE-0b for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjw-000593-4D for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:21 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:39990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjv-00058r-Th for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:20 -0400 Received: by mail-pg0-x243.google.com with SMTP id l2-v6so468463pgc.7 for ; Wed, 16 May 2018 08:53:19 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:17 -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=69KH6e0KmS/GOAScDljSvnKlAK/69zrvY+8SeGJmqVM=; b=iRKbVnbaQO1Blcjh8V8vJj2eGQgKEwNI7qw7MAxGls0q0e9Q+24WDjgrxZdzyV9VWi UoHYyknKPWnrJlRQFwbWfPny7wsKrXZPDEy95j4tWi8DD45eXgC8h+jZ1DNQDQpBJPe/ etL/7Ia/48ZBmxaLZPsyMxnwERw+gyleIxK5M= 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=69KH6e0KmS/GOAScDljSvnKlAK/69zrvY+8SeGJmqVM=; b=G1jS10A0Kme4STJEYOAj7fUvuhpgrNi9l+oYGwUgmVOPthyLY35S9hogPjnQcA3CqV X4srXGx3DGc9M9yqiYmDZZp8eK5KORbX5RFczjoPhK96CWJ7r3UeaqLDemo1LrTnJqyM 3jSLYlrkR3PZgBKxzFtuxbJ8WGCn/dp6MLFSrp4dS2cmklNtn1ZKkGMALGzWlDP+zaI0 x8+5nsA0IgWSgwLEV75Z5b2YsGMlzBZg26MYLw1B3itqTXdCmwV6qsV3X/yBIs2wjfSu 1eucgGaQMIfJhHbxVOwTQtDUVYnVORD/2Dhjtbz2R/QuYkMXuszvv0orw9aE+uavvgX0 EwQQ== X-Gm-Message-State: ALKqPwebygbqNrPij2jqmNUjSpuOcpEvLje8BRIZwTB58YBGSNwZ5Lo9 Fb/3lfAJiFCzEIQOdhSu26oWkNBcIJM= X-Google-Smtp-Source: AB8JxZrGWFPZcjLbZGez82aJiRuP1tjaZzMKAFnA/ZfvnP1MNW1Br6RprkPrn8vppbY9HrHfDJyfmg== X-Received: by 2002:a62:cc08:: with SMTP id a8-v6mr1455829pfg.219.1526485998558; Wed, 16 May 2018 08:53:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:38 -0700 Message-Id: <20180516155243.16937-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PULL 23/28] fpu/softfloat: Make is_nan et al available to softfloat-specialize.h 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 We will need these helpers within softfloat-specialize.h, so move the definitions above the include. After specialization, they will not always be used so mark them to avoid the Werror. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 55e6701f26..ea252e0c84 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -181,6 +181,22 @@ typedef enum __attribute__ ((__packed__)) { float_class_snan, } FloatClass; =20 +/* Simple helpers for checking if, or what kind of, NaN we have */ +static inline __attribute__((unused)) bool is_nan(FloatClass c) +{ + return unlikely(c >=3D float_class_qnan); +} + +static inline __attribute__((unused)) bool is_snan(FloatClass c) +{ + return c =3D=3D float_class_snan; +} + +static inline __attribute__((unused)) bool is_qnan(FloatClass c) +{ + return c =3D=3D float_class_qnan; +} + /* * Structure holding all of the decomposed parts of a float. The * exponent is unbiased and the fraction is normalized. All @@ -536,20 +552,6 @@ static float64 float64_round_pack_canonical(FloatParts= p, float_status *s) return float64_pack_raw(round_canonical(p, s, &float64_params)); } =20 -/* Simple helpers for checking if what NaN we have */ -static bool is_nan(FloatClass c) -{ - return unlikely(c >=3D float_class_qnan); -} -static bool is_snan(FloatClass c) -{ - return c =3D=3D float_class_snan; -} -static bool is_qnan(FloatClass c) -{ - return c =3D=3D float_class_qnan; -} - static FloatParts return_nan(FloatParts a, float_status *s) { switch (a.cls) { --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487612931454.8604240799417; Wed, 16 May 2018 09:20:12 -0700 (PDT) Received: from localhost ([::1]:53725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz9v-0000we-8S for importer@patchew.org; Wed, 16 May 2018 12:20:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyjz-0004gy-O6 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjx-0005A8-Sm for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:23 -0400 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]:43231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjx-00059h-KX for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:21 -0400 Received: by mail-pf0-x235.google.com with SMTP id j20-v6so562583pff.10 for ; Wed, 16 May 2018 08:53:21 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:19 -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=ZlRhHgLQ4KpeMhtq0dx6G/jOtWDQQYOnoKzkDphqGgs=; b=WZnWON4pPk4/zDQDHTobQ1crfbJA2hFgisjFZ9F89oFRsWwe+mqZvcorRVII6VwLdR 9FvGFSO0DHNhH2ktqMCsLSkdIMWWzctZI7lknrtLK8lxEp85GDuXFLwTNjmTAuOWYYwv nR4YSwgTg1FeCeWzkvdb1+l6eAZxGAE1QhMJk= 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=ZlRhHgLQ4KpeMhtq0dx6G/jOtWDQQYOnoKzkDphqGgs=; b=rQ3azyq4ssM2OThJ2xQk1OpLDU+Av2ptlya8k/kPARHOsjeOcHiqFtrbHQvtukARle aYntCBV3XdWrjMfqYrND7nvx9HlXeyQKdHO4tlgdJgI6wSZRimQE6Q/MG3Zej6KbaQZz ryZ+oZtjvByx9h6y+z5fxRexjs3wLvjrMR2gYs8KWu/MRMPzvQ0qIDdQfscsMLuRNN4B 2kRttXUgW/g5zx96DfEf4m4Rd/OiaBqMUrO4MzNA52g/y8wGMJq5EvWOFEdNSKfyR/sS UAt1z32DiGNUzZ7+QLO8DyaBRma+ZC6LkPWIaEHKee2DovPvygs44bndkQ94A1yvYRz2 KKOQ== X-Gm-Message-State: ALKqPwcyv1L7KdfC9iC4n1hgLP5LruXAZre9DHRTDNsJqQTQWMqnT9/K m+Nakmip7qCoi6cfxC1TGzojlVe/tKc= X-Google-Smtp-Source: AB8JxZobEq3vGCG0xZbCzvxxCf8Cmtj+/xwVbta/s5z2VOsNiR8pZm896OdcWi+ud/EorVX94cF+Qw== X-Received: by 2002:a63:4202:: with SMTP id p2-v6mr1145031pga.137.1526485999899; Wed, 16 May 2018 08:53:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:39 -0700 Message-Id: <20180516155243.16937-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::235 Subject: [Qemu-devel] [PULL 24/28] fpu/softfloat: Pass FloatClass to pickNaN 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 For each operand, pass a single enumeration instead of a pair of booleans. The commit also merges multiple different ifdef-selected implementations of pickNaN into a single function whose body is ifdef-selected. Tested-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 168 ++++++++++++++++++------------------- fpu/softfloat.c | 3 +- 2 files changed, 82 insertions(+), 89 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index d1e06da75b..2695183188 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -501,10 +501,10 @@ static float32 commonNaNToFloat32(commonNaNT a, float= _status *status) | tie-break rule. *-------------------------------------------------------------------------= ---*/ =20 -#if defined(TARGET_ARM) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, +static int pickNaN(FloatClass a_cls, FloatClass b_cls, flag aIsLargerSignificand) { +#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) /* ARM mandated NaN propagation rules (see FPProcessNaNs()), take * the first of: * 1. A if it is signaling @@ -513,20 +513,6 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bI= sQNaN, flag bIsSNaN, * 4. B (quiet) * A signaling NaN is always quietened before returning it. */ - if (aIsSNaN) { - return 0; - } else if (bIsSNaN) { - return 1; - } else if (aIsQNaN) { - return 0; - } else { - return 1; - } -} -#elif defined(TARGET_MIPS) || defined(TARGET_HPPA) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ /* According to MIPS specifications, if one of the two operands is * a sNaN, a new qNaN has to be generated. This is done in * floatXX_silence_nan(). For qNaN inputs the specifications @@ -540,35 +526,21 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag b= IsQNaN, flag bIsSNaN, * 4. B (quiet) * A signaling NaN is always silenced before returning it. */ - if (aIsSNaN) { + if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } -} -#elif defined(TARGET_PPC) || defined(TARGET_XTENSA) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ +#elif defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K) /* PowerPC propagation rules: * 1. A if it sNaN or qNaN * 2. B if it sNaN or qNaN * A signaling NaN is always silenced before returning it. */ - if (aIsSNaN || aIsQNaN) { - return 0; - } else { - return 1; - } -} -#elif defined(TARGET_M68K) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ /* M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL * 3.4 FLOATING-POINT INSTRUCTION DETAILS * If either operand, but not both operands, of an operation is a @@ -583,16 +555,12 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag b= IsQNaN, flag bIsSNaN, * a nonsignaling NaN. The operation then continues as described in the * preceding paragraph for nonsignaling NaNs. */ - if (aIsQNaN || aIsSNaN) { /* a is the destination operand */ - return 0; /* return the destination operand */ + if (is_nan(a_cls)) { + return 0; } else { - return 1; /* return b */ + return 1; } -} #else -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ /* This implements x87 NaN propagation rules: * SNaN + QNaN =3D> return the QNaN * two SNaNs =3D> return the one with the larger significand, silenced @@ -603,13 +571,13 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag b= IsQNaN, flag bIsSNaN, * If we get down to comparing significands and they are the same, * return the NaN with the positive sign bit (if any). */ - if (aIsSNaN) { - if (bIsSNaN) { + if (is_snan(a_cls)) { + if (is_snan(b_cls)) { return aIsLargerSignificand ? 0 : 1; } - return bIsQNaN ? 1 : 0; - } else if (aIsQNaN) { - if (bIsSNaN || !bIsQNaN) { + return is_qnan(b_cls) ? 1 : 0; + } else if (is_qnan(a_cls)) { + if (is_snan(b_cls) || !is_qnan(b_cls)) { return 0; } else { return aIsLargerSignificand ? 0 : 1; @@ -617,8 +585,8 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIs= QNaN, flag bIsSNaN, } else { return 1; } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Select which NaN to propagate for a three-input operation. @@ -752,18 +720,26 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, = flag bIsQNaN, flag bIsSNaN, =20 static float32 propagateFloat32NaN(float32 a, float32 b, float_status *sta= tus) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; uint32_t av, bv; + FloatClass a_cls, b_cls; + + /* This is not complete, but is good enough for pickNaN. */ + a_cls =3D (!float32_is_any_nan(a) + ? float_class_normal + : float32_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls =3D (!float32_is_any_nan(b) + ? float_class_normal + : float32_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); =20 - aIsQuietNaN =3D float32_is_quiet_nan(a, status); - aIsSignalingNaN =3D float32_is_signaling_nan(a, status); - bIsQuietNaN =3D float32_is_quiet_nan(b, status); - bIsSignalingNaN =3D float32_is_signaling_nan(b, status); av =3D float32_val(a); bv =3D float32_val(b); =20 - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } =20 @@ -779,14 +755,13 @@ static float32 propagateFloat32NaN(float32 a, float32= b, float_status *status) aIsLargerSignificand =3D (av < bv) ? 1 : 0; } =20 - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return float32_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return float32_silence_nan(a, status); } return a; @@ -908,18 +883,26 @@ static float64 commonNaNToFloat64(commonNaNT a, float= _status *status) =20 static float64 propagateFloat64NaN(float64 a, float64 b, float_status *sta= tus) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; uint64_t av, bv; + FloatClass a_cls, b_cls; + + /* This is not complete, but is good enough for pickNaN. */ + a_cls =3D (!float64_is_any_nan(a) + ? float_class_normal + : float64_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls =3D (!float64_is_any_nan(b) + ? float_class_normal + : float64_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); =20 - aIsQuietNaN =3D float64_is_quiet_nan(a, status); - aIsSignalingNaN =3D float64_is_signaling_nan(a, status); - bIsQuietNaN =3D float64_is_quiet_nan(b, status); - bIsSignalingNaN =3D float64_is_signaling_nan(b, status); av =3D float64_val(a); bv =3D float64_val(b); =20 - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } =20 @@ -935,14 +918,13 @@ static float64 propagateFloat64NaN(float64 a, float64= b, float_status *status) aIsLargerSignificand =3D (av < bv) ? 1 : 0; } =20 - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return float64_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return float64_silence_nan(a, status); } return a; @@ -1075,15 +1057,22 @@ static floatx80 commonNaNToFloatx80(commonNaNT a, f= loat_status *status) =20 floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; + FloatClass a_cls, b_cls; =20 - aIsQuietNaN =3D floatx80_is_quiet_nan(a, status); - aIsSignalingNaN =3D floatx80_is_signaling_nan(a, status); - bIsQuietNaN =3D floatx80_is_quiet_nan(b, status); - bIsSignalingNaN =3D floatx80_is_signaling_nan(b, status); + /* This is not complete, but is good enough for pickNaN. */ + a_cls =3D (!floatx80_is_any_nan(a) + ? float_class_normal + : floatx80_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls =3D (!floatx80_is_any_nan(b) + ? float_class_normal + : floatx80_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); =20 - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } =20 @@ -1099,14 +1088,13 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 = b, float_status *status) aIsLargerSignificand =3D (a.high < b.high) ? 1 : 0; } =20 - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return floatx80_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return floatx80_silence_nan(a, status); } return a; @@ -1217,15 +1205,22 @@ static float128 commonNaNToFloat128(commonNaNT a, f= loat_status *status) static float128 propagateFloat128NaN(float128 a, float128 b, float_status *status) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; + FloatClass a_cls, b_cls; =20 - aIsQuietNaN =3D float128_is_quiet_nan(a, status); - aIsSignalingNaN =3D float128_is_signaling_nan(a, status); - bIsQuietNaN =3D float128_is_quiet_nan(b, status); - bIsSignalingNaN =3D float128_is_signaling_nan(b, status); + /* This is not complete, but is good enough for pickNaN. */ + a_cls =3D (!float128_is_any_nan(a) + ? float_class_normal + : float128_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls =3D (!float128_is_any_nan(b) + ? float_class_normal + : float128_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); =20 - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } =20 @@ -1241,14 +1236,13 @@ static float128 propagateFloat128NaN(float128 a, fl= oat128 b, aIsLargerSignificand =3D (a.high < b.high) ? 1 : 0; } =20 - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return float128_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return float128_silence_nan(a, status); } return a; diff --git a/fpu/softfloat.c b/fpu/softfloat.c index ea252e0c84..55954385ff 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -580,8 +580,7 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, = float_status *s) if (s->default_nan_mode) { return parts_default_nan(s); } else { - if (pickNaN(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), + if (pickNaN(a.cls, b.cls, a.frac > b.frac || (a.frac =3D=3D b.frac && a.sign < b.sign))) { a =3D b; --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487410686657.8558003014722; Wed, 16 May 2018 09:16:50 -0700 (PDT) Received: from localhost ([::1]:53557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIz6f-0006tP-T6 for importer@patchew.org; Wed, 16 May 2018 12:16:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyk0-0004h0-9v for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyjz-0005Ak-7F for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:24 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:41215) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyjy-0005AO-UF for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:23 -0400 Received: by mail-pg0-x242.google.com with SMTP id w4-v6so467149pgq.8 for ; Wed, 16 May 2018 08:53:22 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:20 -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=l7WMGMq5FTzJZw/8Ol7jK0ePReknNRBHJTqi+3dsjxg=; b=fWt0snpHHjqg2xVVaSWBt8OUqMLf+HqjEKjNlBXFyZ/50KWGRLdo6ARXlts45I0V5B 0fGpfJ4zEd9elPrHy4LTr02qXrmjk5WTU/UGLUicRpKcIH58dL09RQdwT7otWUGsWTDD ilhXsLoKdYqtUMXFFBFJbYqvGYj/vbMyZXMkI= 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=l7WMGMq5FTzJZw/8Ol7jK0ePReknNRBHJTqi+3dsjxg=; b=SBFCzVJgcWNj+KJCh7a7bNhdiE5bvWR+yJcGuHvGVVCCMn4FwBL8f1N0mVU99uPS48 s5khp4XxfI8p9WMxN3oocyzfrGx+2EYEZkHmk41J9xnM4188cG/MPy7UdfunVz5prAYe U4rNlBVBRUJfsJqU9i3iRg6Y7LS75wQPLysF2wL9gbXHQgSfKEigc65d2oB+FLmq+lJ9 oFkU+lST3OfVLRc/12VU6xVDXldPSM4zYJYqctvKPxn1V9holmU3xYgfJrz2nMkmbkab Bq89Cs8KuzASUA3bWKc4j96/+0J9qEYNhccn4hjLnRD5YU43HqmKefO3jIcSEO4iSbfD fUTQ== X-Gm-Message-State: ALKqPweFNvReupqCZDFLEIN7ESAPY78g3bBLOhvjqOnly1bH2d+Q8oSx epUyWsnepSmoC2B4RQwB6TUBsmqbBVo= X-Google-Smtp-Source: AB8JxZqMHnkpDQxJzwAPQIYXjYWHB/Va9+xQ5VHaExHSUkwbv+Wy5jVtK+qCHtcDzvWDlEvXmajixw== X-Received: by 2002:a65:6489:: with SMTP id e9-v6mr1180006pgv.44.1526486001489; Wed, 16 May 2018 08:53:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:40 -0700 Message-Id: <20180516155243.16937-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PULL 25/28] fpu/softfloat: Pass FloatClass to pickNaNMulAdd 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 For each operand, pass a single enumeration instead of a pair of booleans. The commit also merges multiple different ifdef-selected implementations of pickNaNMulAdd into a single function whose body is ifdef-selected. Tested-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 70 +++++++++++++++----------------------- fpu/softfloat.c | 5 +-- 2 files changed, 28 insertions(+), 47 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 2695183188..0399dfe011 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -594,15 +594,14 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | information. | Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN *-------------------------------------------------------------------------= ---*/ -#if defined(TARGET_ARM) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bI= sSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) +static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_= cls, + bool infzero, float_status *status) { +#if defined(TARGET_ARM) /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns * the default NaN */ - if (infzero && cIsQNaN) { + if (infzero && is_qnan(c_cls)) { float_raise(float_flag_invalid, status); return 3; } @@ -610,25 +609,20 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, = flag bIsQNaN, flag bIsSNaN, /* This looks different from the ARM ARM pseudocode, because the ARM A= RM * puts the operands to a fused mac operation (a*b)+c in the order c,a= ,b. */ - if (cIsSNaN) { + if (is_snan(c_cls)) { return 2; - } else if (aIsSNaN) { + } else if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsQNaN) { + } else if (is_qnan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } -} #elif defined(TARGET_MIPS) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bI= sSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ /* For MIPS, the (inf,zero,qnan) case sets InvalidOp and returns * the default NaN */ @@ -639,41 +633,36 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, = flag bIsQNaN, flag bIsSNaN, =20 if (snan_bit_is_one(status)) { /* Prefer sNaN over qNaN, in the a, b, c order. */ - if (aIsSNaN) { + if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsSNaN) { + } else if (is_snan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; - } else if (bIsQNaN) { + } else if (is_qnan(b_cls)) { return 1; } else { return 2; } } else { /* Prefer sNaN over qNaN, in the c, a, b order. */ - if (cIsSNaN) { + if (is_snan(c_cls)) { return 2; - } else if (aIsSNaN) { + } else if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsQNaN) { + } else if (is_qnan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } } -} #elif defined(TARGET_PPC) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bI= sSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer * to return an input NaN if we have one (ie c) rather than generating * a default NaN @@ -686,31 +675,26 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, = flag bIsQNaN, flag bIsSNaN, /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB */ - if (aIsSNaN || aIsQNaN) { + if (is_nan(a_cls)) { return 0; - } else if (cIsSNaN || cIsQNaN) { + } else if (is_nan(c_cls)) { return 2; } else { return 1; } -} #else -/* A default implementation: prefer a to b to c. - * This is unlikely to actually match any real implementation. - */ -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bI= sSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ - if (aIsSNaN || aIsQNaN) { + /* A default implementation: prefer a to b to c. + * This is unlikely to actually match any real implementation. + */ + if (is_nan(a_cls)) { return 0; - } else if (bIsSNaN || bIsQNaN) { + } else if (is_nan(b_cls)) { return 1; } else { return 2; } -} #endif +} =20 /*------------------------------------------------------------------------= ---- | Takes two single-precision floating-point values `a' and `b', one of whi= ch diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 55954385ff..8e97602ace 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -601,10 +601,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatP= arts b, FloatParts c, s->float_exception_flags |=3D float_flag_invalid; } =20 - which =3D pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), - is_qnan(c.cls), is_snan(c.cls), - inf_zero, s); + which =3D pickNaNMulAdd(a.cls, b.cls, c.cls, inf_zero, s); =20 if (s->default_nan_mode) { /* Note that this check is after pickNaNMulAdd so that function --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526487929281961.5877483156535; Wed, 16 May 2018 09:25:29 -0700 (PDT) Received: from localhost ([::1]:53941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzF2-0005An-C7 for importer@patchew.org; Wed, 16 May 2018 12:25:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyk3-0004iy-4L for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyk0-0005BO-Nf for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:27 -0400 Received: from mail-pl0-x22a.google.com ([2607:f8b0:400e:c01::22a]:34869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyk0-0005BB-Fp for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:24 -0400 Received: by mail-pl0-x22a.google.com with SMTP id i5-v6so673797plt.2 for ; Wed, 16 May 2018 08:53:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:21 -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=Rz3IqVdJzcvtjJ/dJ47cdMMS5avvv1bCkZtCabOjQ9w=; b=Pkhytwazr+/MM1j7A0UMnVZzHhWk6zTtxT+h6zzFtxy2iyodlidgk2DO38a+XhX3rT 5B3sM7rmmDhm1B0jRs85RiSixVOB2Y2tpYtONxR5SNLXILiGVPwfKOoXyou6IrHPIBAn WlMKp99OZBdQIY1H0dVjoHGwD2hxY3lkcZIkA= 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=Rz3IqVdJzcvtjJ/dJ47cdMMS5avvv1bCkZtCabOjQ9w=; b=Iw2MEPnW9zgXY1xBPsuF0AiHGhzVEA8aZTvBKf6GzcZnw2oRDd2Eiut7BBLfP8/Kq+ fHZVCalaSSq0XsqbozE8KrlO49N2AwFRKHtrNHcT96X59QobtdX2tPxacxxPViehOSx3 V2TxDWT3V6wGuZKRIE3yjgCHTJr0OBin599coWbBFDIm9ElEosJXzihULD8kJvDllKpi fVh4GqDsuQrOaBBncu/Gwn9wqMhke9MbEmVLHJfTSx/jKCjLYsD3LOdn15rl/AlOyv9M Q7OhW0Ek20gXmYbm9Nd9ho5zDyWQwWYJfON+jRC5nQw/WtaNDnKprR2oqYpPHjDvvL9n EBRQ== X-Gm-Message-State: ALKqPwf9Vyzij6NCWd/iidm3jlWWVr2cbBgvsGe/NV2wP3wRXZfznC3E TxYNwyUEgcbQ7l3SgHml04nKNdb3Uv4= X-Google-Smtp-Source: AB8JxZoN1wtuvN3LWj49KSE/oEUqWOP3p0MGSLX1eMWNidBel+1wcLdYOVcmI5ypKPbHZLDQKcDkOg== X-Received: by 2002:a17:902:5ac1:: with SMTP id g1-v6mr1461544plm.43.1526486002955; Wed, 16 May 2018 08:53:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:41 -0700 Message-Id: <20180516155243.16937-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::22a Subject: [Qemu-devel] [PULL 26/28] fpu/softfloat: Define floatN_default_nan in terms of parts_default_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Isolate the target-specific choice to 2 functions instead of 6. The code in float16_default_nan was only correct for ARM, MIPS, and X86. Though float16 support is rare among our targets. The code in float128_default_nan was arguably wrong for Sparc. While QEMU supports the Sparc 128-bit insns, no real cpu enables it. The code in floatx80_default_nan tried to be over-general. There are only two targets that support this format: x86 and m68k. Thus there is no point in inventing a value for snan_bit_is_one. Move routines that no longer have ifdefs out of softfloat-specialize.h. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 105 +++---------------------------------- fpu/softfloat.c | 41 +++++++++++++++ 2 files changed, 47 insertions(+), 99 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 0399dfe011..9d562ed504 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -179,94 +179,22 @@ static FloatParts parts_silence_nan(FloatParts a, flo= at_status *status) return a; } =20 -/*------------------------------------------------------------------------= ---- -| The pattern for a default generated half-precision NaN. -*-------------------------------------------------------------------------= ---*/ -float16 float16_default_nan(float_status *status) -{ -#if defined(TARGET_ARM) - return const_float16(0x7E00); -#else - if (snan_bit_is_one(status)) { - return const_float16(0x7DFF); - } else { -#if defined(TARGET_MIPS) - return const_float16(0x7E00); -#else - return const_float16(0xFE00); -#endif - } -#endif -} - -/*------------------------------------------------------------------------= ---- -| The pattern for a default generated single-precision NaN. -*-------------------------------------------------------------------------= ---*/ -float32 float32_default_nan(float_status *status) -{ -#if defined(TARGET_SPARC) || defined(TARGET_M68K) - return const_float32(0x7FFFFFFF); -#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) = || \ - defined(TARGET_XTENSA) || defined(TARGET_S390X) || \ - defined(TARGET_TRICORE) || defined(TARGET_RISCV) - return const_float32(0x7FC00000); -#elif defined(TARGET_HPPA) - return const_float32(0x7FA00000); -#else - if (snan_bit_is_one(status)) { - return const_float32(0x7FBFFFFF); - } else { -#if defined(TARGET_MIPS) - return const_float32(0x7FC00000); -#else - return const_float32(0xFFC00000); -#endif - } -#endif -} - -/*------------------------------------------------------------------------= ---- -| The pattern for a default generated double-precision NaN. -*-------------------------------------------------------------------------= ---*/ -float64 float64_default_nan(float_status *status) -{ -#if defined(TARGET_SPARC) || defined(TARGET_M68K) - return const_float64(LIT64(0x7FFFFFFFFFFFFFFF)); -#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) = || \ - defined(TARGET_S390X) || defined(TARGET_RISCV) - return const_float64(LIT64(0x7FF8000000000000)); -#elif defined(TARGET_HPPA) - return const_float64(LIT64(0x7FF4000000000000)); -#else - if (snan_bit_is_one(status)) { - return const_float64(LIT64(0x7FF7FFFFFFFFFFFF)); - } else { -#if defined(TARGET_MIPS) - return const_float64(LIT64(0x7FF8000000000000)); -#else - return const_float64(LIT64(0xFFF8000000000000)); -#endif - } -#endif -} - /*------------------------------------------------------------------------= ---- | The pattern for a default generated extended double-precision NaN. *-------------------------------------------------------------------------= ---*/ floatx80 floatx80_default_nan(float_status *status) { floatx80 r; + + /* None of the targets that have snan_bit_is_one use floatx80. */ + assert(!snan_bit_is_one(status)); #if defined(TARGET_M68K) r.low =3D LIT64(0xFFFFFFFFFFFFFFFF); r.high =3D 0x7FFF; #else - if (snan_bit_is_one(status)) { - r.low =3D LIT64(0xBFFFFFFFFFFFFFFF); - r.high =3D 0x7FFF; - } else { - r.low =3D LIT64(0xC000000000000000); - r.high =3D 0xFFFF; - } + /* X86 */ + r.low =3D LIT64(0xC000000000000000); + r.high =3D 0xFFFF; #endif return r; } @@ -285,27 +213,6 @@ floatx80 floatx80_default_nan(float_status *status) const floatx80 floatx80_infinity =3D make_floatx80_init(floatx80_infinity_high, floatx80_infinity_low); =20 -/*------------------------------------------------------------------------= ---- -| The pattern for a default generated quadruple-precision NaN. -*-------------------------------------------------------------------------= ---*/ -float128 float128_default_nan(float_status *status) -{ - float128 r; - - if (snan_bit_is_one(status)) { - r.low =3D LIT64(0xFFFFFFFFFFFFFFFF); - r.high =3D LIT64(0x7FFF7FFFFFFFFFFF); - } else { - r.low =3D LIT64(0x0000000000000000); -#if defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_RISCV) - r.high =3D LIT64(0x7FFF800000000000); -#else - r.high =3D LIT64(0xFFFF800000000000); -#endif - } - return r; -} - /*------------------------------------------------------------------------= ---- | Raises the exceptions specified by `flags'. Floating-point traps can be | defined here if desired. It is currently not possible for such a trap diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 8e97602ace..c8b33e35f4 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2092,6 +2092,47 @@ float64 __attribute__((flatten)) float64_sqrt(float6= 4 a, float_status *status) return float64_round_pack_canonical(pr, status); } =20 +/*------------------------------------------------------------------------= ---- +| The pattern for a default generated NaN. +*-------------------------------------------------------------------------= ---*/ + +float16 float16_default_nan(float_status *status) +{ + FloatParts p =3D parts_default_nan(status); + p.frac >>=3D float16_params.frac_shift; + return float16_pack_raw(p); +} + +float32 float32_default_nan(float_status *status) +{ + FloatParts p =3D parts_default_nan(status); + p.frac >>=3D float32_params.frac_shift; + return float32_pack_raw(p); +} + +float64 float64_default_nan(float_status *status) +{ + FloatParts p =3D parts_default_nan(status); + p.frac >>=3D float64_params.frac_shift; + return float64_pack_raw(p); +} + +float128 float128_default_nan(float_status *status) +{ + FloatParts p =3D parts_default_nan(status); + float128 r; + + /* Extrapolate from the choices made by parts_default_nan to fill + * in the quad-floating format. If the low bit is set, assume we + * want to set all non-snan bits. + */ + r.low =3D -(p.frac & 1); + r.high =3D p.frac >> (DECOMPOSED_BINARY_POINT - 48); + r.high |=3D LIT64(0x7FFF000000000000); + r.high |=3D (uint64_t)p.sign << 63; + + return r; +} =20 /*------------------------------------------------------------------------= ---- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526488108113466.28897399047514; Wed, 16 May 2018 09:28:28 -0700 (PDT) Received: from localhost ([::1]:54045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzHv-0007aW-9U for importer@patchew.org; Wed, 16 May 2018 12:28:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyk3-0004ix-45 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyk1-0005Bl-UN for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:27 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:34318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyk1-0005BX-OJ for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:25 -0400 Received: by mail-pl0-x241.google.com with SMTP id ay10-v6so676886plb.1 for ; Wed, 16 May 2018 08:53:25 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:23 -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=FoXwUVq86zr0ueZIYvuCk2E7EmzERIvaAi2zhHeG+WQ=; b=XnpDxK4dmUOhs2rMTLWQ6D4nBc5TYceQCTYMePPFNBNxfL24UvKEfkzpw6vcwViMoT 9w34QG0/6oW4G7zWW14WWuYTYYJ4oxf/iyXQZ5VAtwIJ6cqeetNM3HrmK2pH433REVRy Y/0HWcmpQ4SBYjzhrv+6F5txbII/hukgoVBHU= 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=FoXwUVq86zr0ueZIYvuCk2E7EmzERIvaAi2zhHeG+WQ=; b=cCQESmI9yEnAQwTryYDq6rChEC4sXFBhcXWFyjqmtObPELBL/AJJruaEyAG8hfecUn MQmJsuhWV5KE+4V55j2KFgPyFNMnqFJSl7ci02wBaBwF0CzZpyuQm1v/kruXA76WB7Nh UMwgg1Xpa0GRxRrP83aG2ztqDPfDJa3/11fjKYkdmt5Cnxmh3FhGc/3Qf+3ih/pnBOYM 0e6FFutBKaWiDEFAmraUNvHrIZri0iA0765ISI1hCgvyCC4lPbl/37WOMAfmId3FGk6z sBp0ZfSBZUe/DcwgkfoH7x8naIWMxkQrBXiIiShTmuqvH8y3TUp7YYzndGZdSnXpM/6I 4y7Q== X-Gm-Message-State: ALKqPwek3zQoL2bBuOcoCqJk5Nx7WyfSvS/W92rmwHgkpoglCothF56T Zcm0hTfELXRzwYG463h5LBwPiba1hoQ= X-Google-Smtp-Source: AB8JxZqXwYXugQbToPXz2jUMWe2r7SuqaE+gvZi44whfAxDuvB3VjRAchAvEfjfDYJyu9T3LcBWWwQ== X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr1499732pls.270.1526486004312; Wed, 16 May 2018 08:53:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:42 -0700 Message-Id: <20180516155243.16937-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PULL 27/28] fpu/softfloat: Clean up parts_default_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Reduce the number of ifdefs. Correct the result for OpenRISC and TriCore (although TriCore fixed in target-specific code). Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 9d562ed504..ec4fb6ba8b 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -129,22 +129,29 @@ static FloatParts parts_default_nan(float_status *sta= tus) uint64_t frac; =20 #if defined(TARGET_SPARC) || defined(TARGET_M68K) + /* !snan_bit_is_one, set all bits */ frac =3D (1ULL << DECOMPOSED_BINARY_POINT) - 1; -#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) = || \ - defined(TARGET_S390X) || defined(TARGET_RISCV) +#elif defined(TARGET_I386) || defined(TARGET_X86_64) \ + || defined(TARGET_MICROBLAZE) + /* !snan_bit_is_one, set sign and msb */ frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); + sign =3D 1; #elif defined(TARGET_HPPA) + /* snan_bit_is_one, set msb-1. */ frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 2); #else + /* This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, + * S390, SH4, TriCore, and Xtensa. I cannot find documentation + * for Unicore32; the choice from the original commit is unchanged. + * Our other supported targets, CRIS, LM32, Moxie, Nios2, and Tile, + * do not have floating-point. + */ if (snan_bit_is_one(status)) { + /* set all bits other than msb */ frac =3D (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; } else { -#if defined(TARGET_MIPS) + /* set msb */ frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); -#else - frac =3D 1ULL << (DECOMPOSED_BINARY_POINT - 1); - sign =3D 1; -#endif } #endif =20 --=20 2.17.0 From nobody Sat Apr 20 00:05:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526488078276195.87091933616057; Wed, 16 May 2018 09:27:58 -0700 (PDT) Received: from localhost ([::1]:54014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIzHR-0007CN-42 for importer@patchew.org; Wed, 16 May 2018 12:27:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIyk4-0004kl-H9 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIyk3-0005CL-En for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:28 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:33617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIyk3-0005Bu-76 for qemu-devel@nongnu.org; Wed, 16 May 2018 11:53:27 -0400 Received: by mail-pl0-x244.google.com with SMTP id n10-v6so673974plp.0 for ; Wed, 16 May 2018 08:53:27 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id c3-v6sm4966632pfn.62.2018.05.16.08.53.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 08:53:24 -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=ZC9TUm1Wa76g6xZsbJV8AL4lnK1ydFZXG6NTJq37V0g=; b=G4scEjNNLVwVVHmNVtkh38YUbMIp9VMG8kMu35hGspt8uP/EvPNxbLtHojF+6UQJUr NkW+9qZGHu5Rz9/3GQw+1M0Sn09GdX9/G5jHRBxcqz81zf7pBuYLcutEX67GPEQzsnW9 MuZsc24Bj2a249b4INwFYHojgnkE4osPfwcW4= 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=ZC9TUm1Wa76g6xZsbJV8AL4lnK1ydFZXG6NTJq37V0g=; b=sGN0JvUgwQTy76P96owO4vS8DJwusgx8TCE8bztmpdyiG0iNUyuDDQyJFNkd+FF7iF JpcPNnD1LOi9ylTph9x1WVDriPvlpsCI20zRApWAkR47LWr8m8G548BoenNQV3fyIe64 z5VteZNRRp6Z/OZpe0L1lx2L4liF/tJ17NEQAWCgfXen4czhx93iGRhsGPmxUIV1IAdC rgpEjeMb1C3fuRKPjTf228hw5einox8pxihkMukc8HmMHL3PZKTGmfvT4kqgbfAv0X1o h2v7TRku0g18AfxFM51CB8AOPiEsCwOqCQRDKW/YZ+6WaFb74ACe8xgU/oUIIxPv4CtL eg8A== X-Gm-Message-State: ALKqPwcHyRBS4phkdhy6d1eTzm4uIrOKTv1YwnYcBUbtwZT6grK+nIyD 6xMpX+o9GQARU7XqH+6Fv+nlXLIoyCE= X-Google-Smtp-Source: AB8JxZpWAdGL+h7clW5Y6I0A/hvJrjKdvXAMHXT9qKVg7YjyZ9nT+ZeSgOe4HiHzRD/rDkF4mOPeRw== X-Received: by 2002:a17:902:8f97:: with SMTP id z23-v6mr1459157plo.329.1526486005786; Wed, 16 May 2018 08:53:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 16 May 2018 08:52:43 -0700 Message-Id: <20180516155243.16937-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516155243.16937-1-richard.henderson@linaro.org> References: <20180516155243.16937-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PULL 28/28] fpu/softfloat: Define floatN_silence_nan in terms of parts_silence_nan 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Isolate the target-specific choice to 3 functions instead of 6. The code in floatx80_default_nan tried to be over-general. There are only two targets that support this format: x86 and m68k. Thus there is no point in inventing a mechanism for snan_bit_is_one. Move routines that no longer have ifdefs out of softfloat-specialize.h. Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 81 ++------------------------------------ fpu/softfloat.c | 31 +++++++++++++++ 2 files changed, 35 insertions(+), 77 deletions(-) diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index ec4fb6ba8b..16c0bcb6fa 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -278,24 +278,6 @@ int float16_is_signaling_nan(float16 a_, float_status = *status) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN from a signalling NaN for the half-precision -| floating point value `a'. -*-------------------------------------------------------------------------= ---*/ - -float16 float16_silence_nan(float16 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { - return float16_default_nan(status); - } else { - return a | (1 << 9); - } -#endif -} - /*------------------------------------------------------------------------= ---- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -334,30 +316,6 @@ int float32_is_signaling_nan(float32 a_, float_status = *status) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN from a signalling NaN for the single-precision -| floating point value `a'. -*-------------------------------------------------------------------------= ---*/ - -float32 float32_silence_nan(float32 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { -# ifdef TARGET_HPPA - a &=3D ~0x00400000; - a |=3D 0x00200000; - return a; -# else - return float32_default_nan(status); -# endif - } else { - return a | (1 << 22); - } -#endif -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the single-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid @@ -706,31 +664,6 @@ int float64_is_signaling_nan(float64 a_, float_status = *status) #endif } =20 -/*------------------------------------------------------------------------= ---- -| Returns a quiet NaN from a signalling NaN for the double-precision -| floating point value `a'. -*-------------------------------------------------------------------------= ---*/ - -float64 float64_silence_nan(float64 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { -# ifdef TARGET_HPPA - a &=3D ~0x0008000000000000ULL; - a |=3D 0x0004000000000000ULL; - return a; -# else - return float64_default_nan(status); -# endif - } else { - return a | LIT64(0x0008000000000000); - } -#endif -} - - /*------------------------------------------------------------------------= ---- | Returns the result of converting the double-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid @@ -886,16 +819,10 @@ int floatx80_is_signaling_nan(floatx80 a, float_statu= s *status) =20 floatx80 floatx80_silence_nan(floatx80 a, float_status *status) { -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { - return floatx80_default_nan(status); - } else { - a.low |=3D LIT64(0xC000000000000000); - return a; - } -#endif + /* None of the targets that have snan_bit_is_one use floatx80. */ + assert(!snan_bit_is_one(status)); + a.low |=3D LIT64(0xC000000000000000); + return a; } =20 /*------------------------------------------------------------------------= ---- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index c8b33e35f4..8cd2400081 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2134,6 +2134,37 @@ float128 float128_default_nan(float_status *status) return r; } =20 +/*------------------------------------------------------------------------= ---- +| Returns a quiet NaN from a signalling NaN for the floating point value `= a'. +*-------------------------------------------------------------------------= ---*/ + +float16 float16_silence_nan(float16 a, float_status *status) +{ + FloatParts p =3D float16_unpack_raw(a); + p.frac <<=3D float16_params.frac_shift; + p =3D parts_silence_nan(p, status); + p.frac >>=3D float16_params.frac_shift; + return float16_pack_raw(p); +} + +float32 float32_silence_nan(float32 a, float_status *status) +{ + FloatParts p =3D float32_unpack_raw(a); + p.frac <<=3D float32_params.frac_shift; + p =3D parts_silence_nan(p, status); + p.frac >>=3D float32_params.frac_shift; + return float32_pack_raw(p); +} + +float64 float64_silence_nan(float64 a, float_status *status) +{ + FloatParts p =3D float64_unpack_raw(a); + p.frac <<=3D float64_params.frac_shift; + p =3D parts_silence_nan(p, status); + p.frac >>=3D float64_params.frac_shift; + return float64_pack_raw(p); +} + /*------------------------------------------------------------------------= ---- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 | and 7, and returns the properly rounded 32-bit integer corresponding to = the --=20 2.17.0