From nobody Fri Oct 10 15:41:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1589907284; cv=none; d=zohomail.com; s=zohoarc; b=Ixc4bhTbZ/tSrjgwPGNXokWtwgF+5aBKWq++JnZsHQ7K5cjocYv6laKY9EI3zEb6Nyu1coev42wF/UPnIb/A77YRCAsQRfE00yEuL8WY1HEFhQ4VfSGlup6wcw2ZryagUfgWiKFyCHVs5/fQx3oBRnv6JB0JpplKMyO4guEYKZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589907284; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9krfltsdrPyRRqutGHrEb2XJlVU12BnO8AU9UkCykds=; b=T9NEyAJse5RTOR3Tgjm3sHD4IEXS+A/LGpXTxeX6AbRvji9CCDDIo1u1LpjJnzrd38/apyAs6OCxwBlTjO3rdikaIuWpbJXbmQz9K2ob5FRHZ1eXPaPvoLIRKvUsYF363lA1Lz4joBvYrBgVrguDFRXp9Zc06qUuvVpSD0PUawc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589907284720812.3186645271861; Tue, 19 May 2020 09:54:44 -0700 (PDT) Received: from localhost ([::1]:41208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb5Vr-0004cX-Fc for importer@patchew.org; Tue, 19 May 2020 12:54:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb5RP-0004f8-EK for qemu-devel@nongnu.org; Tue, 19 May 2020 12:50:07 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jb5RO-0006Cm-8e for qemu-devel@nongnu.org; Tue, 19 May 2020 12:50:07 -0400 Received: by mail-pf1-x42e.google.com with SMTP id 145so161074pfw.13 for ; Tue, 19 May 2020 09:50:04 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gx21sm96685pjb.47.2020.05.19.09.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:50: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=9krfltsdrPyRRqutGHrEb2XJlVU12BnO8AU9UkCykds=; b=saZnCBSHamuCrS7yQ6dkqinrIqi2BifI58CI8L+xnX57s1tBz7fEiGXtRwg8DzcLPf SNG8ndYVJHeqGTwzRmUWegUbxbgD3lzQ8lBGa9rt0MFkoQ9oS1Xb5aRicjFQ/f+Y9ch1 /wKFGW1dOqWTwLxx7btacDyfp3T1Xq7xj1x0A6u/9O5EivRVqhYAS8SIXesI8wLSP62T AMNyTzG0fvP0dw8m3gevxybOAIcOuI52aJvdJ8cLKzUP65D43O1ctHoSmhi6Z6qHR2BA CJTSVXMRhB87PxHBr6vYWOKgtvl+dGIhjDTTRoD4PPj+e05zxWnEBGZgQJCuRbw328RE cyHg== 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=9krfltsdrPyRRqutGHrEb2XJlVU12BnO8AU9UkCykds=; b=N5ZJMQ/6CL2sbbDckkCQdY72eu/1C+zzBQXtZUDsVIkzV5CsyPvV6ujqOl/oQfBPTa FmV+6U+8eBZspzSAhL3SLOqIE+/rI8E9jo5wiYLps+98B7InK4iQYUa+D9+/eYwuNlIn irSR5JJUTzbZ3b0sFfS6ceophfcXS86C61rddX5ijyw4RDaG9RVl5k/RkhPFaQ1j1e9l KnazsRvzTDGbgXJOqXRp6w7ZkOu/uGl+97AI1tsNW58RtdR60AXWNOVI4TbZvMahF5Gf 03+XKCGAKcDBFjE+CMN64Q8a1mEOY9nMdwzu893plmYkWQMlNZ36tvTR2iaVEsu+pXWU TFfg== X-Gm-Message-State: AOAM532eVBpEIDA2Nwgdvh7p8h7qNM7wbBQwHa3mgARuaMgAxFgFRcG6 Bt5H2Iz5CxFOKyOuecBc81gyrhuIPHc= X-Google-Smtp-Source: ABdhPJyBwLv1XFtm3rQ12e4H8e5tXv9YXXRgEP2aBAxGTs6B+YqCRFNvA8Qlxv7QNX/pRE85DcK+ug== X-Received: by 2002:a63:1e4c:: with SMTP id p12mr86745pgm.355.1589907003385; Tue, 19 May 2020 09:50:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/10] softfloat: Change tininess_before_rounding to bool Date: Tue, 19 May 2020 09:49:50 -0700 Message-Id: <20200519164957.26920-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519164957.26920-1-richard.henderson@linaro.org> References: <20200519164957.26920-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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: pass (identity @linaro.org) Slightly tidies the usage within softfloat.c and the representation in float_status. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/fpu/softfloat-helpers.h | 8 ++--- include/fpu/softfloat-types.h | 8 ++--- fpu/softfloat.c | 54 ++++++++++++--------------------- tests/fp/fp-test.c | 2 +- 4 files changed, 28 insertions(+), 44 deletions(-) diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helper= s.h index 528d7ebd9f..40d32a6d5d 100644 --- a/include/fpu/softfloat-helpers.h +++ b/include/fpu/softfloat-helpers.h @@ -53,9 +53,9 @@ this code that are retained. =20 #include "fpu/softfloat-types.h" =20 -static inline void set_float_detect_tininess(int val, float_status *status) +static inline void set_float_detect_tininess(bool val, float_status *statu= s) { - status->float_detect_tininess =3D val; + status->tininess_before_rounding =3D val; } =20 static inline void set_float_rounding_mode(int val, float_status *status) @@ -94,9 +94,9 @@ static inline void set_snan_bit_is_one(bool val, float_st= atus *status) status->snan_bit_is_one =3D val; } =20 -static inline int get_float_detect_tininess(float_status *status) +static inline bool get_float_detect_tininess(float_status *status) { - return status->float_detect_tininess; + return status->tininess_before_rounding; } =20 static inline int get_float_rounding_mode(float_status *status) diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 619b875df6..874ddd9f93 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -116,10 +116,8 @@ typedef struct { * Software IEC/IEEE floating-point underflow tininess-detection mode. */ =20 -enum { - float_tininess_after_rounding =3D 0, - float_tininess_before_rounding =3D 1 -}; +#define float_tininess_after_rounding false +#define float_tininess_before_rounding true =20 /* *Software IEC/IEEE floating-point rounding mode. @@ -158,10 +156,10 @@ enum { */ =20 typedef struct float_status { - signed char float_detect_tininess; signed char float_rounding_mode; uint8_t float_exception_flags; signed char floatx80_rounding_precision; + bool tininess_before_rounding; /* should denormalised results go to zero and set the inexact flag? */ bool flush_to_zero; /* should denormalised inputs go to zero and set the input_denormal fl= ag? */ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index b741cf5bc3..65d457a548 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -744,8 +744,7 @@ static FloatParts round_canonical(FloatParts p, float_s= tatus *s, p.cls =3D float_class_zero; goto do_zero; } else { - bool is_tiny =3D (s->float_detect_tininess - =3D=3D float_tininess_before_rounding) + bool is_tiny =3D s->tininess_before_rounding || (exp < 0) || !((frac + inc) & DECOMPOSED_OVERFLOW_BIT); =20 @@ -3579,11 +3578,9 @@ static float32 roundAndPackFloat32(bool zSign, int z= Exp, uint32_t zSig, float_raise(float_flag_output_denormal, status); return packFloat32(zSign, 0, 0); } - isTiny =3D - (status->float_detect_tininess - =3D=3D float_tininess_before_rounding) - || ( zExp < -1 ) - || ( zSig + roundIncrement < 0x80000000 ); + isTiny =3D status->tininess_before_rounding + || (zExp < -1) + || (zSig + roundIncrement < 0x80000000); shift32RightJamming( zSig, - zExp, &zSig ); zExp =3D 0; roundBits =3D zSig & 0x7F; @@ -3735,11 +3732,9 @@ static float64 roundAndPackFloat64(bool zSign, int z= Exp, uint64_t zSig, float_raise(float_flag_output_denormal, status); return packFloat64(zSign, 0, 0); } - isTiny =3D - (status->float_detect_tininess - =3D=3D float_tininess_before_rounding) - || ( zExp < -1 ) - || ( zSig + roundIncrement < UINT64_C(0x8000000000000000) = ); + isTiny =3D status->tininess_before_rounding + || (zExp < -1) + || (zSig + roundIncrement < UINT64_C(0x8000000000000000)= ); shift64RightJamming( zSig, - zExp, &zSig ); zExp =3D 0; roundBits =3D zSig & 0x3FF; @@ -3878,11 +3873,9 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecisi= on, bool zSign, float_raise(float_flag_output_denormal, status); return packFloatx80(zSign, 0, 0); } - isTiny =3D - (status->float_detect_tininess - =3D=3D float_tininess_before_rounding) - || ( zExp < 0 ) - || ( zSig0 <=3D zSig0 + roundIncrement ); + isTiny =3D status->tininess_before_rounding + || (zExp < 0 ) + || (zSig0 <=3D zSig0 + roundIncrement); shift64RightJamming( zSig0, 1 - zExp, &zSig0 ); zExp =3D 0; roundBits =3D zSig0 & roundMask; @@ -3956,12 +3949,10 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecis= ion, bool zSign, floatx80_infinity_low); } if ( zExp <=3D 0 ) { - isTiny =3D - (status->float_detect_tininess - =3D=3D float_tininess_before_rounding) - || ( zExp < 0 ) - || ! increment - || ( zSig0 < UINT64_C(0xFFFFFFFFFFFFFFFF) ); + isTiny =3D status->tininess_before_rounding + || (zExp < 0) + || !increment + || (zSig0 < UINT64_C(0xFFFFFFFFFFFFFFFF)); shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSi= g1 ); zExp =3D 0; if (isTiny && zSig1) { @@ -4237,17 +4228,12 @@ static float128 roundAndPackFloat128(bool zSign, in= t32_t zExp, float_raise(float_flag_output_denormal, status); return packFloat128(zSign, 0, 0, 0); } - isTiny =3D - (status->float_detect_tininess - =3D=3D float_tininess_before_rounding) - || ( zExp < -1 ) - || ! increment - || lt128( - zSig0, - zSig1, - UINT64_C(0x0001FFFFFFFFFFFF), - UINT64_C(0xFFFFFFFFFFFFFFFF) - ); + isTiny =3D status->tininess_before_rounding + || (zExp < -1) + || !increment + || lt128(zSig0, zSig1, + UINT64_C(0x0001FFFFFFFFFFFF), + UINT64_C(0xFFFFFFFFFFFFFFFF)); shift128ExtraRightJamming( zSig0, zSig1, zSig2, - zExp, &zSig0, &zSig1, &zSig2 ); zExp =3D 0; diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c index 7d0faf2b47..43ef9628c4 100644 --- a/tests/fp/fp-test.c +++ b/tests/fp/fp-test.c @@ -989,7 +989,7 @@ static void QEMU_NORETURN run_test(void) =20 verCases_tininessCode =3D 0; slowfloat_detectTininess =3D tmode; - qsf.float_detect_tininess =3D sf_tininess_to_qemu(tmod= e); + qsf.tininess_before_rounding =3D sf_tininess_to_qemu(t= mode); =20 if (attrs & FUNC_EFF_TININESSMODE || ((attrs & FUNC_EFF_TININESSMODE_REDUCEDPREC) && --=20 2.20.1