From patchwork Fri Dec 12 19:38:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 420648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 05E4814009B for ; Sat, 13 Dec 2014 06:39:17 +1100 (AEDT) Received: from localhost ([::1]:59253 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzW3X-0005wb-8j for incoming@patchwork.ozlabs.org; Fri, 12 Dec 2014 14:39:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzW3A-0005dp-Dy for qemu-devel@nongnu.org; Fri, 12 Dec 2014 14:38:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzW34-0004wQ-9t for qemu-devel@nongnu.org; Fri, 12 Dec 2014 14:38:52 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:42949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzW34-0004wL-4R for qemu-devel@nongnu.org; Fri, 12 Dec 2014 14:38:46 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XzW32-0005Nu-W1 from Maciej_Rozycki@mentor.com ; Fri, 12 Dec 2014 11:38:45 -0800 Received: from localhost (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 12 Dec 2014 19:38:43 +0000 Date: Fri, 12 Dec 2014 19:38:40 +0000 From: "Maciej W. Rozycki" To: Peter Maydell Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] softfloat: Simplify `float128_is_*_nan' functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Don't make separate checks for the trailing significand to be non-zero where the check for the quiet bit being 1 already covers it. The point of the whole expression is to tell inifinities and NaN data apart while also checking for the expected value of the quiet bit, and the quiet bit being 1 in the floating-point datum examined (whether it denotes a qNaN or an sNaN) already makes the datum encoded a NaN rather than an infinity. Signed-off-by: Maciej W. Rozycki --- Peter, This is the cleanup I mentioned yesterday. It makes 128-bit float handling similar to how 16-bit, 32-bit and 64-bit ones already are handled. This is based on the observation that whenever: (a.high << 1) >= 0xffff000000000000 returns true: a.high & 0x0000ffffffffffffULL also does and therefore the RHS of the && expression always evaluates to true if the LHS does (the reverse is obviously not always the case). It applies on top of: https://patchwork.ozlabs.org/patch/420645/ Maciej qemu-softfloat-float128-nan.diff Index: qemu-git-trunk/fpu/softfloat-specialize.h =================================================================== --- qemu-git-trunk.orig/fpu/softfloat-specialize.h 2014-12-11 21:50:59.000000000 +0000 +++ qemu-git-trunk/fpu/softfloat-specialize.h 2014-12-11 21:57:30.338965285 +0000 @@ -1154,8 +1154,7 @@ int float128_is_quiet_nan(float128 a STA int __attribute__ ((unused)) x, y; x = (((a.high >> 47) & 0xffff) == 0xfffe) && (a.low || (a.high & 0x00007fffffffffffULL)); - y = ((a.high << 1) >= 0xffff000000000000) - && (a.low || (a.high & 0x0000ffffffffffffULL)); + y = (a.high << 1) >= 0xffff000000000000; #if SNAN_BIT_IS_VARIABLE return STATUS(nan2008_mode) ? y : x; #elif SNAN_BIT_IS_ONE @@ -1173,8 +1172,7 @@ int float128_is_quiet_nan(float128 a STA int float128_is_signaling_nan(float128 a STATUS_PARAM) { int __attribute__ ((unused)) x, y; - x = ((a.high << 1) >= 0xffff000000000000) - && (a.low || (a.high & 0x0000ffffffffffffULL)); + x = (a.high << 1) >= 0xffff000000000000; y = (((a.high >> 47) & 0xFFFF) == 0xFFFE) && (a.low || (a.high & LIT64(0x00007FFFFFFFFFFF))); #if SNAN_BIT_IS_VARIABLE