From patchwork Tue Feb 26 14:11: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: 159209 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3266810jad; Tue, 26 Feb 2019 06:17:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IYchRDj83v7QnqBFqyjuuVRwn++bKHZfMcLkoVNusp8DgXrZuJMLr93UsUS0Z4wsibcAKHD X-Received: by 2002:a25:25d4:: with SMTP id l203mr4241924ybl.490.1551190630742; Tue, 26 Feb 2019 06:17:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551190630; cv=none; d=google.com; s=arc-20160816; b=e8aB5aUy3MI7kg8ularMBS96eXMioSOjtalfk1XdhiY56cam5Q3XyPNSnne8xJUUbV ErMtun5L08cYYhWgS59Qj/Hu/c+1GQuEpURQHgcLOZyYBFsiK/abHE0F5wFhVlN6oYSH G3emhIvLIsFWc0t4vNrt6p35P5x6b/xDNFgdVLMrOHLlOgUAjHWUKd90ZlVJyzQy7DOe Fj9GtJqnROp/zltHzypP+B4OFrUBqSy6FvSUBWLt7kt9bwsi6rZ+NWfWpTb4AnULGFh6 OfR27TobFnu3SfQ2igiMedDi1GhDhWGhLB1q6w/uXN+cNb9C+h4I9lqASZN4lIox7V6b IQBA== 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=sCJ8UQ8bltaJu3pSGrfKmiXdjjKmZzFd3nDew7MN8/A=; b=seWc8jhwnwWktCL50bh9iizyUJMgY4lsdefEL5crapHy2cVhciEbVG8Cae8nDWeAWv rvrs472+l0FUPc0FZOi1vk/oNsXGx/WI+zpP1VIvVFDeQxuNBMXdQd2uatFoovUlrY7W uwH40f8E6EST8A2HiLmJqhi6PUDAg9xBsZLjNtBPXI3Org/AtaJ66lZVNYFTebJkM8I3 VvT4QpgbWG4W/Pvt9+BTcz5D+9nNMLpuWi1/n1E2PGR2agKQZVgj9xF8M7umm/N+PzIf Xps/i5f6wrxXfj7M7hO1tL02T6uWaxRBav7jpv4G9svKuC/KDsAhPgkanzqAtc4xxHJM NkAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CPQ6FYtu; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e188si6904749ywa.66.2019.02.26.06.17.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 26 Feb 2019 06:17:10 -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=CPQ6FYtu; 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" Received: from localhost ([127.0.0.1]:56128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gydXi-0002ra-7r for patch@linaro.org; Tue, 26 Feb 2019 09:17:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gydSs-0008Av-RZ for qemu-devel@nongnu.org; Tue, 26 Feb 2019 09:12:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gydSo-0003KD-9m for qemu-devel@nongnu.org; Tue, 26 Feb 2019 09:12:10 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:32835) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gydSo-0003Ir-1s for qemu-devel@nongnu.org; Tue, 26 Feb 2019 09:12:06 -0500 Received: by mail-wr1-x42a.google.com with SMTP id i12so14149851wrw.0 for ; Tue, 26 Feb 2019 06:12:05 -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=sCJ8UQ8bltaJu3pSGrfKmiXdjjKmZzFd3nDew7MN8/A=; b=CPQ6FYtu+mWpjh2qTy88wgIEq4gKctElCPCyPiUX8mwOqwRSeU1GLIgRGAGhIP+Fs/ pJbGoiUmGZkzbZELlxvtz8MNxVOFy0JSr4wfAdbQF8+Q18U9C8WRjAsCmIBJCxTAQ4+C RsU6WdAjErkr9foBL+bDC4s9xPEgqRa7hu6EEt3aZQ8HGdcO2f6CgW22V5AQS3o5y/sh 4aEWhB6hr97oG6XZJLY5okOiJRFkXZDALcCu3ZcInu/Q+1fdU714XGZvPELqK7sii9fW GhBOL8/7Ii4rnnG6QvVCoSYP/93K7ElVgnu1I+yJ91RKRKn58ryu+mkX/+v/Iv5pNu9l FDRw== 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=sCJ8UQ8bltaJu3pSGrfKmiXdjjKmZzFd3nDew7MN8/A=; b=E0ZdIX+2ViL/Big9gFmzl3d2RrUNg28miZ5OZOX0PdhDX8f355SfcqFT8qxhGJ9Nn+ uRmxNzrQmu6GzYmGWnf+9pegisUksJzuu2cjLafgkJMdCwFFbKmMsOHLgygSd3afBKdK 6kfPT4ccTRNdvlM3thEbp/spWEQvgCB0fObWGfEaJZutV0oLbIS11akaBpZUW+NVet45 00IdvCGsC6cfKsY4+k0BZ93kbjYKH1Bb4BP4oNjlM4BmywkuZUbvrRDYl7kV19g9J4ie TFsQjfy+Fl33dQ6VvSZdEFZLJMqpRDetfjrVnAHhsL4URMP+z5yZSycfgT6nd9KXRUZX LH8w== X-Gm-Message-State: AHQUAubgb9I8J/ItinTf9puGhW29VgVJzwzdrtRX+zWae7t25CN16big c1r3yXKlIhDbtqtVpVr/hV7pVg== X-Received: by 2002:a5d:4149:: with SMTP id c9mr17249374wrq.58.1551190324928; Tue, 26 Feb 2019 06:12:04 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 132sm32284205wmd.27.2019.02.26.06.12.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 06:12:02 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E5E991FF83; Tue, 26 Feb 2019 14:12:01 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 26 Feb 2019 14:11:56 +0000 Message-Id: <20190226141201.16999-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226141201.16999-1-alex.bennee@linaro.org> References: <20190226141201.16999-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::42a Subject: [Qemu-devel] [PULL 2/7] 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?= , Richard Henderson , qemu-devel@nongnu.org, david@redhat.com 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 -- 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 &&