From nobody Sun Nov 9 14:46:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550869447681592.7891232533777; Fri, 22 Feb 2019 13:04:07 -0800 (PST) Received: from localhost ([127.0.0.1]:56887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHzB-0000KM-Jp for importer@patchew.org; Fri, 22 Feb 2019 16:03:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHrl-00035y-3m for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgu-0006rf-B7 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:05 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgu-0006q7-0I for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:04 -0500 Received: by mail-wr1-x442.google.com with SMTP id w17so3717702wrn.12 for ; Fri, 22 Feb 2019 12:45:03 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j15sm2559894wrt.1.2019.02.22.12.45.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:00 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8B5F11FF83; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) 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=QX9vHdvwnrQQIzWiNBjC4sjIDTbes6ab8cLrV+4UWjE=; b=aeqSN+qUQ6/xXRZWAc7MMqxYQxQ4U4ENwIhvqQfC17B5SOGqNqWY780HKOFKtubUlT pI0KtCJ72NnCM5ynsumxoPU6aX3R2eosRl0D0nioUpe8Np0z6BQMeqhD0fM8oTYJO+uX XrwscjXhdxZ4DizCohxGnzAjlyOAsTeh3BbZ2KmAiNp5semM/D99T+nMDCGWJ5xym//Z CBS5AC5asCggG6JHwGPN3PFAAM0XKf0Mqjh9LaAlqesdgUMAUkxx5UM8o9LaMQc0eslq Vf1amoAWgkJYBnBPmUgVFOMZqduGx0XY391ngaTjXO3jbgkZGIlrD/0iJfGI7oqneRMn S/TA== 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=QX9vHdvwnrQQIzWiNBjC4sjIDTbes6ab8cLrV+4UWjE=; b=CendGVMWCewCRv2f8FWK+swAhK6110yOsLM7J6iBuzLIeTl1LNSMsxiq7UmrSzWXtN TZhf3XL056vPmu5pz5LUenN8RpxnVgkIFL1AGhlTtZgKX0qoD4BsA0zxcGiEgLZ+3TSz 1OwK/aLhFIyw9SZOLLxV1atN3fAi/51K/3o0VxSVCL/KlD8GdemkLspmgCvHzDSAqWg5 lkM5yo89hQ9CISwjRRNQuNhF+v5MbyhVDN71mb0GOULdg6essNhfwGq085wARw2Umftf fNfSjUrrYqmEtygVKafWkfHwJ98i3HFmLSXXA2r004Cvsn90K+PWKVJaEQv/DtsvMmJ9 BnlQ== X-Gm-Message-State: AHQUAuaoQbyfNThR31mgz2OJxp0m0P6Wyollq+VZJKwqYrdUG8NFRPbV jcitSz8tNVwDlZSJ7YHqyJ82lQ== X-Google-Smtp-Source: AHgI3Ia3/K0z5yGFYcAPt1VJMcj0RDZgkqodEExwUYT5A0tpoi9mvLsBDgtjXusIxvRmzH5M6laT5w== X-Received: by 2002:adf:f9c4:: with SMTP id w4mr4447894wrr.218.1550868302887; Fri, 22 Feb 2019 12:45:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:44:56 +0000 Message-Id: <20190222204500.24434-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@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: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v1 2/6] softfloat: add float128_is_{normal, denormal} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-s390x@nongnu.org, Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: David Hildenbrand Needed on s390x, to test for the data class of a number. So it will gain soon a user. A number is considered normal if the exponent is neither 0 nor all 1's. That can be checked by adding 1 to the exponent, and comparing against >=3D 2 after dropping an eventual overflow into the sign bit. While at it, convert the other floatXX_is_normal functions to use a similar, less error prone calculation, as suggested by Richard H. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- include/fpu/softfloat.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 38a5e99cf3..3ff5215b81 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -466,7 +466,7 @@ static inline int float32_is_zero_or_denormal(float32 a) =20 static inline bool float32_is_normal(float32 a) { - return ((float32_val(a) + 0x00800000) & 0x7fffffff) >=3D 0x01000000; + return (((float32_val(a) >> 23) + 1) & 0xff) >=3D 2; } =20 static inline bool float32_is_denormal(float32 a) @@ -622,7 +622,7 @@ static inline int float64_is_zero_or_denormal(float64 a) =20 static inline bool float64_is_normal(float64 a) { - return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >=3D 1ULL << 53; + return (((float64_val(a) >> 52) + 1) & 0x7ff) >=3D 2; } =20 static inline bool float64_is_denormal(float64 a) @@ -940,6 +940,16 @@ static inline int float128_is_zero_or_denormal(float12= 8 a) return (a.high & 0x7fff000000000000LL) =3D=3D 0; } =20 +static inline bool float128_is_normal(float128 a) +{ + return (((a.high >> 48) + 1) & 0x7fff) >=3D 2; +} + +static inline bool float128_is_denormal(float128 a) +{ + return float128_is_zero_or_denormal(a) && !float128_is_zero(a); +} + static inline int float128_is_any_nan(float128 a) { return ((a.high >> 48) & 0x7fff) =3D=3D 0x7fff && --=20 2.20.1