From patchwork Fri Feb 22 20:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159081 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2189949jaa; Fri, 22 Feb 2019 13:03:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IbPxb/W5m+PRywlpqlRQvL/H6xNUh4CHt+Ym/2QGgVblCR2/59RKJGmmri7O7LioLpwDWbM X-Received: by 2002:a81:71c5:: with SMTP id m188mr5046549ywc.353.1550869391498; Fri, 22 Feb 2019 13:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550869391; cv=none; d=google.com; s=arc-20160816; b=nor1FuHw8F6FZFaW6osxmZc0EEWrz/SYJm7phH9eVYw331fBcbilWEW3v4F9AAIH4J coRNJXWmA6ElhIy8ymKYus5IJVljY9wH/ywKG11EDXOwLwkBLxXw2HEHT7PjWesYj8Yt Wpc+ZBEsMre2fQZKBI4+prcam5MTLHBAqvIVOCwo3XuvfG71OzCQttSlAWQ9B2ktLKVU myYiwHtNTygOSIU/I+bf2n5K1H44INquR4g+Gsh+OB+R2k0Cp7WY0F/t16Dl219MC5rW Um/kYHv70wDLHadY8wtEudIa2QNBjZCK1/RTp1QxKXRBPUzdGm5Jj2R47/78yYJEp0O+ wWxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=QX9vHdvwnrQQIzWiNBjC4sjIDTbes6ab8cLrV+4UWjE=; b=rwzba86F04El58aptm6TEYKQKoYCh+MRZ1OigZ/KXmC/dfujujlBH6awaHph62Gy8n D3a+eYvyACWcatbwNI5lGTyjcl/h5HhVtIVGMke1qjQXi5AhVUN1euYUHqvOT2QZP8Ot gi56ix6VHlu5cxDAIodfGuB09Z6T/Ifr2/iozLJCF2hM3sIXXNvay3e7oP9kb4xorRbW bwdLRGXCZMdSPcCJ0X2PbC/Pq4w1SUeUvbLS5fONt8wEKyHCyBX5Q3AN/CgzIcTZG/sb ZffuzFAVGR5nyigNorIGZVaZCWbA9thEHel3tqvn2o/pjJGtghbGVc9s9qgPrkev+fez lFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aeqSN+qU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v3si1526757ybc.35.2019.02.22.13.03.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 13:03:11 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aeqSN+qU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHyR-0008Rk-4i for patch@linaro.org; Fri, 22 Feb 2019 16:03:11 -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) 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-Received: by 2002:adf:f9c4:: with SMTP id w4mr4447894wrr.218.1550868302887; Fri, 22 Feb 2019 12:45:02 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , qemu-s390x@nongnu.org, Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 >= 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ée --- include/fpu/softfloat.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.20.1 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) static inline bool float32_is_normal(float32 a) { - return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000; + return (((float32_val(a) >> 23) + 1) & 0xff) >= 2; } static inline bool float32_is_denormal(float32 a) @@ -622,7 +622,7 @@ static inline int float64_is_zero_or_denormal(float64 a) static inline bool float64_is_normal(float64 a) { - return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53; + return (((float64_val(a) >> 52) + 1) & 0x7ff) >= 2; } static inline bool float64_is_denormal(float64 a) @@ -940,6 +940,16 @@ static inline int float128_is_zero_or_denormal(float128 a) return (a.high & 0x7fff000000000000LL) == 0; } +static inline bool float128_is_normal(float128 a) +{ + return (((a.high >> 48) + 1) & 0x7fff) >= 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) == 0x7fff &&