From patchwork Mon May 14 22:11:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135758 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp186127lji; Mon, 14 May 2018 15:12:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpKRxbQdIPZCd1g8SWpfUoDXXLEebTVNpOxCBSZrgZ3DWUspT/AaZOTkAYn/iZXCFBMEVIw X-Received: by 2002:ac8:330e:: with SMTP id t14-v6mr10890480qta.263.1526335976038; Mon, 14 May 2018 15:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526335976; cv=none; d=google.com; s=arc-20160816; b=KSIACjZ4fli4ZTydlK0nnZHQpSHwPmXpTFyQl+t9lho6E5Z6vM8HPq3+mdS8gOfOe0 JjDUTE/h5Q1n1a9Psp5kbHA36TMd529s+KMVhNfXhMP8gFmMRTgN0056R+mxOka3uReC zfr74P1S1Czh6FeDF+l4+yEEVoKoa7NgsM0+DMlUXTR7qGFnUechqsbBvUj/xxD5pZdF e8A9W+Ncd/2eFI9n3ApOy7yg/lcog/6HDizTw/PXX0gvWi4F6fIafJvaxRrBZsHqfL5R UTDy/QTef331dQlzu9yJdWPf2bJB/tU2Bb3Fela9m4LwR1lavR4oLyb2vo9YV5e+hgIZ lKSQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=/eGeUttM52eudQ5TkxSYzl7bDNiiGBDFDqUuWF7ZJu0=; b=UTR5D7R2T7nIIjcnwoljdiX5148LNhYDrKuf7hLlqlJTcqVkyjJwDp8372rAk0wgua 8saxJemplaemqZpLiIeiBu3ko6EjEs7govQpDVyy+pKW+4OcvH0gpcC1/MjXfT9O71rz P/+1+gUgNaS34yvfYuTXM3whlo28eR5/sRl4NdsXQAwe0K83hN0TOYn/59ydc0yoS5Vp OEhRToV/1TZqiSk4lazZDSasYf3yD3qeSWyJwpDDdUH2Kh9H+rGWQu0Hr6grAH78cpHR a7zh9cfL4F/ELIQHkkmtEgjD2kihfOp4hDq16O8peJT7bM4T6DSAMLNDFqBItQbbJPzM Pd0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PDrBgN8m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m41-v6si5178854qkh.35.2018.05.14.15.12.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PDrBgN8m; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiB-0007oe-8p for patch@linaro.org; Mon, 14 May 2018 18:12:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhj-0007md-CK for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhg-0007I5-W6 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:27 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41374) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhg-0007G0-Pf for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:24 -0400 Received: by mail-pl0-x241.google.com with SMTP id az12-v6so8144532plb.8 for ; Mon, 14 May 2018 15:12:24 -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; bh=/eGeUttM52eudQ5TkxSYzl7bDNiiGBDFDqUuWF7ZJu0=; b=PDrBgN8mttkQhEeVsJ8cF+pl9Uh1C85TtECdJP14WvAzINkIT5cG+JAWvaWvv+8m/8 /AYlMKpUNsl8CYQYJZHJiPC2pv0xzzEb+pZtn+cz3GrAcat9nfr8m+GFVMUvw6jAU0r6 DAdWh5QBKAfPUkfeW2rTm3cy2CVU6PZzyUoRg= 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; bh=/eGeUttM52eudQ5TkxSYzl7bDNiiGBDFDqUuWF7ZJu0=; b=Hmrh+UCOnbuesEYFOHbR6zWHubdn9yLjyyuNhJKOXmYPVTKfu273/o8PGf/D9qwjpy +vqq/OBmOBxj3Zr4Oe6SPpNAl5sgSL1GaXTOIeji9Um3RxbdoMFszzZ9zjody2/0EJSn GCeLS5LUdik8A7gAKpOiZPcvOZ8QPB9OTInJFoIt++oA51IvRD42ZIZ38Ho+HoqFNuMo 0E9Xr8t6FzZxcPmIwnZTzDHjdzY9XgJFv/4UNXEblaNMMlIIQIC9gUrNCCvNDg41GMBp HUg8yooxJnhCzrwc4BGG2tQyhff7DaljBn3LWDNhfvpC46aQxqwGWXYkyyDgLYwZAKsS ++8g== X-Gm-Message-State: ALKqPwf7QVd6WnakvDk4bzITeCeML0jkTuleYWzPytzVcjxDAaGjT1z/ 13VV4dgA3dvkbHi9Jwp2jwYA2d5KvsE= X-Received: by 2002:a17:902:7288:: with SMTP id d8-v6mr11624458pll.218.1526335943603; Mon, 14 May 2018 15:12:23 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:52 -0700 Message-Id: <20180514221219.7091-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v5 01/28] fpu/softfloat: Fix conversion from uint64 to float128 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: peter.maydell@linaro.org, alex.bennee@linaro.org, qemu-stable@nongnu.org, Petr Tesarik Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Petr Tesarik The significand is passed to normalizeRoundAndPackFloat128() as high first, low second. The current code passes the integer first, so the result is incorrectly shifted left by 64 bits. This bug affects the emulation of s390x instruction CXLGBR (convert from logical 64-bit binary-integer operand to extended BFP result). Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Petr Tesarik Message-Id: <20180511071052.1443-1-ptesarik@suse.com> Signed-off-by: Richard Henderson --- fpu/softfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat.c b/fpu/softfloat.c index bc0f52fa54..d07419324a 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3147,7 +3147,7 @@ float128 uint64_to_float128(uint64_t a, float_status *status) if (a == 0) { return float128_zero; } - return normalizeRoundAndPackFloat128(0, 0x406E, a, 0, status); + return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status); } From patchwork Mon May 14 22:11:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135762 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp188690lji; Mon, 14 May 2018 15:15:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo01x+vdcHgm+ET+mt/HExES93n5GPdfEFToqL8lmWl1lJeH6lD1ybL6h5FRgvQZXpcuFnE X-Received: by 2002:aed:2785:: with SMTP id a5-v6mr10782195qtd.249.1526336156541; Mon, 14 May 2018 15:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336156; cv=none; d=google.com; s=arc-20160816; b=k+EKwGBLkt633GwYy/kLAlw4aJsSb73umJzHC9oQBfHInVdm96rJ51CrvEH3mkZ87U 23Z+R3OHoLOJynUFpkd75ZsR961531IKo6Um0HJK2JCofje+h99e8gKRdCoGpIH8Fj8b rm1jkbB0n7eciBuZwez6rdq8GFtePrjgXPA+TDugms09IlkLnv10YyY1m0MeAY/sY7DY y6mpIU8txoRDW3ktFuiMM1tPYcj+xizzx7Sy0kmhqvo4dzNjaRXa0APgX8GTHBvop4+J LLW2o2Gpgy9A7x67WNQ3KjUfZzUQNkkRvFgP66WhW6MIX7pyvwkKlnNavcnn0Bc6BNrw ACJQ== 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:arc-authentication-results; bh=VenDa8tHdyNBHcmt5bnMZDmY8bNh2PQHuQqyvWp2pMY=; b=VWzVI8HArHkGFEJLuQeiZHl3BLIXh7aeKf66M1ap0JVjxSZOP3IGSXExS0EDgSgdQP /Sm6CYah2wDE54BR7PK1fWQTF/d+eU3DOpeYB4w78C4svbSZ8FpslJ7k8K3lqm9q19nu meq5TW0Ame3BjZFSXTOckKFzrShQLSieOtj7MvqjWUC66Fl7rBNcvE/dgzjMVa0onK2g khQZitGWcFWq2HVGnCs5Ag9ZiQFiVnCRrsvWovUGbIF7Umidt9FebS4H7e+Qv9XmgFWE svPbhcOjtNkEnh8TZdRUYT7ymDs0Xp9grT1IwvXHsD9LK2Nc9ea36ODepjkttCGcqlY1 eLKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WohpFkAc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e15-v6si1189500qtp.63.2018.05.14.15.15.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:15:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WohpFkAc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILl5-0002P9-QV for patch@linaro.org; Mon, 14 May 2018 18:15:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhk-0007nM-Ef for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhi-0007Ku-Iy for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:28 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:46770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhi-0007Jj-9E for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:26 -0400 Received: by mail-pl0-x243.google.com with SMTP id 30-v6so3308922pld.13 for ; Mon, 14 May 2018 15:12:26 -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=VenDa8tHdyNBHcmt5bnMZDmY8bNh2PQHuQqyvWp2pMY=; b=WohpFkAcq05POrNffnXj2V8fJy0pVhcbyNhEI0mRWw2/nHZt0+rUfwwsqyD/GVKHH2 FgYW2VmA3QX2NBMyjHaJZaE5TpJkvv4DaRlMkmehEp3p4ellWhmtgsU6fiQgsgpa35FW IkmMbW0chbK6hcU5l5m3jdJsMzATLJy6ObnJI= 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=VenDa8tHdyNBHcmt5bnMZDmY8bNh2PQHuQqyvWp2pMY=; b=nSc8G1V1L7R7lSus+d15Y1XkqbcZ857UjJd621SnIkEfTUQ29uh9/SUUtPTmRFrHPz 4CcJk4bREYNCToQffuKW6SWEKSNJNTCwqcexxRU6qwTKl94s1q3JraAm2kXig9iJSvLy +dKGWLBx+ih6nQtMnww4BxzgmBe3d5JSlcDL/F8n8+d4KNaHdz/Vrb7Vc+vHUU3d61qE 6ckSNAPzI52aJeXOHFI4PYUEZn99YJ+4ipEQGORtpWu9cVhPYLA5gzvOZTLE99Yxo5O/ wtRJwExyvFyc9qL7eroJmHV1kWhlxSkvD9q2BZfSPj6lMxdsqKOh+X5NKTIxKWTULv0A Ed9Q== X-Gm-Message-State: ALKqPweOaOm3UjKRC4oWHcndvN9wbNX7B7Frg/TPZ9/H5+xlWBmqD6kV qR3suoZ+7+hrflS6MbNBNiHFvWUIHRA= X-Received: by 2002:a17:902:b949:: with SMTP id h9-v6mr11550052pls.146.1526335944926; Mon, 14 May 2018 15:12:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:53 -0700 Message-Id: <20180514221219.7091-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v5 02/28] fpu/softfloat: Merge NO_SIGNALING_NANS definitions 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the ifdef inside the relevant functions instead of duplicating the function declarations. Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 100 +++++++++++++++---------------------- 1 file changed, 40 insertions(+), 60 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 27834af0de..58b05718c8 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -233,17 +233,6 @@ typedef struct { uint64_t high, low; } commonNaNT; -#ifdef NO_SIGNALING_NANS -int float16_is_quiet_nan(float16 a_, float_status *status) -{ - return float16_is_any_nan(a_); -} - -int float16_is_signaling_nan(float16 a_, float_status *status) -{ - return 0; -} -#else /*---------------------------------------------------------------------------- | Returns 1 if the half-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -251,12 +240,16 @@ int float16_is_signaling_nan(float16 a_, float_status *status) int float16_is_quiet_nan(float16 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float16_is_any_nan(a_); +#else uint16_t a = float16_val(a_); if (status->snan_bit_is_one) { return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF); } else { return ((a & ~0x8000) >= 0x7C80); } +#endif } /*---------------------------------------------------------------------------- @@ -266,14 +259,17 @@ int float16_is_quiet_nan(float16 a_, float_status *status) int float16_is_signaling_nan(float16 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else uint16_t a = float16_val(a_); if (status->snan_bit_is_one) { return ((a & ~0x8000) >= 0x7C80); } else { return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF); } -} #endif +} /*---------------------------------------------------------------------------- | Returns a quiet NaN if the half-precision floating point value `a' is a @@ -333,17 +329,6 @@ static float16 commonNaNToFloat16(commonNaNT a, float_status *status) } } -#ifdef NO_SIGNALING_NANS -int float32_is_quiet_nan(float32 a_, float_status *status) -{ - return float32_is_any_nan(a_); -} - -int float32_is_signaling_nan(float32 a_, float_status *status) -{ - return 0; -} -#else /*---------------------------------------------------------------------------- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -351,12 +336,16 @@ int float32_is_signaling_nan(float32 a_, float_status *status) int float32_is_quiet_nan(float32 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float32_is_any_nan(a_); +#else uint32_t a = float32_val(a_); if (status->snan_bit_is_one) { return (((a >> 22) & 0x1FF) == 0x1FE) && (a & 0x003FFFFF); } else { return ((uint32_t)(a << 1) >= 0xFF800000); } +#endif } /*---------------------------------------------------------------------------- @@ -366,14 +355,17 @@ int float32_is_quiet_nan(float32 a_, float_status *status) int float32_is_signaling_nan(float32 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else uint32_t a = float32_val(a_); if (status->snan_bit_is_one) { return ((uint32_t)(a << 1) >= 0xFF800000); } else { return (((a >> 22) & 0x1FF) == 0x1FE) && (a & 0x003FFFFF); } -} #endif +} /*---------------------------------------------------------------------------- | Returns a quiet NaN if the single-precision floating point value `a' is a @@ -744,17 +736,6 @@ static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status) } } -#ifdef NO_SIGNALING_NANS -int float64_is_quiet_nan(float64 a_, float_status *status) -{ - return float64_is_any_nan(a_); -} - -int float64_is_signaling_nan(float64 a_, float_status *status) -{ - return 0; -} -#else /*---------------------------------------------------------------------------- | Returns 1 if the double-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -762,6 +743,9 @@ int float64_is_signaling_nan(float64 a_, float_status *status) int float64_is_quiet_nan(float64 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float64_is_any_nan(a_); +#else uint64_t a = float64_val(a_); if (status->snan_bit_is_one) { return (((a >> 51) & 0xFFF) == 0xFFE) @@ -769,6 +753,7 @@ int float64_is_quiet_nan(float64 a_, float_status *status) } else { return ((a << 1) >= 0xFFF0000000000000ULL); } +#endif } /*---------------------------------------------------------------------------- @@ -778,6 +763,9 @@ int float64_is_quiet_nan(float64 a_, float_status *status) int float64_is_signaling_nan(float64 a_, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else uint64_t a = float64_val(a_); if (status->snan_bit_is_one) { return ((a << 1) >= 0xFFF0000000000000ULL); @@ -785,8 +773,8 @@ int float64_is_signaling_nan(float64 a_, float_status *status) return (((a >> 51) & 0xFFF) == 0xFFE) && (a & LIT64(0x0007FFFFFFFFFFFF)); } -} #endif +} /*---------------------------------------------------------------------------- | Returns a quiet NaN if the double-precision floating point value `a' is a @@ -899,17 +887,6 @@ static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status) } } -#ifdef NO_SIGNALING_NANS -int floatx80_is_quiet_nan(floatx80 a_, float_status *status) -{ - return floatx80_is_any_nan(a_); -} - -int floatx80_is_signaling_nan(floatx80 a_, float_status *status) -{ - return 0; -} -#else /*---------------------------------------------------------------------------- | Returns 1 if the extended double-precision floating-point value `a' is a | quiet NaN; otherwise returns 0. This slightly differs from the same @@ -918,6 +895,9 @@ int floatx80_is_signaling_nan(floatx80 a_, float_status *status) int floatx80_is_quiet_nan(floatx80 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return floatx80_is_any_nan(a); +#else if (status->snan_bit_is_one) { uint64_t aLow; @@ -929,6 +909,7 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *status) return ((a.high & 0x7FFF) == 0x7FFF) && (LIT64(0x8000000000000000) <= ((uint64_t)(a.low << 1))); } +#endif } /*---------------------------------------------------------------------------- @@ -939,6 +920,9 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *status) int floatx80_is_signaling_nan(floatx80 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else if (status->snan_bit_is_one) { return ((a.high & 0x7FFF) == 0x7FFF) && ((a.low << 1) >= 0x8000000000000000ULL); @@ -950,8 +934,8 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) && (uint64_t)(aLow << 1) && (a.low == aLow); } -} #endif +} /*---------------------------------------------------------------------------- | Returns a quiet NaN if the extended double-precision floating point value @@ -1060,17 +1044,6 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) } } -#ifdef NO_SIGNALING_NANS -int float128_is_quiet_nan(float128 a_, float_status *status) -{ - return float128_is_any_nan(a_); -} - -int float128_is_signaling_nan(float128 a_, float_status *status) -{ - return 0; -} -#else /*---------------------------------------------------------------------------- | Returns 1 if the quadruple-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -1078,6 +1051,9 @@ int float128_is_signaling_nan(float128 a_, float_status *status) int float128_is_quiet_nan(float128 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return float128_is_any_nan(a); +#else if (status->snan_bit_is_one) { return (((a.high >> 47) & 0xFFFF) == 0xFFFE) && (a.low || (a.high & 0x00007FFFFFFFFFFFULL)); @@ -1085,6 +1061,7 @@ int float128_is_quiet_nan(float128 a, float_status *status) return ((a.high << 1) >= 0xFFFF000000000000ULL) && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL)); } +#endif } /*---------------------------------------------------------------------------- @@ -1094,6 +1071,9 @@ int float128_is_quiet_nan(float128 a, float_status *status) int float128_is_signaling_nan(float128 a, float_status *status) { +#ifdef NO_SIGNALING_NANS + return 0; +#else if (status->snan_bit_is_one) { return ((a.high << 1) >= 0xFFFF000000000000ULL) && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL)); @@ -1101,8 +1081,8 @@ int float128_is_signaling_nan(float128 a, float_status *status) return (((a.high >> 47) & 0xFFFF) == 0xFFFE) && (a.low || (a.high & LIT64(0x00007FFFFFFFFFFF))); } -} #endif +} /*---------------------------------------------------------------------------- | Returns a quiet NaN if the quadruple-precision floating point value `a' is From patchwork Mon May 14 22:11:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135759 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp186484lji; Mon, 14 May 2018 15:13:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq+tZ5BbkDUUxA+f2xhrPlYmT/VCSxC+g4yDTMoYqMv0jYiyPauY1BmUerECQ7pA2YueEsS X-Received: by 2002:a0c:bd99:: with SMTP id n25-v6mr10724956qvg.137.1526336002188; Mon, 14 May 2018 15:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336002; cv=none; d=google.com; s=arc-20160816; b=CHSdoeD3j5ppSHI2SumHNrnljXkAd9iZsKI1ojZC6TBYeX2kxk4gDN+YYcQ5cu8ZFJ YVf82VtafzPiapyeWT4cC82+/4OiHnKyvnb+DC/ZT1kHQfeu/awbWM8nzn1N3ya72eNP /cTvJmAc8M+a2OLg3qMuYwwDtNxKEi8GqBost5En57gtGHKWSjTCjnmxQ1qkb5mh7Tbc 28TK3By2SjlCTfkNVQHGhr+buv+4066Jd0FJaNA+KSMyEa4+CWO6Ud52kjhTF34Dns4z UGtxSZ3utZbTNs5gP91fWGIk5NRk8KU9L/Q04lNDCLCw6J+dN+pVFibsIYfi0x5tEKD7 nZiA== 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:arc-authentication-results; bh=4TmTQacKaQ7wTQhVbzzcmlNjpPvSpyKeaBJzKv3A39I=; b=fKUXIjydQRTg9goMAWmDqPL0/ryzN82FcN+KOSJbSU158Zrz4YRycCJlNcXCnMO1y5 CA7HNs4EJyU1D+g6Kzxt3UujxBOcvv4tXtHBJXsFrG6WDFzJ7Ax/xaDHB2uSwDYn2OOg XUFRcGNmGc1j6AWrIW6V3oRLkOOA3FIIEzjD9mbqyUgCTEEmeJaW0Xnxq9TJomTBq1KK 5thcgjnDjN4vSqNMje2L+TW3sO4v/pyp+YLjRmkA9TtJ8/AA20J3I81xoi7pnKsLWQEr 4RCkSBIG3o9XIoOONKLiby3mvoa7+jwEpl6T5x7V8fQfCBgLjA9wqhvy0YnBJck2JaQk AGew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XdPzEuQN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c189-v6si2906520qkd.185.2018.05.14.15.13.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XdPzEuQN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILib-0008Bh-Fw for patch@linaro.org; Mon, 14 May 2018 18:13:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhm-0007oZ-0D for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhk-0007Ob-7q for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:29 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:39427) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhj-0007Ms-VV for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:28 -0400 Received: by mail-pg0-x242.google.com with SMTP id e1-v6so6066289pga.6 for ; Mon, 14 May 2018 15:12:27 -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=4TmTQacKaQ7wTQhVbzzcmlNjpPvSpyKeaBJzKv3A39I=; b=XdPzEuQNnOfED3+9kvdKHKdL7p1IhD6hDJ3kACFDuuu2+e/j5CrmZVQxYJQ1m5YtGz 7WSmuArybPuz2X6VEzsZi7iQyjE/kZtEfL9KBHuWCZrSnw3D7Saq76fkSONFVVDDS/ct DqYW8M35rePv+TbfZZFVCPO+tKEz1bMFSbBtM= 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=4TmTQacKaQ7wTQhVbzzcmlNjpPvSpyKeaBJzKv3A39I=; b=otdiz30PZ1mVx1nS3keyvMMu873MN/He4kRGOyQX9HD3mJNeyWBSwcqTNqLDJdcQQP kO0tNeT3vvlwKuPqMI9ear3xrMEDEEYi5KhuLmDIQvWUQqPI4GB+FAuAryqrw/HxUm8K p6gUsDF3vAMRG4wPyGIh9bqqEUXeg6RyC7Pd1Gy5xkdIZT/0lN0+4hA3DXKb+H1M/9vD lRbQDSyoCbEhgtwDzbGFWaaKBq9M/jZbRbbqEz5wA/dsLwv+ybIZLKFbsFrSZx5pmGcf O17PfzSnibGQH6kJeK4raJ3hQCHV2McXg/QyUVWBolpGPK1QjKUBkl5NCeUESXosCbFm QASA== X-Gm-Message-State: ALKqPwdOCxYz198ARc+sG1IP7W0lP8sNOMRhoVIS9QWov7DT0mSxezmO qiJr0z8Pxyg9QfTnvH7VXR3XXwJa66U= X-Received: by 2002:a62:3d54:: with SMTP id k81-v6mr12140164pfa.193.1526335946515; Mon, 14 May 2018 15:12:26 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:54 -0700 Message-Id: <20180514221219.7091-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v5 03/28] fpu/softfloat: Split floatXX_silence_nan from floatXX_maybe_silence_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The new function assumes that the input is an SNaN and does not double-check. Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 174 +++++++++++++++++++++++++------------ include/fpu/softfloat.h | 5 ++ 2 files changed, 123 insertions(+), 56 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 58b05718c8..4fc9ea4ac0 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -271,22 +271,35 @@ int float16_is_signaling_nan(float16 a_, float_status *status) #endif } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the half-precision +| floating point value `a'. +*----------------------------------------------------------------------------*/ + +float16 float16_silence_nan(float16 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { + return float16_default_nan(status); + } else { + return a | (1 << 9); + } +#endif +} + /*---------------------------------------------------------------------------- | Returns a quiet NaN if the half-precision floating point value `a' is a | signaling NaN; otherwise returns `a'. *----------------------------------------------------------------------------*/ -float16 float16_maybe_silence_nan(float16 a_, float_status *status) + +float16 float16_maybe_silence_nan(float16 a, float_status *status) { - if (float16_is_signaling_nan(a_, status)) { - if (status->snan_bit_is_one) { - return float16_default_nan(status); - } else { - uint16_t a = float16_val(a_); - a |= (1 << 9); - return make_float16(a); - } + if (float16_is_signaling_nan(a, status)) { + return float16_silence_nan(a, status); } - return a_; + return a; } /*---------------------------------------------------------------------------- @@ -367,30 +380,40 @@ int float32_is_signaling_nan(float32 a_, float_status *status) #endif } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the single-precision +| floating point value `a'. +*----------------------------------------------------------------------------*/ + +float32 float32_silence_nan(float32 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { +# ifdef TARGET_HPPA + a &= ~0x00400000; + a |= 0x00200000; + return a; +# else + return float32_default_nan(status); +# endif + } else { + return a | (1 << 22); + } +#endif +} /*---------------------------------------------------------------------------- | Returns a quiet NaN if the single-precision floating point value `a' is a | signaling NaN; otherwise returns `a'. *----------------------------------------------------------------------------*/ -float32 float32_maybe_silence_nan(float32 a_, float_status *status) +float32 float32_maybe_silence_nan(float32 a, float_status *status) { - if (float32_is_signaling_nan(a_, status)) { - if (status->snan_bit_is_one) { -#ifdef TARGET_HPPA - uint32_t a = float32_val(a_); - a &= ~0x00400000; - a |= 0x00200000; - return make_float32(a); -#else - return float32_default_nan(status); -#endif - } else { - uint32_t a = float32_val(a_); - a |= (1 << 22); - return make_float32(a); - } + if (float32_is_signaling_nan(a, status)) { + return float32_silence_nan(a, status); } - return a_; + return a; } /*---------------------------------------------------------------------------- @@ -776,30 +799,41 @@ int float64_is_signaling_nan(float64 a_, float_status *status) #endif } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the double-precision +| floating point value `a'. +*----------------------------------------------------------------------------*/ + +float64 float64_silence_nan(float64 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { +# ifdef TARGET_HPPA + a &= ~0x0008000000000000ULL; + a |= 0x0004000000000000ULL; + return a; +# else + return float64_default_nan(status); +# endif + } else { + return a | LIT64(0x0008000000000000); + } +#endif +} + /*---------------------------------------------------------------------------- | Returns a quiet NaN if the double-precision floating point value `a' is a | signaling NaN; otherwise returns `a'. *----------------------------------------------------------------------------*/ -float64 float64_maybe_silence_nan(float64 a_, float_status *status) +float64 float64_maybe_silence_nan(float64 a, float_status *status) { - if (float64_is_signaling_nan(a_, status)) { - if (status->snan_bit_is_one) { -#ifdef TARGET_HPPA - uint64_t a = float64_val(a_); - a &= ~0x0008000000000000ULL; - a |= 0x0004000000000000ULL; - return make_float64(a); -#else - return float64_default_nan(status); -#endif - } else { - uint64_t a = float64_val(a_); - a |= LIT64(0x0008000000000000); - return make_float64(a); - } + if (float64_is_signaling_nan(a, status)) { + return float64_silence_nan(a, status); } - return a_; + return a; } /*---------------------------------------------------------------------------- @@ -937,6 +971,25 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) #endif } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the extended double-precision +| floating point value `a'. +*----------------------------------------------------------------------------*/ + +floatx80 floatx80_silence_nan(floatx80 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { + return floatx80_default_nan(status); + } else { + a.low |= LIT64(0xC000000000000000); + return a; + } +#endif +} + /*---------------------------------------------------------------------------- | Returns a quiet NaN if the extended double-precision floating point value | `a' is a signaling NaN; otherwise returns `a'. @@ -945,12 +998,7 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) floatx80 floatx80_maybe_silence_nan(floatx80 a, float_status *status) { if (floatx80_is_signaling_nan(a, status)) { - if (status->snan_bit_is_one) { - a = floatx80_default_nan(status); - } else { - a.low |= LIT64(0xC000000000000000); - return a; - } + return floatx80_silence_nan(a, status); } return a; } @@ -1084,6 +1132,25 @@ int float128_is_signaling_nan(float128 a, float_status *status) #endif } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the quadruple-precision +| floating point value `a'. +*----------------------------------------------------------------------------*/ + +float128 float128_silence_nan(float128 a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#else + if (status->snan_bit_is_one) { + return float128_default_nan(status); + } else { + a.high |= LIT64(0x0000800000000000); + return a; + } +#endif +} + /*---------------------------------------------------------------------------- | Returns a quiet NaN if the quadruple-precision floating point value `a' is | a signaling NaN; otherwise returns `a'. @@ -1092,12 +1159,7 @@ int float128_is_signaling_nan(float128 a, float_status *status) float128 float128_maybe_silence_nan(float128 a, float_status *status) { if (float128_is_signaling_nan(a, status)) { - if (status->snan_bit_is_one) { - a = float128_default_nan(status); - } else { - a.high |= LIT64(0x0000800000000000); - return a; - } + return float128_silence_nan(a, status); } return a; } diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 36626a501b..43962dc3f5 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -257,6 +257,7 @@ int float16_compare_quiet(float16, float16, float_status *status); int float16_is_quiet_nan(float16, float_status *status); int float16_is_signaling_nan(float16, float_status *status); +float16 float16_silence_nan(float16, float_status *status); float16 float16_maybe_silence_nan(float16, float_status *status); static inline int float16_is_any_nan(float16 a) @@ -368,6 +369,7 @@ float32 float32_minnummag(float32, float32, float_status *status); float32 float32_maxnummag(float32, float32, float_status *status); int float32_is_quiet_nan(float32, float_status *status); int float32_is_signaling_nan(float32, float_status *status); +float32 float32_silence_nan(float32, float_status *status); float32 float32_maybe_silence_nan(float32, float_status *status); float32 float32_scalbn(float32, int, float_status *status); @@ -497,6 +499,7 @@ float64 float64_minnummag(float64, float64, float_status *status); float64 float64_maxnummag(float64, float64, float_status *status); int float64_is_quiet_nan(float64 a, float_status *status); int float64_is_signaling_nan(float64, float_status *status); +float64 float64_silence_nan(float64, float_status *status); float64 float64_maybe_silence_nan(float64, float_status *status); float64 float64_scalbn(float64, int, float_status *status); @@ -600,6 +603,7 @@ int floatx80_compare(floatx80, floatx80, float_status *status); int floatx80_compare_quiet(floatx80, floatx80, float_status *status); int floatx80_is_quiet_nan(floatx80, float_status *status); int floatx80_is_signaling_nan(floatx80, float_status *status); +floatx80 floatx80_silence_nan(floatx80, float_status *status); floatx80 floatx80_maybe_silence_nan(floatx80, float_status *status); floatx80 floatx80_scalbn(floatx80, int, float_status *status); @@ -811,6 +815,7 @@ int float128_compare(float128, float128, float_status *status); int float128_compare_quiet(float128, float128, float_status *status); int float128_is_quiet_nan(float128, float_status *status); int float128_is_signaling_nan(float128, float_status *status); +float128 float128_silence_nan(float128, float_status *status); float128 float128_maybe_silence_nan(float128, float_status *status); float128 float128_scalbn(float128, int, float_status *status); From patchwork Mon May 14 22:11:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135766 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp191356lji; Mon, 14 May 2018 15:19:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFWmS3V0V0IhdvQBGKfsc8KPgMlSvv0M4tZNq9O0+IF4uOW2Lm/BtuoMElpS5npI28bknc X-Received: by 2002:ae9:ed02:: with SMTP id c2-v6mr3342586qkg.111.1526336364022; Mon, 14 May 2018 15:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336364; cv=none; d=google.com; s=arc-20160816; b=h6i0Q+X5rdkr7o+rwQ646VCxANZX4XIgN7FgJXy6VKE4b93Pdgs+zY9zK3G6VJv6ZB lXKow4PAy/zArTw0Dl4uwhHl0ihJczUOW5EwS3SzTRQ11VRx59PZFdlISeV3LclNiLro rknsTUExtoreaKlD2EGn2S05CBSno3/kdWc663Argg8BGlvSiQ2jFAOVD6JtrdnoNHDN f57tDCO3iWpzC4mb6zLcOqwMdXX/FCiM65LTYGLbHVJKe9EkLs5rSZczbq3uUTiq/wh7 mQWuLQEr2hrkvuC7D0m4M3P9RaBhk6unoQ6fW6A4rn8L+eOu4NVeQp8AQ3rdlk5Of/eJ yGhg== 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:arc-authentication-results; bh=ebFxh3+eguD7gF5K8+FfZvuBwarnBxL0aNh5uRBWCAs=; b=Zv3hHi0eNo5vLGy5pdjAvAYgRpMrFJpvPjlHXXMyVra4jrgaPt6ZdvbwnGrEmq9w4k mZVcHn/gJmGJUGmBAhbZBOld0FZuye+YaDh+vSHNnkuKyD+x335Kl2YKD7AztA4JIwYP nrMYGozvtKg4TiaBsz5vHJQ8o3QtKxMUCca8YcyK5I4kmUWzPwA/hNjYEtTIXamMVbmh JaCf+r++yawDVxc2HkZ67oj1tO2qAQNlLI7EkWyA3lkL+YVn+4E4mzL98C7bI/Zb/0Di +STZAQ4gFe+tjCzURF/Xa86jJXdGJ67fvuAABF8ocRRZmsyp3Wp9Wq3P9XcgFCgqcHP1 S7Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cD6+Nu78; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o6-v6si6710593qvb.108.2018.05.14.15.19.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:19:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cD6+Nu78; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILoR-0004EO-Br for patch@linaro.org; Mon, 14 May 2018 18:19:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhl-0007oW-Vn for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhl-0007Qj-0K for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:29 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhk-0007Om-RG for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:28 -0400 Received: by mail-pg0-x244.google.com with SMTP id v7-v6so3276339pgs.0 for ; Mon, 14 May 2018 15:12:28 -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=ebFxh3+eguD7gF5K8+FfZvuBwarnBxL0aNh5uRBWCAs=; b=cD6+Nu783+P3CV39HIkihsJG14Lpep8gWzTnWD3crTjqZolahDVU1wfb74Z29WYqjS OGqaE1hwT7rYxjO//2TTGjmsryKwcpVXVaidiJfaVH3HlCbuy/Jw9+FXuXaSp7VM9Zpc 2rDWMVRyY5vbV0/2Ktt1maSyzg1ijdKqImdvg= 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=ebFxh3+eguD7gF5K8+FfZvuBwarnBxL0aNh5uRBWCAs=; b=gmJbuwpDqG3prz69dE2i//iyps9APLS8BYl6iU8VuVytS05jMLWT5HcSLic1T5PxOD 9WfG87XY6lMujBjhazbWsrJvthGByAA9WpYVAER7MZwVU9PzxLa7vYqUYky1az5Sv+TZ h9uCNPNk+UZbl69W1CGb3CGbWrYwVt07+O3CL5AvAdJA0UlDBMeudv0M0jWG7BJIfvr+ hrH9dOv0J/tk0E2MBUxulQm7hqvSP5nG0jhMv4YE9uhYI9qCrwe5fXQIGBl5bgVfzdc3 d8+DD+VhSlcFX/z2N2jbRuN366JaoA2tNTmtyoGDCDTth4MzoPayh5GvQRRxuVoioUwy 5pBA== X-Gm-Message-State: ALKqPweJfcimnJ/fk/9Yr24seKORFFXKnAH5HgITAkPy8+UCz7x+C+yw KqD9kQceq/ZBlVIyoQC+BMRcZEYalGs= X-Received: by 2002:a62:3889:: with SMTP id f131-v6mr12184027pfa.173.1526335947560; Mon, 14 May 2018 15:12:27 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:55 -0700 Message-Id: <20180514221219.7091-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v5 04/28] fpu/softfloat: Move softfloat-specialize.h below FloatParts definition 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We want to be able to specialize on the canonical representation. Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- fpu/softfloat.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index d07419324a..0d17027379 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -95,16 +95,6 @@ this code that are retained. *----------------------------------------------------------------------------*/ #include "fpu/softfloat-macros.h" -/*---------------------------------------------------------------------------- -| Functions and definitions to determine: (1) whether tininess for underflow -| is detected before or after rounding by default, (2) what (if anything) -| happens when exceptions are raised, (3) how signaling NaNs are distinguished -| from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs -| are propagated from function inputs to output. These details are target- -| specific. -*----------------------------------------------------------------------------*/ -#include "softfloat-specialize.h" - /*---------------------------------------------------------------------------- | Returns the fraction bits of the half-precision floating-point value `a'. *----------------------------------------------------------------------------*/ @@ -322,6 +312,16 @@ static inline float64 float64_pack_raw(FloatParts p) return make_float64(pack_raw(float64_params, p)); } +/*---------------------------------------------------------------------------- +| Functions and definitions to determine: (1) whether tininess for underflow +| is detected before or after rounding by default, (2) what (if anything) +| happens when exceptions are raised, (3) how signaling NaNs are distinguished +| from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs +| are propagated from function inputs to output. These details are target- +| specific. +*----------------------------------------------------------------------------*/ +#include "softfloat-specialize.h" + /* Canonicalize EXP and FRAC, setting CLS. */ static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, float_status *status) From patchwork Mon May 14 22:11:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135760 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp187535lji; Mon, 14 May 2018 15:14:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrScIbHkA1N/ZJjzesc/pTx64WZ2KmAGgNFlCKlROqsauV23enghbjPQF3sGLCj/7enBnYT X-Received: by 2002:ae9:c10e:: with SMTP id z14-v6mr3562516qki.323.1526336079761; Mon, 14 May 2018 15:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336079; cv=none; d=google.com; s=arc-20160816; b=vYIEdyEVy3P4LWvBBzWok1QYKs+d7DWsWISm03M/KGSOTwlHdRT8rhqQR4zLIZFtyo v4v9jRe+jXR3VtThjNiH8c1MGQ4wzz0WnHpIyhLIiceJhXuk/0px8Fc2Jrrc8Ylmc2Rt Y7TOUCDy5fqZls9a26vVsl3zQrIqGhNfY0x4sUPjSh5DES3rCD/iSD2MgnM6xWhrdio8 rplUw12X5gZwfq6P+pQl6XgN4u2LX1k1MenuhfNqg2Z5EAUHnylcVqBDMMkktC7i7SPv Bqd4wJ+E9nP6ce1vp+MQHV6SJFNMzM7PUdjwX1xi6dPh+VFQDl+F1vsiwa2Basp30NoU 1TqQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=VrjybWtyS9x1dk/X8ACHYXOClLJ40q5WBHgCIV0De2Q=; b=ZwRtHbsFcvEltHsaeqdF+bJM9+ecwmiQJhFLi7TW4VtDL0/m0eCoNVaKUrxEISUBqy n2vM5XloSC7HO2wntFK3EhnU/nd6dKRYIucbKeNjQkKOlYelI9lWC/9GgAU0jaENS/5/ ovZxt6iJe16C+EOoR0o6S0SGmnAxBWASv20gToX86XpXRP7Q5NqsTGElu0dGZGj2NP7y E3herPx4dF2kaf4EPO83BUV25sd5LiUzgoXve8zx7cJAy/ydqv55oqkoyFi3Ob9JgWn0 oZ1rGmqYAC2lYXnw0t90eh3tNWqEaMk6MMH2/UtAcWsZwV9omBl7030ucRvRcHH3IZ5U 7NVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WqRcg4+V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r80-v6si2282053qka.279.2018.05.14.15.14.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:14:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WqRcg4+V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILjr-0001GF-54 for patch@linaro.org; Mon, 14 May 2018 18:14:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhn-0007pw-3l for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhm-0007T6-3g for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:31 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhl-0007S0-Un for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:30 -0400 Received: by mail-pl0-x243.google.com with SMTP id c19-v6so8153090pls.6 for ; Mon, 14 May 2018 15:12:29 -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; bh=VrjybWtyS9x1dk/X8ACHYXOClLJ40q5WBHgCIV0De2Q=; b=WqRcg4+Vqe4G0yuI0aKgKT2BmRX4A9RqASLhRtXu+IbKKTIKDTTfXh+DSG4cZI9cj+ iqxxspLnx9sqBRh5nUGffIQ1mhQRiBk6V5gZfyfiaaUw3Z8wrlA1uB8/2zsql+NyPhq1 jUe2PjaTiYRVOeWhsVUDHoiZgAPFbA1jhtKv0= 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; bh=VrjybWtyS9x1dk/X8ACHYXOClLJ40q5WBHgCIV0De2Q=; b=H7V7FAceuMvTJftyRO52qIDV0lgyx0gl3ECkJFCuPANMnAYc0Ai2wHpBJL4RXEPOMY meealf2P8u3xz1qeaEGGTXKube+rVXrDUHWrJwCihD8VTmYdb05fQOisQt4glyG8hH5B k+ZzWBS1o3x/MhZZdGOStqQhTYaXOQ3+MTbT8N+nng9AotpeoAzXQbF7EZruaBjSdD6i F3c4I59zpLcZnMt40KFaBQhrWd1kpVY8zCCVRRUuYakSuI/nQGoCTU+IzsCC5bx3esxZ x/igb3Ev2L2bUZeI6fR0DT+OvRnDUJ9H6HB3WYNB41mwTIVnaWuCYEQRWsJ1moGjhu/1 4oKg== X-Gm-Message-State: ALKqPwf1gxqbHoDk3EBwGFkNSyZl43DyVdBSDybr0/hCocsz/Vg88Ygr qYX7FSYxQYMfsEPf6VTBXwJ4aKrTF88= X-Received: by 2002:a17:902:b68f:: with SMTP id c15-v6mr11566196pls.201.1526335948782; Mon, 14 May 2018 15:12:28 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:56 -0700 Message-Id: <20180514221219.7091-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v5 05/28] fpu/softfloat: Canonicalize NaN fraction 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Shift the NaN fraction to a canonical position, much like we do for the fraction of normal numbers. This will facilitate manipulation of NaNs within the shared code paths. Signed-off-by: Richard Henderson --- fpu/softfloat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.17.0 Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 0d17027379..607c4a78d5 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -330,10 +330,11 @@ static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, if (part.frac == 0) { part.cls = float_class_inf; } else { + part.frac <<= parm->frac_shift; #ifdef NO_SIGNALING_NANS part.cls = float_class_qnan; #else - int64_t msb = part.frac << (parm->frac_shift + 2); + int64_t msb = part.frac << 2; if ((msb < 0) == status->snan_bit_is_one) { part.cls = float_class_snan; } else { @@ -480,6 +481,7 @@ static FloatParts round_canonical(FloatParts p, float_status *s, case float_class_qnan: case float_class_snan: exp = exp_max; + frac >>= parm->frac_shift; break; default: @@ -503,6 +505,7 @@ static float16 float16_round_pack_canonical(FloatParts p, float_status *s) case float_class_dnan: return float16_default_nan(s); case float_class_msnan: + p.frac >>= float16_params.frac_shift; return float16_maybe_silence_nan(float16_pack_raw(p), s); default: p = round_canonical(p, s, &float16_params); @@ -521,6 +524,7 @@ static float32 float32_round_pack_canonical(FloatParts p, float_status *s) case float_class_dnan: return float32_default_nan(s); case float_class_msnan: + p.frac >>= float32_params.frac_shift; return float32_maybe_silence_nan(float32_pack_raw(p), s); default: p = round_canonical(p, s, &float32_params); @@ -539,6 +543,7 @@ static float64 float64_round_pack_canonical(FloatParts p, float_status *s) case float_class_dnan: return float64_default_nan(s); case float_class_msnan: + p.frac >>= float64_params.frac_shift; return float64_maybe_silence_nan(float64_pack_raw(p), s); default: p = round_canonical(p, s, &float64_params); From patchwork Mon May 14 22:11:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135763 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp190134lji; Mon, 14 May 2018 15:17:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoK9JXkRIubu2AuagjUuwNHe4uWyy2vsex286LOkbyTLCJNnKVhWAGWbX6gPoM01qzIfSpB X-Received: by 2002:a37:4708:: with SMTP id u8-v6mr10140740qka.299.1526336265468; Mon, 14 May 2018 15:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336265; cv=none; d=google.com; s=arc-20160816; b=qIrjZLAOF6r4wKNyLGzvGeFkUl2Cao3LvfpvOPbMWfeTtjtbExhnjeM3NCGgHLOubP O6hbwaI3YWSz36QiL/X6frDZ3w1CruxB50LtkFxZSJbtT3B+YfIQpZrlvRDKw5pNNDxp ZL3x8myOadFCgZyARHtnkvxMKXiQFX9I6LAotItf+dKWSR9239PDTv16SEwz2SWp+MY3 MDYTu5vYT1KCSuoiYi7MRY8mVAD4mKaeYQDR3YWq20EW2cAJybmY7lOsGW1qoE6QjiIb UzpfSgKLBoCpyNzGn+e28WkPkFgI+xaTksQksKXSQ4zxib6lcMnvKNrpog9NEgbBrvQR jlTg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=sMFvxehNW2WjX/2qTbv+EhzKGZ6dKWsMD6UmFGMjN8k=; b=pn/gFj+jUlsV+XDC3/etMuvz9ebwOwshdHN4Dkf6V++xiaiFSjrOwXOfQSbziA8x3K MruvoXrJuZ/Mc0VVjssNmf6JCC4AOun8oS7JHUapuzgKI4JoAUTSLXju5p9bK/Ruzdgf mxc4cbBgUCA6kWw9z3DqidCZnZZ9qsIbusuJiS8Hfy07yyc9v6pHsNTZuUhmqYVyV8PX r8ERFZVN7kWsh9gSWNfriffFAToozV0ZEc+4NCSxfNXW4t6VI1sJ28qOdytDAP0J3C8T +lN+KEmgm/jwS+5NSQwipXoAB+vywRAbN8vgqejaUGW/gQJb7EQZxYKtxPkUqiLO7NOb wEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xw4oWvHS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 19-v6si6541288qts.53.2018.05.14.15.17.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Xw4oWvHS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILmq-0003sb-R6 for patch@linaro.org; Mon, 14 May 2018 18:17:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILho-0007rT-JT for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhn-0007Vn-Ja for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:32 -0400 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:42494) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhn-0007Ug-DX for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:31 -0400 Received: by mail-pl0-x244.google.com with SMTP id u6-v6so8148774pls.9 for ; Mon, 14 May 2018 15:12:31 -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; bh=sMFvxehNW2WjX/2qTbv+EhzKGZ6dKWsMD6UmFGMjN8k=; b=Xw4oWvHSUvr/S9d3lFMZDuiXtbPqogZB9Fn0mY4PYEoNT3ytPLUBUdA7GMw6MNwSne 1pZ68NXADgioiUqmScfeT5fzxiiBlCO4riEE6lJpUiVv2bwG3z3yWc/GytLdOYn1P774 +npjrGV3nbZJ7Q8AdUZF7nwjpoUAY0/QOD0BY= 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; bh=sMFvxehNW2WjX/2qTbv+EhzKGZ6dKWsMD6UmFGMjN8k=; b=RZEBFj80ur4yjCrg4TUAtEeE3UjuXjFKmGNFH4XTRm8ANxIVWSy4Ru6ezRVQ4UtoPt mhsqKIp9LVsxuD6ouVLd8ICwEbINmDnduQklifU/bamIyTnHMmahKPfOMO9y7NOw0THY 12oz2plDrNJscBjsNutxQplrBFduOX8Gk4jWzdYwa8oMMthSf1r5fOq6zXuIYYDfrxvt 82EywN3Ut2vLWM0X0cEpaSnYNosNQT5GxoSR+bUDWfSt3exr4Cl6nN/UIaAahmnPkVGl LLSK0VvZcknAyCARY+MuzThqXXUvqBgq5U8/fwyOcSu1UaqOTkbbEZdTzK24wzlq8M+6 waHw== X-Gm-Message-State: ALKqPwf/fAdVhcpwjNJVH2YMyZPQ+xVpLoAqDnk4SFP1aOaQvK+wDcP2 gWiIUHyqvMe9QEc9AyLmXn/HpN4ncqg= X-Received: by 2002:a17:902:10c:: with SMTP id 12-v6mr11712846plb.252.1526335950252; Mon, 14 May 2018 15:12:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:57 -0700 Message-Id: <20180514221219.7091-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v5 06/28] fpu/softfloat: Introduce parts_is_snan_frac 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 15 +++++++++++++++ fpu/softfloat.c | 12 ++---------- 2 files changed, 17 insertions(+), 10 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 4fc9ea4ac0..515cb12cfa 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -86,6 +86,21 @@ this code that are retained. #define NO_SIGNALING_NANS 1 #endif +/*---------------------------------------------------------------------------- +| For the deconstructed floating-point with fraction FRAC, return true +| if the fraction represents a signalling NaN; otherwise false. +*----------------------------------------------------------------------------*/ + +static bool parts_is_snan_frac(uint64_t frac, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + return false; +#else + flag msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1); + return msb == status->snan_bit_is_one; +#endif +} + /*---------------------------------------------------------------------------- | The pattern for a default generated half-precision NaN. *----------------------------------------------------------------------------*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 607c4a78d5..19f40d6932 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -331,16 +331,8 @@ static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, part.cls = float_class_inf; } else { part.frac <<= parm->frac_shift; -#ifdef NO_SIGNALING_NANS - part.cls = float_class_qnan; -#else - int64_t msb = part.frac << 2; - if ((msb < 0) == status->snan_bit_is_one) { - part.cls = float_class_snan; - } else { - part.cls = float_class_qnan; - } -#endif + part.cls = (parts_is_snan_frac(part.frac, status) + ? float_class_snan : float_class_qnan); } } else if (part.exp == 0) { if (likely(part.frac == 0)) { From patchwork Mon May 14 22:11:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135770 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp193600lji; Mon, 14 May 2018 15:22:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokwdfwkkM41wD2I2Pgern6Svegpwx0ohJ7csVzb806rbcNU75tligP1JElYD3y1m8+0viY X-Received: by 2002:a37:cf82:: with SMTP id v2-v6mr10215517qkl.67.1526336539049; Mon, 14 May 2018 15:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336539; cv=none; d=google.com; s=arc-20160816; b=KjugTNtGshWSmog1XMtivicL/l8xIuNPyL0ZE50ishWGt82+mGB7kloUmX1IR6CEL0 uCGDsErtMfa4qPlI+Zg9GARA2O5IdmDhLa6UIMVADlFk/0flKinnjdhFBhyQDx6noFkT yn+WQm3FEQPlIPK7AkqTieRJUtHniPisRhjuQKMzZKGg4nwjecicK7sqJCxN57NWM2ps NWNfXnXl9qU3Zgq8j6Pjst8fk/KKhiRc1OsAMEKw0eD/cJjhYDhowXGUFe8GCfZWO8uR 7h7zY9Pcjp/Z2WFWvzjypSphEokuhWumb0WHcFw0nDSWYEn+la9kagMapUyQvopSaGCW kbXA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+vvqSgQxe1wFpwzrd9m3dE4eIudcFO3NRIbmpaTbg/g=; b=BEid9fWnMrvoAYmUHgSIrOuqKZ+t6lotVLJeSG/+zmC+evhPZa58Krmgscwt5bgXmG kYa2+oFaIECinrkWFx4qF/gKwqikHr9kGMJldnRTPnir5lxqGCkonLBAxcA49rSm8jmp Se3lEb+b5Qv0dRmysnXrg5nrjXDE+dG04wxDI7lvAPfL2JDNynV4EZ6fOaahWDs/l2xC dBtGO2Z9MTODM3QK0RCc9OGCVeFbYYMoK2EuNNZH8ZsMXj8jcdppRJuv6r/ce4zNSHcW 7Ky5HQZUTeOfcTAyYZkVQjw8WJ/RQ75uGGcycmjzv19LCeEJujHNq09o7jtwYQWAbkOd NBdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LDiBklzp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e46-v6si1936375qte.273.2018.05.14.15.22.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LDiBklzp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILrG-0007XS-GR for patch@linaro.org; Mon, 14 May 2018 18:22:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52445) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhs-0007vk-Uf for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhp-0007Zo-Bt for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:36 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:37436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhp-0007X8-3R for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:33 -0400 Received: by mail-pf0-x244.google.com with SMTP id e9-v6so6669184pfi.4 for ; Mon, 14 May 2018 15:12:33 -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; bh=+vvqSgQxe1wFpwzrd9m3dE4eIudcFO3NRIbmpaTbg/g=; b=LDiBklzpaKFGMO4pALYqNQio8vgEi5Riy/nx2nCcwy0eqJflwETXjkzyGysjZVaql7 Qa7fGaulr6lIhYR9yF8jfHdRti2GitqtnVdt6fTVTDjoIbL6YisFzwsgQTPEppChI+LO RDhISdMaA/ZVXNcbijb9jheedoZPOikakf/I4= 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; bh=+vvqSgQxe1wFpwzrd9m3dE4eIudcFO3NRIbmpaTbg/g=; b=FMYe7oA0Isak+QvFxKG1IZZKYMXvcNz6pC5RvVD324PGZhYXjOOVPpIYs9DrWJ0mBJ tuWgk2RqsKUgnKJI++vlPr3Q4TQBR5wg44UYizQo0Jrfg9s5hde0FyXc7bhby3ZJ+++7 aQhhF5Ap1f5ngpS/Va9IdPaaGbEl806lh3LE6hxe2jP72aNproIH/3of82U2u70pvbvm l+JR9JsWwAcmpFnWRYLKYW0bwSQjW1ixzsWrHj6aSpSuH2T1iY8YeRo5EAcLSoZ/9O0O lrirzupvq4Q/ttsM9V0IdzUCRn1RWEmohNo0oOZTs/ggo4ap0Un04qm1qb1dbhBUEcO8 hLIQ== X-Gm-Message-State: ALKqPweOTodElbl1Ak46VjJtLbUM7X8fv8VIbNdotwQTylhT624FrSAp K3S8JvZG0kqDav91L+2xX6hfD7R7TFk= X-Received: by 2002:a65:62d0:: with SMTP id m16-v6mr9647295pgv.279.1526335951744; Mon, 14 May 2018 15:12:31 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:58 -0700 Message-Id: <20180514221219.7091-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v5 07/28] fpu/softfloat: Replace float_class_dnan with parts_default_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" With a canonical representation of NaNs, we can return the default nan directly rather than delay the expansion until the final format is known. Note one case where we uselessly assigned to a.sign, which was overwritten/ignored later when expanding float_class_dnan. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 37 +++++++++++++++++++++++++++++++++++++ fpu/softfloat.c | 38 +++++++++++--------------------------- 2 files changed, 48 insertions(+), 27 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 515cb12cfa..0d3d81a52b 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -101,6 +101,43 @@ static bool parts_is_snan_frac(uint64_t frac, float_status *status) #endif } +/*---------------------------------------------------------------------------- +| The pattern for a default generated deconstructed floating-point NaN. +*----------------------------------------------------------------------------*/ + +static FloatParts parts_default_nan(float_status *status) +{ + bool sign = 0; + uint64_t frac; + +#if defined(TARGET_SPARC) || defined(TARGET_M68K) + frac = (1ULL << DECOMPOSED_BINARY_POINT) - 1; +#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) || \ + defined(TARGET_S390X) || defined(TARGET_RISCV) + frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); +#elif defined(TARGET_HPPA) + frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#else + if (status->snan_bit_is_one) { + frac = (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; + } else { +#if defined(TARGET_MIPS) + frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); +#else + frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); + sign = 1; +#endif + } +#endif + + return (FloatParts) { + .cls = float_class_qnan, + .sign = sign, + .exp = INT_MAX, + .frac = frac + }; +} + /*---------------------------------------------------------------------------- | The pattern for a default generated half-precision NaN. *----------------------------------------------------------------------------*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 19f40d6932..51780b718f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -188,7 +188,6 @@ typedef enum __attribute__ ((__packed__)) { float_class_inf, float_class_qnan, /* all NaNs from here */ float_class_snan, - float_class_dnan, float_class_msnan, /* maybe silenced */ } FloatClass; @@ -494,8 +493,6 @@ static FloatParts float16_unpack_canonical(float16 f, float_status *s) static float16 float16_round_pack_canonical(FloatParts p, float_status *s) { switch (p.cls) { - case float_class_dnan: - return float16_default_nan(s); case float_class_msnan: p.frac >>= float16_params.frac_shift; return float16_maybe_silence_nan(float16_pack_raw(p), s); @@ -513,8 +510,6 @@ static FloatParts float32_unpack_canonical(float32 f, float_status *s) static float32 float32_round_pack_canonical(FloatParts p, float_status *s) { switch (p.cls) { - case float_class_dnan: - return float32_default_nan(s); case float_class_msnan: p.frac >>= float32_params.frac_shift; return float32_maybe_silence_nan(float32_pack_raw(p), s); @@ -532,8 +527,6 @@ static FloatParts float64_unpack_canonical(float64 f, float_status *s) static float64 float64_round_pack_canonical(FloatParts p, float_status *s) { switch (p.cls) { - case float_class_dnan: - return float64_default_nan(s); case float_class_msnan: p.frac >>= float64_params.frac_shift; return float64_maybe_silence_nan(float64_pack_raw(p), s); @@ -566,7 +559,7 @@ static FloatParts return_nan(FloatParts a, float_status *s) /* fall through */ case float_class_qnan: if (s->default_nan_mode) { - a.cls = float_class_dnan; + return parts_default_nan(s); } break; @@ -583,7 +576,7 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s) } if (s->default_nan_mode) { - a.cls = float_class_dnan; + return parts_default_nan(s); } else { if (pickNaN(is_qnan(a.cls), is_snan(a.cls), is_qnan(b.cls), is_snan(b.cls), @@ -614,8 +607,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, /* Note that this check is after pickNaNMulAdd so that function * has an opportunity to set the Invalid flag. */ - a.cls = float_class_dnan; - return a; + which = 3; } switch (which) { @@ -628,8 +620,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, a = c; break; case 3: - a.cls = float_class_dnan; - return a; + return parts_default_nan(s); default: g_assert_not_reached(); } @@ -682,7 +673,7 @@ static FloatParts addsub_floats(FloatParts a, FloatParts b, bool subtract, if (a.cls == float_class_inf) { if (b.cls == float_class_inf) { float_raise(float_flag_invalid, s); - a.cls = float_class_dnan; + return parts_default_nan(s); } return a; } @@ -828,9 +819,7 @@ static FloatParts mul_floats(FloatParts a, FloatParts b, float_status *s) if ((a.cls == float_class_inf && b.cls == float_class_zero) || (a.cls == float_class_zero && b.cls == float_class_inf)) { s->float_exception_flags |= float_flag_invalid; - a.cls = float_class_dnan; - a.sign = sign; - return a; + return parts_default_nan(s); } /* Multiply by 0 or Inf */ if (a.cls == float_class_inf || a.cls == float_class_zero) { @@ -908,8 +897,7 @@ static FloatParts muladd_floats(FloatParts a, FloatParts b, FloatParts c, if (inf_zero) { s->float_exception_flags |= float_flag_invalid; - a.cls = float_class_dnan; - return a; + return parts_default_nan(s); } if (flags & float_muladd_negate_c) { @@ -933,12 +921,12 @@ static FloatParts muladd_floats(FloatParts a, FloatParts b, FloatParts c, if (c.cls == float_class_inf) { if (p_class == float_class_inf && p_sign != c.sign) { s->float_exception_flags |= float_flag_invalid; - a.cls = float_class_dnan; + return parts_default_nan(s); } else { a.cls = float_class_inf; a.sign = c.sign ^ sign_flip; + return a; } - return a; } if (p_class == float_class_inf) { @@ -1148,8 +1136,7 @@ static FloatParts div_floats(FloatParts a, FloatParts b, float_status *s) && (a.cls == float_class_inf || a.cls == float_class_zero)) { s->float_exception_flags |= float_flag_invalid; - a.cls = float_class_dnan; - return a; + return parts_default_nan(s); } /* Inf / x or 0 / x */ if (a.cls == float_class_inf || a.cls == float_class_zero) { @@ -1347,7 +1334,6 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_dnan: case float_class_msnan: s->float_exception_flags = orig_flags | float_flag_invalid; return max; @@ -1439,7 +1425,6 @@ static uint64_t round_to_uint_and_pack(FloatParts in, int rmode, uint64_t max, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_dnan: case float_class_msnan: s->float_exception_flags = orig_flags | float_flag_invalid; return max; @@ -1940,8 +1925,7 @@ static FloatParts sqrt_float(FloatParts a, float_status *s, const FloatFmt *p) } if (a.sign) { s->float_exception_flags |= float_flag_invalid; - a.cls = float_class_dnan; - return a; + return parts_default_nan(s); } if (a.cls == float_class_inf) { return a; /* sqrt(+inf) = +inf */ From patchwork Mon May 14 22:11:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135764 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp191124lji; Mon, 14 May 2018 15:19:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKrque+TiW0glXMICEcv8mbMoN7wwLDxkEkHgm0s8VbAzepKZeLpVSQ4p0ifuIqy4KOgw9 X-Received: by 2002:ac8:482:: with SMTP id s2-v6mr10871180qtg.144.1526336343310; Mon, 14 May 2018 15:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336343; cv=none; d=google.com; s=arc-20160816; b=fJ48+YWDW4gBEs5Le+8BnfyFUpU3u6My0+OyhZJsUYX9tJFBil/BA/WQhalLVGC0+M /o56X0pDrsB29V1WhlRLyOmg+QP8lnLlYLMSZIVFWGchNgsmLHx4Jo12mvMc5GELhZ2H PjA8BU+tgU6Kxt74pOCW16Ye/bjn8Bu/BQW0Bus9OxltSCRRLYcsIaKxgEJtgEtGhEZR w4qeUvs9AhTALdR9sF/IU2cHa3rDKI3Sn/1EFx2tbwAVtBAtMestpGBgPc5gYj6Mus6I jHYC2npfCWeD685cPQxqHaE0JMe2qwwkezPTab3OSRypQFBuXgNYfE+v5gBXNlWQtC9k lU9Q== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=8MMEeLkuowEda0GJxT77HlfYSnWSRj+TbO/ixCfRrxo=; b=FTDRfVzxol2ibXRI623Eu4w9x6fvob0U8zDxejxaOneRLs1qd1AxKBGTAfNgko8TxH Hy8Lwi6MvvVDqSVrhQ2oBSmStNts2iv+8filnOocHR086ZYN0ae37yvB8K1IdzPoXub3 C5NNkJMbufHWtuAnhM/ch42Bu/06AB80nXOXJ5jRV7AIjckdoghPFJK0k162AW1/riBl 1ICR9Jy2yqbWhaXbk25ncO/9pS/ETP4PiS1Bo7TOKzhhRFkILjSf8Dma27fvB5Js+/ds ozpBYOa+LQb98xzAWyjRxYQWFbdKBOZGprDdO75T9J0TaCnLl+ctgtXESzRoeQKI1dIJ XSGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f/BxW1sI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k5-v6si512635qvg.7.2018.05.14.15.19.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:19:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f/BxW1sI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILo6-000407-Lh for patch@linaro.org; Mon, 14 May 2018 18:19:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhs-0007vi-UO for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhq-0007e9-HC for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:36 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:42493) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhq-0007bY-8y for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:34 -0400 Received: by mail-pl0-x242.google.com with SMTP id u6-v6so8148826pls.9 for ; Mon, 14 May 2018 15:12:34 -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; bh=8MMEeLkuowEda0GJxT77HlfYSnWSRj+TbO/ixCfRrxo=; b=f/BxW1sI2h8tZovSH6t6/MdQx41zMtZEhl38usijRWX+a/T1t3tYghVn87cP34LRnS 9S412Lk0squzBLDhH3bKr82sioUgdqHXCDd9DV7VQEr5pIIpMjBTaRHX+KwaxlZHZavl 1KJRvqECaHQGRtlBh5AB3ysRC2UWO4Tl/WTg4= 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; bh=8MMEeLkuowEda0GJxT77HlfYSnWSRj+TbO/ixCfRrxo=; b=CE0n3qxewflLTQlxBr++OXqnTNBnyMK8zHrauaMvF9squmbU2HhJ2/4xbxPn72fjmh 3lWTuowuS0MsM75kfmLFBvE5zq9mFx72KI8g8I50Ijqn14fzScUAI6Kvu/GdSNBVmIwD w0Q4lXlXzkfmr0sZ7uWkWH7MeEaNqRaiLqhTV0YDF5EBCSuV2tPSlF1/4hQxctgXVYUS dk0UHq8d4yRwUvjHvsnyYelWTLkQ5DTLbaxIPaFRfQV9wkVQ2//mgertx+l4dGlMUwP7 a+XYgQMlw4NYPRDhXmfkIFC1NRSMpjOfpYvSL1xuh1hBhMl8EBGGTUF/qCBF/hn2LVkH FkLA== X-Gm-Message-State: ALKqPwclwHctN4C3OE/N2JCCmRX0oldZXzAAUAgDXzvKFJzVky8ntmMQ i5hI7bBrquYkxWUTDUlW34lh7xh5ObI= X-Received: by 2002:a17:902:8c81:: with SMTP id t1-v6mr11370851plo.310.1526335953029; Mon, 14 May 2018 15:12:33 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:11:59 -0700 Message-Id: <20180514221219.7091-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v5 08/28] fpu/softfloat: Replace float_class_msnan with parts_silence_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" With a canonical representation of NaNs, we can silence an SNaN immediately rather than delay until the final format is known. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 23 ++++++++++++++++++++++ fpu/softfloat.c | 40 ++++++++++---------------------------- 2 files changed, 33 insertions(+), 30 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 0d3d81a52b..571d1df378 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -138,6 +138,29 @@ static FloatParts parts_default_nan(float_status *status) }; } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the deconstructed +| floating-point parts. +*----------------------------------------------------------------------------*/ + +static FloatParts parts_silence_nan(FloatParts a, float_status *status) +{ +#ifdef NO_SIGNALING_NANS + g_assert_not_reached(); +#elif defined(TARGET_HPPA) + a.frac &= ~(1ULL << (DECOMPOSED_BINARY_POINT - 1)); + a.frac |= 1ULL << (DECOMPOSED_BINARY_POINT - 2); +#else + if (status->snan_bit_is_one) { + return parts_default_nan(status); + } else { + a.frac |= 1ULL << (DECOMPOSED_BINARY_POINT - 1); + } +#endif + a.cls = float_class_qnan; + return a; +} + /*---------------------------------------------------------------------------- | The pattern for a default generated half-precision NaN. *----------------------------------------------------------------------------*/ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 51780b718f..41253c6749 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -188,7 +188,6 @@ typedef enum __attribute__ ((__packed__)) { float_class_inf, float_class_qnan, /* all NaNs from here */ float_class_snan, - float_class_msnan, /* maybe silenced */ } FloatClass; /* @@ -492,14 +491,7 @@ static FloatParts float16_unpack_canonical(float16 f, float_status *s) static float16 float16_round_pack_canonical(FloatParts p, float_status *s) { - switch (p.cls) { - case float_class_msnan: - p.frac >>= float16_params.frac_shift; - return float16_maybe_silence_nan(float16_pack_raw(p), s); - default: - p = round_canonical(p, s, &float16_params); - return float16_pack_raw(p); - } + return float16_pack_raw(round_canonical(p, s, &float16_params)); } static FloatParts float32_unpack_canonical(float32 f, float_status *s) @@ -509,14 +501,7 @@ static FloatParts float32_unpack_canonical(float32 f, float_status *s) static float32 float32_round_pack_canonical(FloatParts p, float_status *s) { - switch (p.cls) { - case float_class_msnan: - p.frac >>= float32_params.frac_shift; - return float32_maybe_silence_nan(float32_pack_raw(p), s); - default: - p = round_canonical(p, s, &float32_params); - return float32_pack_raw(p); - } + return float32_pack_raw(round_canonical(p, s, &float32_params)); } static FloatParts float64_unpack_canonical(float64 f, float_status *s) @@ -526,14 +511,7 @@ static FloatParts float64_unpack_canonical(float64 f, float_status *s) static float64 float64_round_pack_canonical(FloatParts p, float_status *s) { - switch (p.cls) { - case float_class_msnan: - p.frac >>= float64_params.frac_shift; - return float64_maybe_silence_nan(float64_pack_raw(p), s); - default: - p = round_canonical(p, s, &float64_params); - return float64_pack_raw(p); - } + return float64_pack_raw(round_canonical(p, s, &float64_params)); } /* Simple helpers for checking if what NaN we have */ @@ -555,7 +533,7 @@ static FloatParts return_nan(FloatParts a, float_status *s) switch (a.cls) { case float_class_snan: s->float_exception_flags |= float_flag_invalid; - a.cls = float_class_msnan; + a = parts_silence_nan(a, s); /* fall through */ case float_class_qnan: if (s->default_nan_mode) { @@ -584,7 +562,9 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s) (a.frac == b.frac && a.sign < b.sign))) { a = b; } - a.cls = float_class_msnan; + if (is_snan(a.cls)) { + return parts_silence_nan(a, s); + } } return a; } @@ -624,8 +604,10 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, default: g_assert_not_reached(); } - a.cls = float_class_msnan; + if (is_snan(a.cls)) { + return parts_silence_nan(a, s); + } return a; } @@ -1334,7 +1316,6 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_msnan: s->float_exception_flags = orig_flags | float_flag_invalid; return max; case float_class_inf: @@ -1425,7 +1406,6 @@ static uint64_t round_to_uint_and_pack(FloatParts in, int rmode, uint64_t max, switch (p.cls) { case float_class_snan: case float_class_qnan: - case float_class_msnan: s->float_exception_flags = orig_flags | float_flag_invalid; return max; case float_class_inf: From patchwork Mon May 14 22:12:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135765 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp191239lji; Mon, 14 May 2018 15:19:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZozEkdRs1J7ocNA95a2K0KXTf4FNSC6Vl4v3/rLbdGA4r8/cpjLpNIicMFUTTTbV7+cxFqM X-Received: by 2002:a37:f4f:: with SMTP id z76-v6mr9668153qkg.373.1526336352814; Mon, 14 May 2018 15:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336352; cv=none; d=google.com; s=arc-20160816; b=dEwxfZLEG0xDoMSzQyj1yJAhUEmvCvF6MUcAzUdQ/WjY4mfziE6965dE1ZSk9InomI skZgRUop/xGejU59FwqcGw56cJHe5qcFvq4VfZYavaIaW6i8tixj199jMYL0IOjLI9hh 40tUZzhmNrojvxhfDnnZjp2pAHuc75d2hGlYNJkJQeStjXAVCHvn033T12ex9sHREjfq RJi4xYv2A02lby+8MPkJE3Vypc4unTH7YKuJwkvwX5leNmYRH3DYJNWhT4sF2NXGuvDt yqQLVI6YmerqU13kEv2+wuac9W3cJqayZMZh6su+AllYM/STzoJN8tADpu8WaFfnWR3V opVA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Bl+bwYZCboI6Mmo4YIXtqqIxAxnsh+z/MxA7ULhGDVk=; b=eAAc2ozbCfL4uQKxUV9mXN3dVyHW0rTO0rjzsvzpn4qP1Ep3Kbo/o8SSXY006wXGwM 4zbNkAkrDETa7SkCwd3j6T7eAyKSlt9AnTVPaSpoVZUo49mfl9zOBEpv9Gwx6TCmtdST lwKA4co1yTYy34BzeIPT40frAqOFduCDNc964n56LYurdxniP3XhxAtuiPrtZtPXxaCQ PDjSgpaFaobf5H9JAozA243D0OrgzDvGAhe+RpW0TshjW1z/eQ68tAU7v1/lzL3X7Vr5 QQ0+E06nTQNxSdGXFRQ5QrbzMG7IscSYNIqBg+sqbQy2PiBrBdh45Cuaa3FwVBKjMcGj 5lGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ffz+sry5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 2-v6si3650478qku.200.2018.05.14.15.19.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:19:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ffz+sry5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILoG-0004vd-6P for patch@linaro.org; Mon, 14 May 2018 18:19:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhs-0007vm-V2 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhr-0007gE-Kx for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:36 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:40994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhr-0007eu-FN for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:35 -0400 Received: by mail-pf0-x241.google.com with SMTP id v63-v6so6663071pfk.8 for ; Mon, 14 May 2018 15:12:35 -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; bh=Bl+bwYZCboI6Mmo4YIXtqqIxAxnsh+z/MxA7ULhGDVk=; b=ffz+sry546DryKyts4jk6x90tJh4u/k6fKql2TTEiUFMK1ToyjhBQD0isvKdFKVoaH eSxRM3jX6tVCl09VzjdNRm+AjkpHwKQ6EyKGC16PnUedBAX+UFCGhofmAEfh5TG6ORd8 wbhV02Qkq9fy++GG/CCDqsbOLKwK0YEJ7ZUn8= 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; bh=Bl+bwYZCboI6Mmo4YIXtqqIxAxnsh+z/MxA7ULhGDVk=; b=lwcOugOi2Y3MZO+sZYvLVR0AiwXogby9nBdvOsv0NMK+2uKS8IN4bKZBNV4NMgMFoh 7C1Sa7hvyhTzz50SWloZBfagf+bANHH+NlN1xFps5mCeg4nuMoyPriJRN0+TIC7tLpHn 0lBeuisKrN+g9A4k0woZYlFNxwDCiIN3iZ+qaExCGZpdiYVLvSiAghPVcc2UwQegJ6jy KtMpdTV7q6V3unJWMujZzIBJfwzyfa6HWzu9jyZgNpXaXMLPw4l+xV8m1qPVYN4/c41B uLv+wIQvSTHU0WGdJFH677N4/7V7yMlpogwPbGkYD+IHFDPovM6M/2eKFEyP6jOlQpaV I1cQ== X-Gm-Message-State: ALKqPwflahAlquAb/j+U3kYp9s0GHgytgRloMeV19fPcX+BNDJ6G+IOV SM3nTejhTbHRcPf9xsQ0byxN0nzc/Q8= X-Received: by 2002:a63:ae42:: with SMTP id e2-v6mr5734302pgp.424.1526335954211; Mon, 14 May 2018 15:12:34 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:00 -0700 Message-Id: <20180514221219.7091-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v5 09/28] target/arm: Use floatX_silence_nan when we have already checked for SNaN 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 6 +++--- target/arm/helper.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 4f8034c513..6f0eb83661 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -376,7 +376,7 @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp) float16 nan = a; if (float16_is_signaling_nan(a, fpst)) { float_raise(float_flag_invalid, fpst); - nan = float16_maybe_silence_nan(a, fpst); + nan = float16_silence_nan(a, fpst); } if (fpst->default_nan_mode) { nan = float16_default_nan(fpst); @@ -405,7 +405,7 @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) float32 nan = a; if (float32_is_signaling_nan(a, fpst)) { float_raise(float_flag_invalid, fpst); - nan = float32_maybe_silence_nan(a, fpst); + nan = float32_silence_nan(a, fpst); } if (fpst->default_nan_mode) { nan = float32_default_nan(fpst); @@ -434,7 +434,7 @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) float64 nan = a; if (float64_is_signaling_nan(a, fpst)) { float_raise(float_flag_invalid, fpst); - nan = float64_maybe_silence_nan(a, fpst); + nan = float64_silence_nan(a, fpst); } if (fpst->default_nan_mode) { nan = float64_default_nan(fpst); diff --git a/target/arm/helper.c b/target/arm/helper.c index c6fd7f9479..3df5cf30e4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11739,7 +11739,7 @@ float16 HELPER(recpe_f16)(float16 input, void *fpstp) float16 nan = f16; if (float16_is_signaling_nan(f16, fpst)) { float_raise(float_flag_invalid, fpst); - nan = float16_maybe_silence_nan(f16, fpst); + nan = float16_silence_nan(f16, fpst); } if (fpst->default_nan_mode) { nan = float16_default_nan(fpst); @@ -11787,7 +11787,7 @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) float32 nan = f32; if (float32_is_signaling_nan(f32, fpst)) { float_raise(float_flag_invalid, fpst); - nan = float32_maybe_silence_nan(f32, fpst); + nan = float32_silence_nan(f32, fpst); } if (fpst->default_nan_mode) { nan = float32_default_nan(fpst); @@ -11835,7 +11835,7 @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) float64 nan = f64; if (float64_is_signaling_nan(f64, fpst)) { float_raise(float_flag_invalid, fpst); - nan = float64_maybe_silence_nan(f64, fpst); + nan = float64_silence_nan(f64, fpst); } if (fpst->default_nan_mode) { nan = float64_default_nan(fpst); @@ -11934,7 +11934,7 @@ float16 HELPER(rsqrte_f16)(float16 input, void *fpstp) float16 nan = f16; if (float16_is_signaling_nan(f16, s)) { float_raise(float_flag_invalid, s); - nan = float16_maybe_silence_nan(f16, s); + nan = float16_silence_nan(f16, s); } if (s->default_nan_mode) { nan = float16_default_nan(s); @@ -11978,7 +11978,7 @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) float32 nan = f32; if (float32_is_signaling_nan(f32, s)) { float_raise(float_flag_invalid, s); - nan = float32_maybe_silence_nan(f32, s); + nan = float32_silence_nan(f32, s); } if (s->default_nan_mode) { nan = float32_default_nan(s); @@ -12021,7 +12021,7 @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) float64 nan = f64; if (float64_is_signaling_nan(f64, s)) { float_raise(float_flag_invalid, s); - nan = float64_maybe_silence_nan(f64, s); + nan = float64_silence_nan(f64, s); } if (s->default_nan_mode) { nan = float64_default_nan(s); From patchwork Mon May 14 22:12:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135771 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp193913lji; Mon, 14 May 2018 15:22:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnfJn0jeqOYmnRyJt4NGYrRu+0/nvxZFJCoya2HqVhayg2yZPNPJpP0crk06xK1/XSvKNE X-Received: by 2002:a37:be86:: with SMTP id o128-v6mr9814120qkf.141.1526336566477; Mon, 14 May 2018 15:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336566; cv=none; d=google.com; s=arc-20160816; b=X2wdOLChRx2COZ4ZCac4Aby5E5ci3/iq5NaHHklHeTDz6BaZ7JeptINJXA17McDcP5 KaFMPwXFyYt5VYwh0Tzb6tzGoU/E+d11r6oqZKXzP7RXZdMV/SIn2YV46E4XH4d+z+Ru WBAJi9y5pge6wWv5yA9U7xIyMZ1+W/w3Uw5BBulroY7il1lgUcQUfbalOqbUijeA3Ilw JksKDaGAi/wNqNk4lB8fguJL7nY6eKwTgIGJYx3fnLm8let2NZhnTXgnXrBJVLwSxIpm K+lHpBt59nTJnmordJPl+dEqleY4S/3+SLIKsZ+HI0b/n6jURe4IBcN4QD4YK/6LFYO9 GAPg== 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:arc-authentication-results; bh=kgFsjCcIc/1z2LVhH2EQj9VB0xsd4Fb5MP2a+hsVHBk=; b=iYOlmUk0oSV1iqeu7nMWJRIJ57ukR4f5cqc+k+1nYCXWbd7UH/sdAkv49WDvqiEAKe Xz8n8Td1C3NnhPeMF4IotCQ/alYH4TQK6S/040xlhuLuzR50wsbpSRBW3mUl8ul1e70P a+opu4JjTbVZA9k9FgwaVoeyAvpw/1V3S2CpxuFPAPK6qyWKfOv938RHPWomAsATjFT2 TGPkFOOAsSFO1ijOBs3zTbZQfWSehTA57qfDvIAQEC7+6I/Y0rthcAETmT0Te09i6Xij Wq5v1OJe2xMFRr+gZPFsGnWOdNnLLLzTJ8RS6hzR28BGqpz1HokX1d2AW6if+OCwh1Bh QSPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XyULRLhX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k2-v6si2522491qkf.87.2018.05.14.15.22.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:22:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XyULRLhX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILrh-0007uo-Pn for patch@linaro.org; Mon, 14 May 2018 18:22:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhv-0007y7-AF for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILht-0007jt-58 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:39 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39429) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhs-0007hw-RO for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:37 -0400 Received: by mail-pg0-x244.google.com with SMTP id e1-v6so6066412pga.6 for ; Mon, 14 May 2018 15:12:36 -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=kgFsjCcIc/1z2LVhH2EQj9VB0xsd4Fb5MP2a+hsVHBk=; b=XyULRLhX/CrL0OnMsZI9FmenjNZs6XzAGCkDXnoOecZPWKkehhZNBqe/3y6zk09nLu 1lIxSLLmqn5Nl4GfjUAwDZ4HfNhFFzLoqrvGHhyjFQP/9z2EBmuRCgf0cftiznRJmHo3 10nEe+xrBLnNTNR0NMeEQDEVRlcl9FnKzZU48= 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=kgFsjCcIc/1z2LVhH2EQj9VB0xsd4Fb5MP2a+hsVHBk=; b=PyO7Os7qGcQxT2o/uVpAqq3Zty0kBXIRi4LIiq39Tof7Mp8Nu3H5ws+uMq8KaUIHYc Jzsc02eWDZoKKuzvlVyQNOk4SCnAqhg6Y5qYfK+sewgDDx9DeZDUcRo665N/1c/rtC0K 3W9QgCeIOeeGYE3K5oEYVNIFj6Z5y/GsJ+pWm9e/NUFwWjBo0FPyD6kKpV/ah/cunKQb uAElE6oh0nyzvQdZRFN7JZYCx8T8YClarGx4KraO9rHBKWZGUEdeMXHtr9UkZbHgRali ZC71NE6e43KbeRFzt3W9ykxcfzmHU/ZesJcN2sJAFD9/pSrtkyPDFwjJkldOJY1R5NOU 2iyw== X-Gm-Message-State: ALKqPwc2AbA1sbsNA1Y3+ndtQe5+v26Y+xcNycFEKVXCjdwhsapthvHc 15TojAKcnt8M9zCxXIjsmNtRBx3Ifag= X-Received: by 2002:a63:6f4c:: with SMTP id k73-v6mr2312903pgc.303.1526335955493; Mon, 14 May 2018 15:12:35 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:01 -0700 Message-Id: <20180514221219.7091-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v5 10/28] target/arm: convert conversion helpers to fpst/ahp_flag 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée Instead of passing env and leaving it up to the helper to get the right fpstatus we pass it explicitly. There was already a get_fpstatus helper for neon for the 32 bit code. We also add an get_ahp_flag() for passing the state of the alternative FP16 format flag. This leaves scope for later tracking the AHP state in translation flags. Signed-off-by: Alex Bennée Signed-off-by: Richard Henderson --- v4 - remove neon_fcvt_*; they are now identical to vfp_fcvt_*. - add flags to vfp_fcvt_* helper decls. - add some missing tcg_temp_free_*. v5 - always use get_fpstatus_ptr(false) for FZ, since FZ16 is supposed to be supressed. --- target/arm/helper.h | 10 +++--- target/arm/translate.h | 12 +++++++ target/arm/helper.c | 56 +++++------------------------ target/arm/translate-a64.c | 38 ++++++++++++++++---- target/arm/translate.c | 74 +++++++++++++++++++++++++++++--------- 5 files changed, 113 insertions(+), 77 deletions(-) -- 2.17.0 diff --git a/target/arm/helper.h b/target/arm/helper.h index ce89968b2d..047f3bc1ca 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -187,12 +187,10 @@ DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) -DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env) -DEF_HELPER_2(vfp_fcvt_f32_to_f16, i32, f32, env) -DEF_HELPER_2(neon_fcvt_f16_to_f32, f32, i32, env) -DEF_HELPER_2(neon_fcvt_f32_to_f16, i32, f32, env) -DEF_HELPER_FLAGS_2(vfp_fcvt_f16_to_f64, TCG_CALL_NO_RWG, f64, i32, env) -DEF_HELPER_FLAGS_2(vfp_fcvt_f64_to_f16, TCG_CALL_NO_RWG, i32, f64, env) +DEF_HELPER_FLAGS_3(vfp_fcvt_f16_to_f32, TCG_CALL_NO_RWG, f32, f16, ptr, i32) +DEF_HELPER_FLAGS_3(vfp_fcvt_f32_to_f16, TCG_CALL_NO_RWG, f16, f32, ptr, i32) +DEF_HELPER_FLAGS_3(vfp_fcvt_f16_to_f64, TCG_CALL_NO_RWG, f64, f16, ptr, i32) +DEF_HELPER_FLAGS_3(vfp_fcvt_f64_to_f16, TCG_CALL_NO_RWG, f16, f64, ptr, i32) DEF_HELPER_4(vfp_muladdd, f64, f64, f64, f64, ptr) DEF_HELPER_4(vfp_muladds, f32, f32, f32, f32, ptr) diff --git a/target/arm/translate.h b/target/arm/translate.h index 37a1bba056..45f04244be 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -177,4 +177,16 @@ void arm_free_cc(DisasCompare *cmp); void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); void arm_gen_test_cc(int cc, TCGLabel *label); +/* Return state of Alternate Half-precision flag, caller frees result */ +static inline TCGv_i32 get_ahp_flag(void) +{ + TCGv_i32 ret = tcg_temp_new_i32(); + + tcg_gen_ld_i32(ret, cpu_env, + offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPSCR])); + tcg_gen_extract_i32(ret, ret, 26, 1); + + return ret; +} + #endif /* TARGET_ARM_TRANSLATE_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 3df5cf30e4..a1c1dc5bbe 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11540,64 +11540,24 @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) } /* Half precision conversions. */ -static float32 do_fcvt_f16_to_f32(uint32_t a, CPUARMState *env, float_status *s) +float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) { - int ieee = (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) == 0; - float32 r = float16_to_float32(make_float16(a), ieee, s); - if (ieee) { - return float32_maybe_silence_nan(r, s); - } - return r; + return float16_to_float32(a, !ahp_mode, fpstp); } -static uint32_t do_fcvt_f32_to_f16(float32 a, CPUARMState *env, float_status *s) +float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) { - int ieee = (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) == 0; - float16 r = float32_to_float16(a, ieee, s); - if (ieee) { - r = float16_maybe_silence_nan(r, s); - } - return float16_val(r); + return float32_to_float16(a, !ahp_mode, fpstp); } -float32 HELPER(neon_fcvt_f16_to_f32)(uint32_t a, CPUARMState *env) +float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) { - return do_fcvt_f16_to_f32(a, env, &env->vfp.standard_fp_status); + return float16_to_float64(a, !ahp_mode, fpstp); } -uint32_t HELPER(neon_fcvt_f32_to_f16)(float32 a, CPUARMState *env) +float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) { - return do_fcvt_f32_to_f16(a, env, &env->vfp.standard_fp_status); -} - -float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, CPUARMState *env) -{ - return do_fcvt_f16_to_f32(a, env, &env->vfp.fp_status); -} - -uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, CPUARMState *env) -{ - return do_fcvt_f32_to_f16(a, env, &env->vfp.fp_status); -} - -float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, CPUARMState *env) -{ - int ieee = (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) == 0; - float64 r = float16_to_float64(make_float16(a), ieee, &env->vfp.fp_status); - if (ieee) { - return float64_maybe_silence_nan(r, &env->vfp.fp_status); - } - return r; -} - -uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, CPUARMState *env) -{ - int ieee = (env->vfp.xregs[ARM_VFP_FPSCR] & (1 << 26)) == 0; - float16 r = float64_to_float16(a, ieee, &env->vfp.fp_status); - if (ieee) { - r = float16_maybe_silence_nan(r, &env->vfp.fp_status); - } - return float16_val(r); + return float64_to_float16(a, !ahp_mode, fpstp); } #define float32_two make_float32(0x40000000) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a0b0c43d12..4db18031bb 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5147,10 +5147,15 @@ static void handle_fp_fcvt(DisasContext *s, int opcode, } else { /* Single to half */ TCGv_i32 tcg_rd = tcg_temp_new_i32(); - gen_helper_vfp_fcvt_f32_to_f16(tcg_rd, tcg_rn, cpu_env); + TCGv_i32 ahp = get_ahp_flag(); + TCGv_ptr fpst = get_fpstatus_ptr(false); + + gen_helper_vfp_fcvt_f32_to_f16(tcg_rd, tcg_rn, fpst, ahp); /* write_fp_sreg is OK here because top half of tcg_rd is zero */ write_fp_sreg(s, rd, tcg_rd); tcg_temp_free_i32(tcg_rd); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); } tcg_temp_free_i32(tcg_rn); break; @@ -5163,9 +5168,13 @@ static void handle_fp_fcvt(DisasContext *s, int opcode, /* Double to single */ gen_helper_vfp_fcvtsd(tcg_rd, tcg_rn, cpu_env); } else { + TCGv_ptr fpst = get_fpstatus_ptr(false); + TCGv_i32 ahp = get_ahp_flag(); /* Double to half */ - gen_helper_vfp_fcvt_f64_to_f16(tcg_rd, tcg_rn, cpu_env); + gen_helper_vfp_fcvt_f64_to_f16(tcg_rd, tcg_rn, fpst, ahp); /* write_fp_sreg is OK here because top half of tcg_rd is zero */ + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(ahp); } write_fp_sreg(s, rd, tcg_rd); tcg_temp_free_i32(tcg_rd); @@ -5175,17 +5184,21 @@ static void handle_fp_fcvt(DisasContext *s, int opcode, case 0x3: { TCGv_i32 tcg_rn = read_fp_sreg(s, rn); + TCGv_ptr tcg_fpst = get_fpstatus_ptr(false); + TCGv_i32 tcg_ahp = get_ahp_flag(); tcg_gen_ext16u_i32(tcg_rn, tcg_rn); if (dtype == 0) { /* Half to single */ TCGv_i32 tcg_rd = tcg_temp_new_i32(); - gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, cpu_env); + gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp); write_fp_sreg(s, rd, tcg_rd); + tcg_temp_free_ptr(tcg_fpst); + tcg_temp_free_i32(tcg_ahp); tcg_temp_free_i32(tcg_rd); } else { /* Half to double */ TCGv_i64 tcg_rd = tcg_temp_new_i64(); - gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, cpu_env); + gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp); write_fp_dreg(s, rd, tcg_rd); tcg_temp_free_i64(tcg_rd); } @@ -9053,12 +9066,17 @@ static void handle_2misc_narrow(DisasContext *s, bool scalar, } else { TCGv_i32 tcg_lo = tcg_temp_new_i32(); TCGv_i32 tcg_hi = tcg_temp_new_i32(); + TCGv_ptr fpst = get_fpstatus_ptr(true); + TCGv_i32 ahp = get_ahp_flag(); + tcg_gen_extr_i64_i32(tcg_lo, tcg_hi, tcg_op); - gen_helper_vfp_fcvt_f32_to_f16(tcg_lo, tcg_lo, cpu_env); - gen_helper_vfp_fcvt_f32_to_f16(tcg_hi, tcg_hi, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tcg_lo, tcg_lo, fpst, ahp); + gen_helper_vfp_fcvt_f32_to_f16(tcg_hi, tcg_hi, fpst, ahp); tcg_gen_deposit_i32(tcg_res[pass], tcg_lo, tcg_hi, 16, 16); tcg_temp_free_i32(tcg_lo); tcg_temp_free_i32(tcg_hi); + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(ahp); } break; case 0x56: /* FCVTXN, FCVTXN2 */ @@ -11532,18 +11550,24 @@ static void handle_2misc_widening(DisasContext *s, int opcode, bool is_q, /* 16 -> 32 bit fp conversion */ int srcelt = is_q ? 4 : 0; TCGv_i32 tcg_res[4]; + TCGv_ptr fpst = get_fpstatus_ptr(true); + TCGv_i32 ahp = get_ahp_flag(); + for (pass = 0; pass < 4; pass++) { tcg_res[pass] = tcg_temp_new_i32(); read_vec_element_i32(s, tcg_res[pass], rn, srcelt + pass, MO_16); gen_helper_vfp_fcvt_f16_to_f32(tcg_res[pass], tcg_res[pass], - cpu_env); + fpst, ahp); } for (pass = 0; pass < 4; pass++) { write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_32); tcg_temp_free_i32(tcg_res[pass]); } + + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(ahp); } } diff --git a/target/arm/translate.c b/target/arm/translate.c index 731cf327a1..5ba59e0188 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3824,38 +3824,56 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) gen_vfp_sqrt(dp); break; case 4: /* vcvtb.f32.f16, vcvtb.f64.f16 */ + { + TCGv_ptr fpst = get_fpstatus_ptr(false); + TCGv_i32 ahp_mode = get_ahp_flag(); tmp = gen_vfp_mrs(); tcg_gen_ext16u_i32(tmp, tmp); if (dp) { gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - cpu_env); + fpst, ahp_mode); } else { gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - cpu_env); + fpst, ahp_mode); } + tcg_temp_free_i32(ahp_mode); + tcg_temp_free_ptr(fpst); tcg_temp_free_i32(tmp); break; + } case 5: /* vcvtt.f32.f16, vcvtt.f64.f16 */ + { + TCGv_ptr fpst = get_fpstatus_ptr(false); + TCGv_i32 ahp = get_ahp_flag(); tmp = gen_vfp_mrs(); tcg_gen_shri_i32(tmp, tmp, 16); if (dp) { gen_helper_vfp_fcvt_f16_to_f64(cpu_F0d, tmp, - cpu_env); + fpst, ahp); } else { gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp, - cpu_env); + fpst, ahp); } tcg_temp_free_i32(tmp); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); break; + } case 6: /* vcvtb.f16.f32, vcvtb.f16.f64 */ + { + TCGv_ptr fpst = get_fpstatus_ptr(false); + TCGv_i32 ahp = get_ahp_flag(); tmp = tcg_temp_new_i32(); + if (dp) { gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - cpu_env); + fpst, ahp); } else { gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - cpu_env); + fpst, ahp); } + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); gen_mov_F0_vreg(0, rd); tmp2 = gen_vfp_mrs(); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); @@ -3863,15 +3881,21 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) tcg_temp_free_i32(tmp2); gen_vfp_msr(tmp); break; + } case 7: /* vcvtt.f16.f32, vcvtt.f16.f64 */ + { + TCGv_ptr fpst = get_fpstatus_ptr(true); + TCGv_i32 ahp = get_ahp_flag(); tmp = tcg_temp_new_i32(); if (dp) { gen_helper_vfp_fcvt_f64_to_f16(tmp, cpu_F0d, - cpu_env); + fpst, ahp); } else { gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, - cpu_env); + fpst, ahp); } + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); tcg_gen_shli_i32(tmp, tmp, 16); gen_mov_F0_vreg(0, rd); tmp2 = gen_vfp_mrs(); @@ -3880,6 +3904,7 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) tcg_temp_free_i32(tmp2); gen_vfp_msr(tmp); break; + } case 8: /* cmp */ gen_vfp_cmp(dp); break; @@ -7222,53 +7247,70 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) } break; case NEON_2RM_VCVT_F16_F32: + { + TCGv_ptr fpst; + TCGv_i32 ahp; + if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) || q || (rm & 1)) { return 1; } tmp = tcg_temp_new_i32(); tmp2 = tcg_temp_new_i32(); + fpst = get_fpstatus_ptr(true); + ahp = get_ahp_flag(); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 0)); - gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, fpst, ahp); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 1)); - gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tmp2, cpu_F0s, fpst, ahp); tcg_gen_shli_i32(tmp2, tmp2, 16); tcg_gen_or_i32(tmp2, tmp2, tmp); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 2)); - gen_helper_neon_fcvt_f32_to_f16(tmp, cpu_F0s, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tmp, cpu_F0s, fpst, ahp); tcg_gen_ld_f32(cpu_F0s, cpu_env, neon_reg_offset(rm, 3)); neon_store_reg(rd, 0, tmp2); tmp2 = tcg_temp_new_i32(); - gen_helper_neon_fcvt_f32_to_f16(tmp2, cpu_F0s, cpu_env); + gen_helper_vfp_fcvt_f32_to_f16(tmp2, cpu_F0s, fpst, ahp); tcg_gen_shli_i32(tmp2, tmp2, 16); tcg_gen_or_i32(tmp2, tmp2, tmp); neon_store_reg(rd, 1, tmp2); tcg_temp_free_i32(tmp); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); break; + } case NEON_2RM_VCVT_F32_F16: + { + TCGv_ptr fpst; + TCGv_i32 ahp; if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) || q || (rd & 1)) { return 1; } + fpst = get_fpstatus_ptr(true); + ahp = get_ahp_flag(); tmp3 = tcg_temp_new_i32(); tmp = neon_load_reg(rm, 0); tmp2 = neon_load_reg(rm, 1); tcg_gen_ext16u_i32(tmp3, tmp); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ahp); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 0)); tcg_gen_shri_i32(tmp3, tmp, 16); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ahp); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 1)); tcg_temp_free_i32(tmp); tcg_gen_ext16u_i32(tmp3, tmp2); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ahp); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 2)); tcg_gen_shri_i32(tmp3, tmp2, 16); - gen_helper_neon_fcvt_f16_to_f32(cpu_F0s, tmp3, cpu_env); + gen_helper_vfp_fcvt_f16_to_f32(cpu_F0s, tmp3, fpst, ahp); tcg_gen_st_f32(cpu_F0s, cpu_env, neon_reg_offset(rd, 3)); tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp3); + tcg_temp_free_i32(ahp); + tcg_temp_free_ptr(fpst); break; + } case NEON_2RM_AESE: case NEON_2RM_AESMC: if (!arm_dc_feature(s, ARM_FEATURE_V8_AES) || ((rm | rd) & 1)) { From patchwork Mon May 14 22:12:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135768 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp191751lji; Mon, 14 May 2018 15:19:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpt6WmpofVFUj1P7gnXzPI8aBb7bO7Yhkq/3wQOOULpsr57e+1f9AoZnsoTPS+97wSpcLcc X-Received: by 2002:a0c:8856:: with SMTP id 22-v6mr10848938qvm.79.1526336397952; Mon, 14 May 2018 15:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336397; cv=none; d=google.com; s=arc-20160816; b=E8go+ZLIrqbACt5iNb0C9SP4FPit9fu4dHMR0lkHjGbupFo2Ez4RoAOK9s5VFYzMgs QQmb/7DMF2tEZVnjCAYBzQmeIufm4j9CwXuuN8Dx0cZgylmPSPbn8O24xuTb/0OcSU7i yayCNoDeRjTkefoEgGVA1Yc5vvl/3AAZ0bqmRCFyGbH7jcxHpnPl3bEC4+m8jFn0vWM5 9eLN6UQZyihwTrMOspqsOsC6R98Bw4rX+16p74utaGBWoy0WT7DWv9lBN47m4jpBnX7u vembQsy1eIPcovSa3nFX8pRr1lVGpSoAja7kJ+jBgi6af6SDUd3A02gXs4ckEHXnQBQc 4QIw== 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:arc-authentication-results; bh=3Gt6m5cGwrRSwWZ854aVfOdGATsWs+vxTefTZvehpJc=; b=OEQ/u6oCYqiQIdA1xTcgbkT+URVBWs4y3skO5wn56d2jXKPIulFzy8l2PZpDtFy4nB EENLZsWlXeavC7Jg743cnstNc0RuukXv0gipVVwQzuS0tSm30TiQGK9O3AUwolZzlO8h 0HMNPNXe1Zyoc9mo8P/JcNiU8chC5tWc4YKzNgyDBfJOw9B8aRGXJINw0d8dQoRViJtS O26mhAN5PU1ivKuE4WcX5fv1U6RM7qg7LD+5TnxQuxXjwUzxlaSDPh3uARWudyQsNJ+M dnYiX+GbRroRo+UIImg5u02L8b2APpwOqd4ex9TLQLPmMPWToL2w6/VmJrfhuFGj2aVh AU6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IC0Mhdyz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 26-v6si9229858qvv.71.2018.05.14.15.19.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IC0Mhdyz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILoz-0005Xj-Bw for patch@linaro.org; Mon, 14 May 2018 18:19:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhv-0007yG-E4 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhu-0007mc-BS for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:39 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:40995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhu-0007km-5E for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:38 -0400 Received: by mail-pf0-x242.google.com with SMTP id v63-v6so6663117pfk.8 for ; Mon, 14 May 2018 15:12:38 -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=3Gt6m5cGwrRSwWZ854aVfOdGATsWs+vxTefTZvehpJc=; b=IC0Mhdyz1pIkQRdu7TQVS1K+eebs3RGicGGpfrpPYyI6FXcyb4axp4NMAsePVmoNHW V58zd0YDr5AVZtJ2rkkTq2pe7Ue1+VoolphTSXI9d43jlirWe5vJEN67bxh+NLfhsF/v xV9uT0f3bt5SpI2/MKMkGOWnffqM+blHxijaU= 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=3Gt6m5cGwrRSwWZ854aVfOdGATsWs+vxTefTZvehpJc=; b=nPJugY69LM9ZAbQNYQ6HB6eM7PdwpyDkhzNo1NKjIfMV+LqKKysNvJ7JpkRliTyG60 LBvMXb3kpinNPlrzLLNdOLq7ze1cbqxgoGu37PYUTGP73vCML5txxKxy7TkhtLYv8kuT WSvwvrJB+CAEI5gyoXmX6uDdFjYAgo/cAJW1Fx4wyhur/RSQpae0YfPD01WjLv9ZJD4A +uHHYmTthc2Qk3wYaNO53yU/aAy0salD+x493/9rRHmbiSs/IHxaaS83vX/5arceuVOg yYrCSgAyf1EbinRZzxFOOSW4Lshp6OSUs4q0eD9936l6pj7Lst4jVN2vFBy879+Cq0e5 cSzA== X-Gm-Message-State: ALKqPweVSH5WgFiwFdxhmL6bLetoMMrk7c2Htgx4WgqOs8YF0OZ8f/Yf 0nLHUnWNgMvqiRWcgZxA/gJ08hOuEPg= X-Received: by 2002:a63:8849:: with SMTP id l70-v6mr10026762pgd.49.1526335956835; Mon, 14 May 2018 15:12:36 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:02 -0700 Message-Id: <20180514221219.7091-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v5 11/28] target/arm: squash FZ16 behaviour for conversions 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée The ARM ARM specifies FZ16 is suppressed for conversions. Rather than pushing this logic into the softfloat code we can simply save the FZ state and temporarily disable it for the softfloat call. Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Signed-off-by: Richard Henderson --- v4 - float16_to_floatX squished the wrong softfloat bit for FZ16; need to adjust input denormals in this case. --- target/arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) -- 2.17.0 diff --git a/target/arm/helper.c b/target/arm/helper.c index a1c1dc5bbe..e05c7230d4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11542,22 +11542,54 @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) /* Half precision conversions. */ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) { - return float16_to_float32(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float32 r = float16_to_float32(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; } float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) { - return float32_to_float16(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r = float32_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; } float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) { - return float16_to_float64(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float64 r = float16_to_float64(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; } float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) { - return float64_to_float16(a, !ahp_mode, fpstp); + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r = float64_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; } #define float32_two make_float32(0x40000000) From patchwork Mon May 14 22:12:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135767 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp191483lji; Mon, 14 May 2018 15:19:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8hO6B8rK79clIaggsqTryNMOarFHxE68dDl2vOhfRVVqaRdOT0Hhmau1dHjDlYh2E7d4f X-Received: by 2002:a37:8503:: with SMTP id h3-v6mr9742284qkd.199.1526336375614; Mon, 14 May 2018 15:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336375; cv=none; d=google.com; s=arc-20160816; b=cRahFuqcF/H/9OhAoFzFXnTaKcbC1QMkRUlAJhtw3iY/UE6k3HvhBQ5VXsC4X7wi4b m4MjRUn9OSFNguenL1QC1to/RaXyhlCuZ3/GaNEYX1pDxXZK910cxVYFKQxDKb308yH+ QnlR8oCl/6nWnD90aczhcgOuJsEMXqs7dXpuUrJ/nrl4WCGDcvNAd0f503xRKPtr30wL 5PK5VEyjC70UvnmsKSApdEYYjUr/NlVwBfQjSl0NbYl+tdJPFP0kmrGQfdljOlwY93OR 2biny4q8gqdoPkf+a2YQmcL/XX7JjkhSh1I0hgSB7ObImADiWAlQTNztSbpCifrmJclK g+cg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=3p1uYPjT+Qh7BPWBI2DONjm1ihiuZReCWqTClVy4o+c=; b=vp7a20USAd3KXZrrv02/54m4fyaSqC+dLdlcvYMmkhpSqHGbAXXrVZWRvkcAguemQK M3Q8mZ3JmM5EFXZYdH7MRss7nmDI/wIbSzgKlLdMlw5cgecaWTUBwAZ583QjUbow59YQ lCe6K/MSinvSbGOgyihIjQ0+AObGLRdMu0JeFmI1jQnxiqSSkw1n5VxoxdvZQD6esdmj eU5plP4rUM+T8FDvUhmWLoF9Q54y1sL6gjTj1sDsOjH/LLU/1V2w2BTmI0HUCUAcB9v/ NZv7kUtkH4v/SG3dSHwsI219E+hMX4+asFcS8ym6QkNYyvEAVcjg3ONnijLrW6Y4a8c7 avzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MftfZeHn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d88-v6si1430394qkh.133.2018.05.14.15.19.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:19:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MftfZeHn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILoc-0005Hp-Vu for patch@linaro.org; Mon, 14 May 2018 18:19:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhw-0007zT-J7 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhv-0007pc-MM for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:40 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44297) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhv-0007o7-HU for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:39 -0400 Received: by mail-pg0-x241.google.com with SMTP id x145-v6so6057473pgx.11 for ; Mon, 14 May 2018 15:12:39 -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; bh=3p1uYPjT+Qh7BPWBI2DONjm1ihiuZReCWqTClVy4o+c=; b=MftfZeHnFRwIvAEpXl6i8nx22jPVEbWx/bZgX4etNf8Di/jK2g4Hcq3qtJHBwEi7RO DVu1Io1OMZlFda4Z/dgzNtiM3gfvAEPbPKBZ4+XBRi8CIv8hPjVpt4jGpqVbueOM7ma8 qiRWSUToNAVBgj9PBPsXJ3NdYTfAQfPSFKkm4= 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; bh=3p1uYPjT+Qh7BPWBI2DONjm1ihiuZReCWqTClVy4o+c=; b=d2Uu5rwY2z7UUFLQZ7RtkZFjRKpB/TPf1fuiLsRAaT6Z8rBm4QKvaPrNs1zu0MncWS gz8FF8gCVo+JuQJyk5iZyRB7rNKq3hgeli0+djWbPUWWQQZ5aFveIiZQgLmrk8+eUX9Y XwmtY3BwDGNhVDkYOqdb3h0KCH8xP64l7PkI2htzBRbmQXRA5NrkSSMDGu35Etd6LFUb M7tpI6Uqjh8aPLzYVBYBMtTQ7AfAteO2uyg1XGZzR7SUIooP/FpYCEKWxM0f8dMCUNVp D/3gDKMA5AaR2ecJ46RqYk4mYLg29/irioTypjSPFCsIVoCtKGzM+RGziQ/+sxkyeiRC FSiQ== X-Gm-Message-State: ALKqPweyUMcYbf6mtxDRu36xFoVN40dNhE6BhLDbCvlhhiFniY7+a2OB hD0/Es11Xv9BQ032zP+GVjZEkRMgo9Q= X-Received: by 2002:a63:5f11:: with SMTP id t17-v6mr8331778pgb.94.1526335958243; Mon, 14 May 2018 15:12:38 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:03 -0700 Message-Id: <20180514221219.7091-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v5 12/28] target/arm: Remove floatX_maybe_silence_nan from conversions 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is now handled properly by the generic softfloat code. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper-a64.c | 1 - target/arm/helper.c | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index 6f0eb83661..f92bdea732 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -466,7 +466,6 @@ float32 HELPER(fcvtx_f64_to_f32)(float64 a, CPUARMState *env) set_float_rounding_mode(float_round_to_zero, &tstat); set_float_exception_flags(0, &tstat); r = float64_to_float32(a, &tstat); - r = float32_maybe_silence_nan(r, &tstat); exflags = get_float_exception_flags(&tstat); if (exflags & float_flag_inexact) { r = make_float32(float32_val(r) | 1); diff --git a/target/arm/helper.c b/target/arm/helper.c index e05c7230d4..db8bbe52a6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11348,20 +11348,12 @@ FLOAT_CONVS(ui, d, 64, u) /* floating point conversion */ float64 VFP_HELPER(fcvtd, s)(float32 x, CPUARMState *env) { - float64 r = float32_to_float64(x, &env->vfp.fp_status); - /* ARM requires that S<->D conversion of any kind of NaN generates - * a quiet NaN by forcing the most significant frac bit to 1. - */ - return float64_maybe_silence_nan(r, &env->vfp.fp_status); + return float32_to_float64(x, &env->vfp.fp_status); } float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) { - float32 r = float64_to_float32(x, &env->vfp.fp_status); - /* ARM requires that S<->D conversion of any kind of NaN generates - * a quiet NaN by forcing the most significant frac bit to 1. - */ - return float32_maybe_silence_nan(r, &env->vfp.fp_status); + return float64_to_float32(x, &env->vfp.fp_status); } /* VFP3 fixed point conversion. */ From patchwork Mon May 14 22:12:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135772 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp194141lji; Mon, 14 May 2018 15:23:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo+Epw5745K/XQ0+JQ0LBLAEz6EmOjuHcG4jCNt9rIQWUFGZWFu/6X9CmC6OmYRBn2ka3ZX X-Received: by 2002:a37:7f46:: with SMTP id a67-v6mr5721693qkd.351.1526336584256; Mon, 14 May 2018 15:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336584; cv=none; d=google.com; s=arc-20160816; b=QrR05YxObjoDDuo8bpPq/TvlkZEbY82R3n+0ARyLIhVj6AKg798gt9/NgU/0vWlduX vZSNfq8tNnBVSg70DfbLd1RSYnQzEXfwSB53nAzm7X4DAJW4A87hmQbw7aUxPdvb7dK7 QyTSHU70ptCj+3CyxM/rurdoI1sTXCW5GPrJXYuQaRPDGAIZTS96Otq6Z6DQqNS2WA1N o3qXMcPmN+c4IOMES/KoONJp3PFrSae8RprZPOrBIDr8tGc4vA5/AicYAwEq+XqZ9N0X K/u14YFG1ddH4Py05musa9dW5Tgj+CFeH+yoPD7rYzrBB9XadSagewLy+pO0zeXLHSww +Z+w== 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:arc-authentication-results; bh=xMM/6wnUJ8B/UfH6AgnsVWQZAYVhlZ+l678zaVK2h38=; b=lDMFZMdW0oAUpzBe85r7Ksb2XKD2i2vulNlxzMy5g00CiMcrw9f1Db9zm5pIUv1vEX CF4fN/nTNH3IT+6AVVr8AFcgfgs2tt64D93gIQjdY1jgtnY+H5DXE0PgOgxJqdQZ20S6 8xsvaqJ0vXBAnT1f8VOtqY+UBG0kNpo+rlHCofTkMLTqspYRxh6d/rG1K2mHTVwa/NgF b0+w67BGsgYXZa1yvB6CBSfKE/Ngc8rq6IyFRPspp4nOqQq6ppgDkx+/aR+tMV3bSQ5w /pAmrO83ohYTvFrTNUmV3SlXgXdKRLDd3ntWZA9ZM0bhL1PlKY3upzzrRZhEQCsLOp3B +7cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RJOvV0rL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o15-v6si765384qvh.62.2018.05.14.15.23.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RJOvV0rL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILrz-0008BA-Hr for patch@linaro.org; Mon, 14 May 2018 18:23:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILhy-00081F-3a for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhw-0007sY-Uf for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:42 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:42032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhw-0007qm-PE for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:40 -0400 Received: by mail-pg0-x242.google.com with SMTP id p9-v6so6060364pgc.9 for ; Mon, 14 May 2018 15:12:40 -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=xMM/6wnUJ8B/UfH6AgnsVWQZAYVhlZ+l678zaVK2h38=; b=RJOvV0rLN3a256X/U6her30qw+7VdMJZO6/23LTYn8zXILaytmUIlfCmkUxrF0S7Gb m4xPVrJvMtQLWCR/lnr6gm+3PUH1tPLwNbltdy4sCqye7ghZEi6U8Ykz4qyrcGJEsmFz I3QDflfnS6rgCu/+gsZw+izlNqjA+TRrqsaz4= 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=xMM/6wnUJ8B/UfH6AgnsVWQZAYVhlZ+l678zaVK2h38=; b=FRWu2btsALyVCg8r5hGdEBl6YEfo8c0RyIZnS8jUTeqbQveULjgohci0OE75BXnW+H R79AITsEf3Q3SBQCDg+1iOpjZwNsOBoSwHNEJzVjyKQHeVvmLMBk/e+7tZUpMm/Jw8NX 1h3Yxf80GoZb8N6u0MVfNRG9YNVRQ4EEToPeaa8rBAdelXuLv7dpbTK764CbGXo2nEXO Ie6W6DOPWiAMNLalb88aUOqanlSxsgI/hzLqlpKNg7vTQn/kXPp9K6yQG51JLhAIfCvJ T3dQFjbKzL46v8kizlH/WDcjJhv6G7zr+/Lscf9T606hrhJX8zg/haiV/BYigWwoVmbh BUDg== X-Gm-Message-State: ALKqPwdUGTsgwS8KC/SNh5yjmHlk2JYqawmJ+Yo392phErEErOpXlblS xYjmB4xrLOv0EnHSv2z0lxAhnjCw4u0= X-Received: by 2002:a65:53ca:: with SMTP id z10-v6mr7726785pgr.413.1526335959580; Mon, 14 May 2018 15:12:39 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:04 -0700 Message-Id: <20180514221219.7091-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v5 13/28] fpu/softfloat: Partial support for ARM Alternative half-precision 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée For float16 ARM supports an alternative half-precision format which sacrifices the ability to represent NaN/Inf in return for a higher dynamic range. The new FloatFmt flag, arm_althp, is then used to modify the behaviour of canonicalize and round_canonical with respect to representation and exception raising. Usage of this new flag waits until we re-factor float-to-float conversions. Signed-off-by: Alex Bennée Signed-off-by: Richard Henderson --- v3 - squash NaN to 0 if destination is AHP F16 v4 - handle inf -> ahp max in float_to_float not round_canonical - assert no nan and inf for ahp in round_canonical - check ahp before snan in float_to_float v5 - split out canonicalize and round_canonical changes from the rest --- fpu/softfloat.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) -- 2.17.0 Reviewed-by: Peter Maydell diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 41253c6749..55d0d01ec3 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -220,8 +220,10 @@ typedef struct { * frac_shift: shift to normalise the fraction with DECOMPOSED_BINARY_POINT * The following are computed based the size of fraction * frac_lsb: least significant bit of fraction - * fram_lsbm1: the bit bellow the least significant bit (for rounding) + * frac_lsbm1: the bit bellow the least significant bit (for rounding) * round_mask/roundeven_mask: masks used for rounding + * The following optional modifiers are available: + * arm_althp: handle ARM Alternative Half Precision */ typedef struct { int exp_size; @@ -233,6 +235,7 @@ typedef struct { uint64_t frac_lsbm1; uint64_t round_mask; uint64_t roundeven_mask; + bool arm_althp; } FloatFmt; /* Expand fields based on the size of exponent and fraction */ @@ -324,7 +327,7 @@ static inline float64 float64_pack_raw(FloatParts p) static FloatParts canonicalize(FloatParts part, const FloatFmt *parm, float_status *status) { - if (part.exp == parm->exp_max) { + if (part.exp == parm->exp_max && !parm->arm_althp) { if (part.frac == 0) { part.cls = float_class_inf; } else { @@ -413,7 +416,15 @@ static FloatParts round_canonical(FloatParts p, float_status *s, } frac >>= frac_shift; - if (unlikely(exp >= exp_max)) { + if (parm->arm_althp) { + /* ARM Alt HP eschews Inf and NaN for a wider exponent. */ + if (unlikely(exp > exp_max)) { + /* Overflow. Return the maximum normal. */ + flags = float_flag_invalid; + exp = exp_max; + frac = -1; + } + } else if (unlikely(exp >= exp_max)) { flags |= float_flag_overflow | float_flag_inexact; if (overflow_norm) { exp = exp_max - 1; @@ -464,12 +475,14 @@ static FloatParts round_canonical(FloatParts p, float_status *s, case float_class_inf: do_inf: + assert(!parm->arm_althp); exp = exp_max; frac = 0; break; case float_class_qnan: case float_class_snan: + assert(!parm->arm_althp); exp = exp_max; frac >>= parm->frac_shift; break; From patchwork Mon May 14 22:12:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135781 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp200959lji; Mon, 14 May 2018 15:31:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZof9TBYKlQv+hyj9wmN6qewRdfjgmU40oYpIytK+HB+EsEiMZLj1nsC0xuAQA55/UGsTOqC X-Received: by 2002:a0c:9699:: with SMTP id a25-v6mr10725983qvd.119.1526337108983; Mon, 14 May 2018 15:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337108; cv=none; d=google.com; s=arc-20160816; b=E08jpnWTK1sROli++VDe0W09qomh2e3u3YCG5l7HnVfhYKmrV0ELQGGF4FG8XVElXc fcNktANSxwAGAlsezmrDNICAr2snLU9PTsfkhjLdmP1U16DR1Cnd7rC5RhjXeFmm48h5 Lcq493DOwqnwxbWI2e/dFCblML7Ls2oWTedZWyMslH/q5RJbvBOYkgCpyyKVR3zG7Pjx mUlXGBrpSrV6qrtA3vxob0tkGWdzjHCSgWnT8IRbC+/0He4aEo97NhzeBQxiUZsKh6lc vdEDa45/PYNXQ+pY9HzAyBv+cKakup+ct7uh69seyBD5djED8F4mEo63Lbb7jWi8aL19 nvpw== 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:arc-authentication-results; bh=YVASLLmdeyYkv95jR1njHejb/dXrJzhKOk8H1pN32jc=; b=BBw9MwVVy4BNQ6QSw3iYGNN1IQZEbQJCqRFTz0fZBtoe3YXlxulCIHvbphUh2C6EnC X+RTeydH1EfAsjikFtM70kvGc317X+9iZfzhZBDOqY7dLhALMIJMr9VoUJJHwBzm/685 2VWzQ0acSr6kZqeZEaeEAfC1LG+GQ6Edn7BbxoNg46AH0zjYRgDhw6lrnGxtviEeMblG g3jLPDRIt4G0mFrYjyjdYP2F2ghMXwZLkvkk9icaurniqiVNlerBMqVj79eQuXSCYUZo yc+FUGOZYRm5eRX0um8rCzRpSJ+9bcPkmHuWsqWNtLXHE941GYvxs5CD9zuH9A+olg/y yAmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aIGJPLMp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 33-v6si10425743qtf.369.2018.05.14.15.31.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:31:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aIGJPLMp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIM0S-0006N8-AT for patch@linaro.org; Mon, 14 May 2018 18:31:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi1-00084h-OS for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhy-0007vg-PO for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:45 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:36752) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhy-0007u6-EB for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:42 -0400 Received: by mail-pf0-x22c.google.com with SMTP id w129-v6so6668454pfd.3 for ; Mon, 14 May 2018 15:12:42 -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=YVASLLmdeyYkv95jR1njHejb/dXrJzhKOk8H1pN32jc=; b=aIGJPLMpcFcgMDdkUonOWayAkoFGILlxFerx8y5OJ4/Ug3hKa2okknvZacc3jGZ3wi jZn+rzn+sgiU/4taTTtzadG3JGpIwpac83sKbtcFc3iNrmnRAanpRgeDpfFbRO/S2CDZ YZ9qcC1mVggiaBIrxIf68OKnY3Z+SUiVnQtfc= 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=YVASLLmdeyYkv95jR1njHejb/dXrJzhKOk8H1pN32jc=; b=D0T0B54NbkwVrqw+H5DstcQXGRQlAn9+hLKIuExtU5sv35ModEl7w8+yagB/AkyrXM Aszmh8GBRcIHQ26xGB1idgL2CNwoB7h3xjz4UfWVm7697CyBf9mOizbnZ+UHu1/s7H/y qemEDlNq+8noUieEb0eKvVeq5osS1LWQPBfbTjcLpdKNlwDkTb+05O4FKjwdKCc9YZ/O NRT0JorvugzrBdlpZv2Rp1WWYEuBUHuIZWUv4HTrD1+t8/ULHSq6dUlbAQTcF5TwcMcj HYXho4MDmPyV2picFN40h1tfpSkwXgdYgVNDvWmY7NzTuLqy0h+ioKCNf+8/Gk6B42gg CHIg== X-Gm-Message-State: ALKqPwfGa6bwVOaW/HNZeVhO6u58ARBbOUzjNfeTnSJrHBUBzdWRmhnl yguXuovjNmQ92GEQhKLSdb6zb/fyPRA= X-Received: by 2002:a65:4a48:: with SMTP id a8-v6mr9491529pgu.395.1526335960798; Mon, 14 May 2018 15:12:40 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:05 -0700 Message-Id: <20180514221219.7091-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PATCH v5 14/28] fpu/softfloat: re-factor float to float conversions 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée This allows us to delete a lot of additional boilerplate code which is no longer needed. Signed-off-by: Alex Bennée Signed-off-by: Richard Henderson --- v2 - pass FloatFmt to float_to_float instead of sizes - split AHP handling to another patch - use rth's suggested re-packing (+ setting .exp) v3 - also rm extractFloat16Sign v4 - update for canonical nan handling v5 - merge arm alt fp16 support into this patch --- fpu/softfloat-specialize.h | 40 --- include/fpu/softfloat.h | 8 +- fpu/softfloat.c | 488 +++++++++---------------------------- 3 files changed, 122 insertions(+), 414 deletions(-) -- 2.17.0 Reviewed-by: Peter Maydell diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 571d1df378..995a0132c6 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -377,46 +377,6 @@ float16 float16_maybe_silence_nan(float16 a, float_status *status) return a; } -/*---------------------------------------------------------------------------- -| Returns the result of converting the half-precision floating-point NaN -| `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid -| exception is raised. -*----------------------------------------------------------------------------*/ - -static commonNaNT float16ToCommonNaN(float16 a, float_status *status) -{ - commonNaNT z; - - if (float16_is_signaling_nan(a, status)) { - float_raise(float_flag_invalid, status); - } - z.sign = float16_val(a) >> 15; - z.low = 0; - z.high = ((uint64_t) float16_val(a)) << 54; - return z; -} - -/*---------------------------------------------------------------------------- -| Returns the result of converting the canonical NaN `a' to the half- -| precision floating-point format. -*----------------------------------------------------------------------------*/ - -static float16 commonNaNToFloat16(commonNaNT a, float_status *status) -{ - uint16_t mantissa = a.high >> 54; - - if (status->default_nan_mode) { - return float16_default_nan(status); - } - - if (mantissa) { - return make_float16(((((uint16_t) a.sign) << 15) - | (0x1F << 10) | mantissa)); - } else { - return float16_default_nan(status); - } -} - /*---------------------------------------------------------------------------- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 43962dc3f5..a6860e858d 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -211,10 +211,10 @@ float128 uint64_to_float128(uint64_t, float_status *status); /*---------------------------------------------------------------------------- | Software half-precision conversion routines. *----------------------------------------------------------------------------*/ -float16 float32_to_float16(float32, flag, float_status *status); -float32 float16_to_float32(float16, flag, float_status *status); -float16 float64_to_float16(float64 a, flag ieee, float_status *status); -float64 float16_to_float64(float16 a, flag ieee, float_status *status); +float16 float32_to_float16(float32, bool ieee, float_status *status); +float32 float16_to_float32(float16, bool ieee, float_status *status); +float16 float64_to_float16(float64 a, bool ieee, float_status *status); +float64 float16_to_float64(float16 a, bool ieee, float_status *status); int16_t float16_to_int16(float16, float_status *status); uint16_t float16_to_uint16(float16 a, float_status *status); int16_t float16_to_int16_round_to_zero(float16, float_status *status); diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 55d0d01ec3..e9e421728b 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -113,15 +113,6 @@ static inline int extractFloat16Exp(float16 a) return (float16_val(a) >> 10) & 0x1f; } -/*---------------------------------------------------------------------------- -| Returns the sign bit of the single-precision floating-point value `a'. -*----------------------------------------------------------------------------*/ - -static inline flag extractFloat16Sign(float16 a) -{ - return float16_val(a)>>15; -} - /*---------------------------------------------------------------------------- | Returns the fraction bits of the single-precision floating-point value `a'. *----------------------------------------------------------------------------*/ @@ -254,6 +245,11 @@ static const FloatFmt float16_params = { FLOAT_PARAMS(5, 10) }; +static const FloatFmt float16_params_ahp = { + FLOAT_PARAMS(5, 10), + .arm_althp = true +}; + static const FloatFmt float32_params = { FLOAT_PARAMS(8, 23) }; @@ -497,14 +493,27 @@ static FloatParts round_canonical(FloatParts p, float_status *s, return p; } +/* Explicit FloatFmt version */ +static FloatParts float16a_unpack_canonical(float16 f, float_status *s, + const FloatFmt *params) +{ + return canonicalize(float16_unpack_raw(f), params, s); +} + static FloatParts float16_unpack_canonical(float16 f, float_status *s) { - return canonicalize(float16_unpack_raw(f), &float16_params, s); + return float16a_unpack_canonical(f, s, &float16_params); +} + +static float16 float16a_round_pack_canonical(FloatParts p, float_status *s, + const FloatFmt *params) +{ + return float16_pack_raw(round_canonical(p, s, params)); } static float16 float16_round_pack_canonical(FloatParts p, float_status *s) { - return float16_pack_raw(round_canonical(p, s, &float16_params)); + return float16a_round_pack_canonical(p, s, &float16_params); } static FloatParts float32_unpack_canonical(float32 f, float_status *s) @@ -1181,6 +1190,104 @@ float64 float64_div(float64 a, float64 b, float_status *status) return float64_round_pack_canonical(pr, status); } +/* + * Float to Float conversions + * + * Returns the result of converting one float format to another. The + * conversion is performed according to the IEC/IEEE Standard for + * Binary Floating-Point Arithmetic. + * + * The float_to_float helper only needs to take care of raising + * invalid exceptions and handling the conversion on NaNs. + */ + +static FloatParts float_to_float(FloatParts a, const FloatFmt *dstf, + float_status *s) +{ + if (dstf->arm_althp) { + switch (a.cls) { + case float_class_qnan: + case float_class_snan: + /* There is no NaN in the destination format. Raise Invalid + * and return a zero with the sign of the input NaN. + */ + s->float_exception_flags |= float_flag_invalid; + a.cls = float_class_zero; + a.frac = 0; + a.exp = 0; + break; + + case float_class_inf: + /* There is no Inf in the destination format. Raise Invalid + * and return the maximum normal with the correct sign. + */ + s->float_exception_flags |= float_flag_invalid; + a.cls = float_class_normal; + a.exp = dstf->exp_max; + a.frac = ((1ull << dstf->frac_size) - 1) << dstf->frac_shift; + break; + + default: + break; + } + } else if (is_nan(a.cls)) { + if (is_snan(a.cls)) { + s->float_exception_flags |= float_flag_invalid; + a = parts_silence_nan(a, s); + } + if (s->default_nan_mode) { + return parts_default_nan(s); + } + } + return a; +} + +float32 float16_to_float32(float16 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp; + FloatParts p = float16a_unpack_canonical(a, s, fmt16); + FloatParts pr = float_to_float(p, &float32_params, s); + return float32_round_pack_canonical(pr, s); +} + +float64 float16_to_float64(float16 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp; + FloatParts p = float16a_unpack_canonical(a, s, fmt16); + FloatParts pr = float_to_float(p, &float64_params, s); + return float64_round_pack_canonical(pr, s); +} + +float16 float32_to_float16(float32 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp; + FloatParts p = float32_unpack_canonical(a, s); + FloatParts pr = float_to_float(p, fmt16, s); + return float16a_round_pack_canonical(pr, s, fmt16); +} + +float64 float32_to_float64(float32 a, float_status *s) +{ + FloatParts p = float32_unpack_canonical(a, s); + FloatParts pr = float_to_float(p, &float64_params, s); + return float64_round_pack_canonical(pr, s); +} + +float16 float64_to_float16(float64 a, bool ieee, float_status *s) +{ + const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp; + FloatParts p = float64_unpack_canonical(a, s); + FloatParts pr = float_to_float(p, fmt16, s); + return float16a_round_pack_canonical(pr, s, fmt16); +} + +float32 float64_to_float32(float64 a, float_status *s) +{ + FloatParts p = float64_unpack_canonical(a, s); + FloatParts pr = float_to_float(p, &float32_params, s); + return float32_round_pack_canonical(pr, s); +} + /* * Rounds the floating-point value `a' to an integer, and returns the * result as a floating-point value. The operation is performed @@ -3124,41 +3231,6 @@ float128 uint64_to_float128(uint64_t a, float_status *status) return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status); } - - - -/*---------------------------------------------------------------------------- -| Returns the result of converting the single-precision floating-point value -| `a' to the double-precision floating-point format. The conversion is -| performed according to the IEC/IEEE Standard for Binary Floating-Point -| Arithmetic. -*----------------------------------------------------------------------------*/ - -float64 float32_to_float64(float32 a, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - a = float32_squash_input_denormal(a, status); - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - if ( aExp == 0xFF ) { - if (aSig) { - return commonNaNToFloat64(float32ToCommonNaN(a, status), status); - } - return packFloat64( aSign, 0x7FF, 0 ); - } - if ( aExp == 0 ) { - if ( aSig == 0 ) return packFloat64( aSign, 0, 0 ); - normalizeFloat32Subnormal( aSig, &aExp, &aSig ); - --aExp; - } - return packFloat64( aSign, aExp + 0x380, ( (uint64_t) aSig )<<29 ); - -} - /*---------------------------------------------------------------------------- | Returns the result of converting the single-precision floating-point value | `a' to the extended double-precision floating-point format. The conversion @@ -3677,173 +3749,6 @@ int float32_unordered_quiet(float32 a, float32 b, float_status *status) return 0; } - -/*---------------------------------------------------------------------------- -| Returns the result of converting the double-precision floating-point value -| `a' to the single-precision floating-point format. The conversion is -| performed according to the IEC/IEEE Standard for Binary Floating-Point -| Arithmetic. -*----------------------------------------------------------------------------*/ - -float32 float64_to_float32(float64 a, float_status *status) -{ - flag aSign; - int aExp; - uint64_t aSig; - uint32_t zSig; - a = float64_squash_input_denormal(a, status); - - aSig = extractFloat64Frac( a ); - aExp = extractFloat64Exp( a ); - aSign = extractFloat64Sign( a ); - if ( aExp == 0x7FF ) { - if (aSig) { - return commonNaNToFloat32(float64ToCommonNaN(a, status), status); - } - return packFloat32( aSign, 0xFF, 0 ); - } - shift64RightJamming( aSig, 22, &aSig ); - zSig = aSig; - if ( aExp || zSig ) { - zSig |= 0x40000000; - aExp -= 0x381; - } - return roundAndPackFloat32(aSign, aExp, zSig, status); - -} - - -/*---------------------------------------------------------------------------- -| Packs the sign `zSign', exponent `zExp', and significand `zSig' into a -| half-precision floating-point value, returning the result. After being -| shifted into the proper positions, the three fields are simply added -| together to form the result. This means that any integer portion of `zSig' -| will be added into the exponent. Since a properly normalized significand -| will have an integer portion equal to 1, the `zExp' input should be 1 less -| than the desired result exponent whenever `zSig' is a complete, normalized -| significand. -*----------------------------------------------------------------------------*/ -static float16 packFloat16(flag zSign, int zExp, uint16_t zSig) -{ - return make_float16( - (((uint32_t)zSign) << 15) + (((uint32_t)zExp) << 10) + zSig); -} - -/*---------------------------------------------------------------------------- -| Takes an abstract floating-point value having sign `zSign', exponent `zExp', -| and significand `zSig', and returns the proper half-precision floating- -| point value corresponding to the abstract input. Ordinarily, the abstract -| value is simply rounded and packed into the half-precision format, with -| the inexact exception raised if the abstract input cannot be represented -| exactly. However, if the abstract value is too large, the overflow and -| inexact exceptions are raised and an infinity or maximal finite value is -| returned. If the abstract value is too small, the input value is rounded to -| a subnormal number, and the underflow and inexact exceptions are raised if -| the abstract input cannot be represented exactly as a subnormal half- -| precision floating-point number. -| The `ieee' flag indicates whether to use IEEE standard half precision, or -| ARM-style "alternative representation", which omits the NaN and Inf -| encodings in order to raise the maximum representable exponent by one. -| The input significand `zSig' has its binary point between bits 22 -| and 23, which is 13 bits to the left of the usual location. This shifted -| significand must be normalized or smaller. If `zSig' is not normalized, -| `zExp' must be 0; in that case, the result returned is a subnormal number, -| and it must not require rounding. In the usual case that `zSig' is -| normalized, `zExp' must be 1 less than the ``true'' floating-point exponent. -| Note the slightly odd position of the binary point in zSig compared with the -| other roundAndPackFloat functions. This should probably be fixed if we -| need to implement more float16 routines than just conversion. -| The handling of underflow and overflow follows the IEC/IEEE Standard for -| Binary Floating-Point Arithmetic. -*----------------------------------------------------------------------------*/ - -static float16 roundAndPackFloat16(flag zSign, int zExp, - uint32_t zSig, flag ieee, - float_status *status) -{ - int maxexp = ieee ? 29 : 30; - uint32_t mask; - uint32_t increment; - bool rounding_bumps_exp; - bool is_tiny = false; - - /* Calculate the mask of bits of the mantissa which are not - * representable in half-precision and will be lost. - */ - if (zExp < 1) { - /* Will be denormal in halfprec */ - mask = 0x00ffffff; - if (zExp >= -11) { - mask >>= 11 + zExp; - } - } else { - /* Normal number in halfprec */ - mask = 0x00001fff; - } - - switch (status->float_rounding_mode) { - case float_round_nearest_even: - increment = (mask + 1) >> 1; - if ((zSig & mask) == increment) { - increment = zSig & (increment << 1); - } - break; - case float_round_ties_away: - increment = (mask + 1) >> 1; - break; - case float_round_up: - increment = zSign ? 0 : mask; - break; - case float_round_down: - increment = zSign ? mask : 0; - break; - default: /* round_to_zero */ - increment = 0; - break; - } - - rounding_bumps_exp = (zSig + increment >= 0x01000000); - - if (zExp > maxexp || (zExp == maxexp && rounding_bumps_exp)) { - if (ieee) { - float_raise(float_flag_overflow | float_flag_inexact, status); - return packFloat16(zSign, 0x1f, 0); - } else { - float_raise(float_flag_invalid, status); - return packFloat16(zSign, 0x1f, 0x3ff); - } - } - - if (zExp < 0) { - /* Note that flush-to-zero does not affect half-precision results */ - is_tiny = - (status->float_detect_tininess == float_tininess_before_rounding) - || (zExp < -1) - || (!rounding_bumps_exp); - } - if (zSig & mask) { - float_raise(float_flag_inexact, status); - if (is_tiny) { - float_raise(float_flag_underflow, status); - } - } - - zSig += increment; - if (rounding_bumps_exp) { - zSig >>= 1; - zExp++; - } - - if (zExp < -10) { - return packFloat16(zSign, 0, 0); - } - if (zExp < 0) { - zSig >>= -zExp; - zExp = 0; - } - return packFloat16(zSign, zExp, zSig >> 13); -} - /*---------------------------------------------------------------------------- | If `a' is denormal and we are in flush-to-zero mode then set the | input-denormal exception and return zero. Otherwise just return the value. @@ -3859,163 +3764,6 @@ float16 float16_squash_input_denormal(float16 a, float_status *status) return a; } -static void normalizeFloat16Subnormal(uint32_t aSig, int *zExpPtr, - uint32_t *zSigPtr) -{ - int8_t shiftCount = countLeadingZeros32(aSig) - 21; - *zSigPtr = aSig << shiftCount; - *zExpPtr = 1 - shiftCount; -} - -/* Half precision floats come in two formats: standard IEEE and "ARM" format. - The latter gains extra exponent range by omitting the NaN/Inf encodings. */ - -float32 float16_to_float32(float16 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - - aSign = extractFloat16Sign(a); - aExp = extractFloat16Exp(a); - aSig = extractFloat16Frac(a); - - if (aExp == 0x1f && ieee) { - if (aSig) { - return commonNaNToFloat32(float16ToCommonNaN(a, status), status); - } - return packFloat32(aSign, 0xff, 0); - } - if (aExp == 0) { - if (aSig == 0) { - return packFloat32(aSign, 0, 0); - } - - normalizeFloat16Subnormal(aSig, &aExp, &aSig); - aExp--; - } - return packFloat32( aSign, aExp + 0x70, aSig << 13); -} - -float16 float32_to_float16(float32 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - - a = float32_squash_input_denormal(a, status); - - aSig = extractFloat32Frac( a ); - aExp = extractFloat32Exp( a ); - aSign = extractFloat32Sign( a ); - if ( aExp == 0xFF ) { - if (aSig) { - /* Input is a NaN */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0, 0); - } - return commonNaNToFloat16( - float32ToCommonNaN(a, status), status); - } - /* Infinity */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0x1f, 0x3ff); - } - return packFloat16(aSign, 0x1f, 0); - } - if (aExp == 0 && aSig == 0) { - return packFloat16(aSign, 0, 0); - } - /* Decimal point between bits 22 and 23. Note that we add the 1 bit - * even if the input is denormal; however this is harmless because - * the largest possible single-precision denormal is still smaller - * than the smallest representable half-precision denormal, and so we - * will end up ignoring aSig and returning via the "always return zero" - * codepath. - */ - aSig |= 0x00800000; - aExp -= 0x71; - - return roundAndPackFloat16(aSign, aExp, aSig, ieee, status); -} - -float64 float16_to_float64(float16 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint32_t aSig; - - aSign = extractFloat16Sign(a); - aExp = extractFloat16Exp(a); - aSig = extractFloat16Frac(a); - - if (aExp == 0x1f && ieee) { - if (aSig) { - return commonNaNToFloat64( - float16ToCommonNaN(a, status), status); - } - return packFloat64(aSign, 0x7ff, 0); - } - if (aExp == 0) { - if (aSig == 0) { - return packFloat64(aSign, 0, 0); - } - - normalizeFloat16Subnormal(aSig, &aExp, &aSig); - aExp--; - } - return packFloat64(aSign, aExp + 0x3f0, ((uint64_t)aSig) << 42); -} - -float16 float64_to_float16(float64 a, flag ieee, float_status *status) -{ - flag aSign; - int aExp; - uint64_t aSig; - uint32_t zSig; - - a = float64_squash_input_denormal(a, status); - - aSig = extractFloat64Frac(a); - aExp = extractFloat64Exp(a); - aSign = extractFloat64Sign(a); - if (aExp == 0x7FF) { - if (aSig) { - /* Input is a NaN */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0, 0); - } - return commonNaNToFloat16( - float64ToCommonNaN(a, status), status); - } - /* Infinity */ - if (!ieee) { - float_raise(float_flag_invalid, status); - return packFloat16(aSign, 0x1f, 0x3ff); - } - return packFloat16(aSign, 0x1f, 0); - } - shift64RightJamming(aSig, 29, &aSig); - zSig = aSig; - if (aExp == 0 && zSig == 0) { - return packFloat16(aSign, 0, 0); - } - /* Decimal point between bits 22 and 23. Note that we add the 1 bit - * even if the input is denormal; however this is harmless because - * the largest possible single-precision denormal is still smaller - * than the smallest representable half-precision denormal, and so we - * will end up ignoring aSig and returning via the "always return zero" - * codepath. - */ - zSig |= 0x00800000; - aExp -= 0x3F1; - - return roundAndPackFloat16(aSign, aExp, zSig, ieee, status); -} - /*---------------------------------------------------------------------------- | Returns the result of converting the double-precision floating-point value | `a' to the extended double-precision floating-point format. The conversion From patchwork Mon May 14 22:12:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135774 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp196198lji; Mon, 14 May 2018 15:25:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpvX0nvDRoef1cLwLyWxm8hQ0+0C4mwQzEW+aRF+gojqhgZiqgRb6K4CjJzdzORSiTsZyZZ X-Received: by 2002:a37:d9da:: with SMTP id q87-v6mr10742409qkl.302.1526336751963; Mon, 14 May 2018 15:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336751; cv=none; d=google.com; s=arc-20160816; b=y1oYXsWIiXD6UF+pNyqqPycWZbto21RAHIOFHl5+JhG42nFuYZZxhjdcM89OXkN4G3 Zil5V90U8vrUYWhg+12k3bCQyRXcH3yo6tkqutyUnOIPq70Qpfu2EVxZkHiVPe86RTNt dNJornJRDYpxaa4U1nDQA0SbYqwWQQK4/OfBw7nqdGZWZ6yNViwUn6is+sLX11aj9r7M OxEwoVUCvBt4vTzW9Prsygx9bwzRKCZL/575NmUAtltUq9ehrFcGDzK8OIcVxlvclB18 1dL+PjuIa5dwhkXdJTKS26Xc83MJiiBDxGdKuPbp6LHowMz4r/Oj7LlnkudLP7SPCtbP EfFA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=1Mx8i479tPm4Ez9yZyrtzG8zM3rDgGJOLuQ8CZwezuY=; b=EbiXNkPbYHeSL8pgjHoy5mA3TuS3HOeam0vtAzpOGanxBTRsrdy/P/agGYeyztGzkX fyj73uYb39lo7TT9fyJStvgRY1NLCXMN5NM9MGwycKqrP+xutSX1vEs3TCwQ5TfOLZMQ TPPG6PQdAfzkAuJgEy+hC3ZGslDvPe2d9VpUE7Vn+bCNHE6tCgE71x/IBR7W168GaelC bTG8i27KxTAqTkDHJ0ElbMxQQkcRuyGcnlH7Txl8rdKigqe40q9VRXvup/z9do3MCL8k cCr6bYPPRs8u8uTU996r5CBDv7e66ptaDyR/I254MD8ZN9qm7k9n0r543mxHuWJuXZTa yJXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iOhj4Jn/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c135-v6si3092550qka.357.2018.05.14.15.25.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iOhj4Jn/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILuh-0002TM-DV for patch@linaro.org; Mon, 14 May 2018 18:25:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi1-00084Q-Gz for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILhz-0007xk-M8 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:45 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:47014) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILhz-0007wJ-G6 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:43 -0400 Received: by mail-pg0-x241.google.com with SMTP id z4-v6so6056119pgu.13 for ; Mon, 14 May 2018 15:12:43 -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; bh=1Mx8i479tPm4Ez9yZyrtzG8zM3rDgGJOLuQ8CZwezuY=; b=iOhj4Jn/bKMaUxN7uUFY0a9XgqdblkmATGsNwXqgoUYqhFj0ZEvOjPEtK1rwWMa1NC r4rbag3m7rOPQXIPxAVRv6ommiSeLh9fs6jHHkjXESSO7rQkpOjXNS6OGFv+cD6zNyp8 OXQufz3HxMS7VypsNWCQEtpZ2c3f9TLWa1f8I= 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; bh=1Mx8i479tPm4Ez9yZyrtzG8zM3rDgGJOLuQ8CZwezuY=; b=Fk2039ehp6Xy6lkigFNLUnjYOH/zK0b9XLPvcrV1WEF8fzCI4ynR9CUk5DCsGuPBjN p5HLUpksxwbgiIRqZiR1CekfOJ+v5Cdiq+uBT+AgqOcG4IJnzWEH5gzxS9l8Jp52aqoM bDtuiDGyJhI5G3A12Ylue/nfXbTmTq/Fl911Mg3+vQ08O6uR6fDl267uv2zlCDhpiY9F 9cDsNh3UkCjGtiwCu2vb+Pyv+jK56sVkqRsA6No/uDavXM0quVyv9n3KcTNfaxQMoK+T X4RETCblfNpgTFjxAoKhJyXCOlyBSOxTnI0k+6wbIYIB6p7M73vffWGx4WKyDF9gt+0U y8og== X-Gm-Message-State: ALKqPwfVSKz0qvMA8InufhUT0u7PC490OQhFDdAYtYw4/JAqI/2TcN11 c23oBjnpoIsKWHgnSLOuI9wSlCAGuAU= X-Received: by 2002:a63:b406:: with SMTP id s6-v6mr10076044pgf.334.1526335962306; Mon, 14 May 2018 15:12:42 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:06 -0700 Message-Id: <20180514221219.7091-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v5 15/28] target/hppa: Remove floatX_maybe_silence_nan from conversions 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is now handled properly by the generic softfloat code. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/hppa/op_helper.c | 2 -- 1 file changed, 2 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index a3af62daf7..912e8d5be4 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -341,7 +341,6 @@ float64 HELPER(fdiv_d)(CPUHPPAState *env, float64 a, float64 b) float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg) { float64 ret = float32_to_float64(arg, &env->fp_status); - ret = float64_maybe_silence_nan(ret, &env->fp_status); update_fr0_op(env, GETPC()); return ret; } @@ -349,7 +348,6 @@ float64 HELPER(fcnv_s_d)(CPUHPPAState *env, float32 arg) float32 HELPER(fcnv_d_s)(CPUHPPAState *env, float64 arg) { float32 ret = float64_to_float32(arg, &env->fp_status); - ret = float32_maybe_silence_nan(ret, &env->fp_status); update_fr0_op(env, GETPC()); return ret; } From patchwork Mon May 14 22:12:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135775 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp196396lji; Mon, 14 May 2018 15:26:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrAL3v0oNOub6YGtom9V+4KenHnNfoDkfP5c+XH6/67VLCAUUUZrGS/r42ytl79pC5poS5Y X-Received: by 2002:a0c:bb87:: with SMTP id i7-v6mr10892164qvg.100.1526336768649; Mon, 14 May 2018 15:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336768; cv=none; d=google.com; s=arc-20160816; b=qWaKzBXMqhlWPc+Kb71ZHBLIhK71SFhxR0Rvd33sIatNH1dG0KZwTiP2O9Cz7syjSo jODtGr16FJLMfCGcXtcBWMuOeLQdyY4QnwcuXWhqRnAER/DxBm4xnPxmzOqtmoomMcKk 5LZSDjLM56NIISCPxn2khpKc1afRNaWuqNnJQ9aOevnPKNqryO3wTXvOkpOSg1rc3tCO LB3psk8PjuMTCG+cQpC4UtU8yGhOtPZOOqRbkBt0m9Pbc4IR9CpkdLJsY2udmcXjLHk9 elI81QG5Hz1g0iUjR+NtO5TLz/WvawRMLnXymA1jz+rUhXWIg+zA05bnlrEJIhjgwqcW mRng== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Ec+SMNRzcNPO1wdC4VjFMBQqFtdgGcnELN/AuHLHLvE=; b=ICFJedpEJUEUs9kj7+dJWRLJ3c+io3uZUT09AwrUIyxGYvF6XL8xZW1CbffDfnYB1e 5WogCw+YQ4MmGn6SFajiGcnOqXr8NhTG/T9yIqOZVWfcT0EDHgDFD7QYTMbBBMcDK5Ay UdkugVp/coSqISIV4SJQBpVtnoI3cs3gZxkgZItRAog+RYpJHvNoOc7w1YkvgfkIz98Y jX4llucjh94ChHbfgK7pcBNGx2GniJPN2qLlq4bNUfiPdSc7U7Y+o8WU5NevV3fCQuhw t65DIXzwxB1Vv7s/uv7FPmidiElH5hWK3KDEQCP9YSDmCAnfwu7YyG10pHXDzws+0Uwo DvTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f0batlrH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b186-v6si2399631qke.118.2018.05.14.15.26.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:26:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f0batlrH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILuy-0002fY-1F for patch@linaro.org; Mon, 14 May 2018 18:26:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi1-00084f-NW for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi0-00080V-QH for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:45 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:34389) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi0-0007z8-L3 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:44 -0400 Received: by mail-pg0-x244.google.com with SMTP id k2-v6so484935pgc.1 for ; Mon, 14 May 2018 15:12:44 -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; bh=Ec+SMNRzcNPO1wdC4VjFMBQqFtdgGcnELN/AuHLHLvE=; b=f0batlrH7F8ypHM2bjxZVAr3xMv29jFDATnedebG6Uhv1mIswvaIVZTfcLhwToS09r vPJdGVa+ztOkv4ipGFhndwUxLwiwI8A72GNgnDNnbIdva9zbILfPsQgjIIYcQ2SSxRn+ BapcLOYc8a8FHnj0ZmhGRjhkQbZfl23TpGwnE= 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; bh=Ec+SMNRzcNPO1wdC4VjFMBQqFtdgGcnELN/AuHLHLvE=; b=EFSygQGdHdrnnKDox9twqPuuGz3fkDMfMGZfFQOkfm1iWMtlEDLroe+irGJA8EgRJu PjeqnYg0AKMLDP+/hbPG0mBrhxu+OFdfXRxF6zcxh8huzTIaLDAhuE5H8vntWratCZnB 5sXAtbA2oVQmf/+AUNINExDR0nK89PgEF4oIYkfXgoxWU1Sz6mVGmPzmYcuaZtNbetuQ Zzx1rANextzpoGjX7axSgtr/tANVvjPIFtklgJ6WkuDc4V09B8TAqcsskKKpSzGcUWPO GjQpPvIjkqdgZdCGXwoajsPNqRDMyRqRxlF0cG7/LQMpnslSGBH0Il8Fm39cLBEHySVv PrSQ== X-Gm-Message-State: ALKqPwe8icuZ8J2WJJZeAvGedauStzTzscx4LQan3YNtSGMA/NY5N3qC gvQmA7FswUPLcEY5sB8xQ7b3XWk+ku0= X-Received: by 2002:a65:61c8:: with SMTP id j8-v6mr9804784pgv.370.1526335963510; Mon, 14 May 2018 15:12:43 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:07 -0700 Message-Id: <20180514221219.7091-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v5 16/28] target/m68k: Use floatX_silence_nan when we have already checked for SNaN 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Peter Maydell Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- target/m68k/softfloat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.0 diff --git a/target/m68k/softfloat.c b/target/m68k/softfloat.c index e41b07d042..6ec227e20f 100644 --- a/target/m68k/softfloat.c +++ b/target/m68k/softfloat.c @@ -31,13 +31,14 @@ static floatx80 propagateFloatx80NaNOneArg(floatx80 a, float_status *status) { if (floatx80_is_signaling_nan(a, status)) { float_raise(float_flag_invalid, status); + a = floatx80_silence_nan(a, status); } if (status->default_nan_mode) { return floatx80_default_nan(status); } - return floatx80_maybe_silence_nan(a, status); + return a; } /*---------------------------------------------------------------------------- From patchwork Mon May 14 22:12:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135773 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp195913lji; Mon, 14 May 2018 15:25:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQMMyrZvZVSir6IM+9yZZIg9t/3Pn4SNNUBp49wM6MzBpbf0p6aNvhIjvxytSXTRQDgS3c X-Received: by 2002:a37:dd85:: with SMTP id u5-v6mr9891820qku.376.1526336725320; Mon, 14 May 2018 15:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336725; cv=none; d=google.com; s=arc-20160816; b=pjGw+x9019b3+xVzFgczIjf2M3zOYh6zrZwL26naDKLLai/FE5gtrSPOz7k/IBfywq EZc1w3gA+LpBPtRhTpGrV2/FcKqsOtIgXeROVrYi9JuCTDdE9yJvQv2QO12rFJXRcoMn PFA0huAQbeUR92uWtkyh49pZDa1sDoux8HawhAyViBQ4fPSvnFG7MFABgFXgV3XVimtz l3+d9hTckNLZz4kuiX6+p8k5oL9nhejGvU4Ci3HKyEDLklsKqhAgqSAXgAKoas8B3Hgm EQwaj2FSnmHl2C78CZQee6kU/qHsgzWrQ308nEFpD64ufiftkz55Yb4zjp6fm0IK0cJt 4Bug== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=YG4WDuvg/nU14CtfIK1nI16sf1EHjyzdnNJh8QSrA1M=; b=DygSrQscWDMYzFF29KywsXk0CUgD8h+By8b3P/yEPmrJd962rqvkj3rUbE4mtukbn3 TpIbzsJTSUfC2tzKbUHDQQBDnb0LIMoONhs8VrtF4GdTb8ABU7UN27q99n9jdb+Kn4lr Rg5TV0bv0irCahTdEgol2JRrw9+fyE1gJWjGxG63crirOmfarW8vG0gB5Cfyvwg8uVi/ GXtso5NaBQ6SL0isomA9BpMj+2O54WFWHqneGrJHJWQCDSH/cR3RgoQd2mbi2guhGzNA xHKYu4Pm8INmb9cvURmtDc4a8Ok7JfO3HtCK92fbuTmnruwKFXOKownEOK+R9sHx3nfo G1FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PVWlf9na; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s26-v6si3363882qkl.331.2018.05.14.15.25.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PVWlf9na; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILuG-0001z7-JN for patch@linaro.org; Mon, 14 May 2018 18:25:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi3-00086n-Qk for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi2-00084G-Io for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:47 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:46272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi2-00082b-DF for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:46 -0400 Received: by mail-pf0-x244.google.com with SMTP id p12-v6so6656624pff.13 for ; Mon, 14 May 2018 15:12:46 -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; bh=YG4WDuvg/nU14CtfIK1nI16sf1EHjyzdnNJh8QSrA1M=; b=PVWlf9na+m230jhnYcQw+laf+8jfu7s3eAYWA+ASbwYchpY6hJhYe7V3vjZAlPNy8d rmFp2RMcRCKpW3TMahvSK4/3x6J1MaN+TUuls6lzXZzXUeMMyUGq4JPV+47z5wH4eGOo IUN+fxRv+IESeGxI02yD8dA9yRFaBGT1C9fX8= 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; bh=YG4WDuvg/nU14CtfIK1nI16sf1EHjyzdnNJh8QSrA1M=; b=kUxY/rgNNS+KaujcTzMQvhkMmrn0XSnbLn3CxbqSPmgZsIzqqxibh1pJjdiPrDQ/we L7hf1ugVEelCQFSXuhHlcAc0Xkd+fwOD4uuXDp7JY6TI67V99voPuvz3nh5IjCqwoXye JKJFL8hWxEI5Zyubl+8lgWBUIxBabnHzWR2Nlh6zKcxdT8xoInIditcUj8Z+AY0GLsbb h4x5073AUucoxsS3ErvqK1ckmHgvYbo7QPPuCsTqWUATEnkYqDNqJPFXZTOm3lRwuiTE VZHFDEpNMhB8moBIZw/NZPKWwFervgI/jC9wMjoqGi4sq9XIQDptEBIpHxtpt+7bI5Qy LqIw== X-Gm-Message-State: ALKqPwfEYaO+Khy3+2pEgb0TpGXsmEH35+mA+2g/yfF86xQL30ve0fdj 5B0qYaywHL6yyJ9+7DnBj8FS7UmezCo= X-Received: by 2002:a63:887:: with SMTP id 129-v6mr9671439pgi.17.1526335965161; Mon, 14 May 2018 15:12:45 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:08 -0700 Message-Id: <20180514221219.7091-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v5 17/28] target/mips: Remove floatX_maybe_silence_nan from conversions 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: peter.maydell@linaro.org, Yongbok Kim , alex.bennee@linaro.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is now handled properly by the generic softfloat code. Cc: Aurelien Jarno Cc: Yongbok Kim Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/mips/msa_helper.c | 4 ---- target/mips/op_helper.c | 2 -- 2 files changed, 6 deletions(-) -- 2.17.0 diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 8fb7a369ca..c74e3cdc65 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -1615,7 +1615,6 @@ static inline float16 float16_from_float32(int32_t a, flag ieee, float16 f_val; f_val = float32_to_float16((float32)a, ieee, status); - f_val = float16_maybe_silence_nan(f_val, status); return a < 0 ? (f_val | (1 << 15)) : f_val; } @@ -1625,7 +1624,6 @@ static inline float32 float32_from_float64(int64_t a, float_status *status) float32 f_val; f_val = float64_to_float32((float64)a, status); - f_val = float32_maybe_silence_nan(f_val, status); return a < 0 ? (f_val | (1 << 31)) : f_val; } @@ -1636,7 +1634,6 @@ static inline float32 float32_from_float16(int16_t a, flag ieee, float32 f_val; f_val = float16_to_float32((float16)a, ieee, status); - f_val = float32_maybe_silence_nan(f_val, status); return a < 0 ? (f_val | (1 << 31)) : f_val; } @@ -1646,7 +1643,6 @@ static inline float64 float64_from_float32(int32_t a, float_status *status) float64 f_val; f_val = float32_to_float64((float64)a, status); - f_val = float64_maybe_silence_nan(f_val, status); return a < 0 ? (f_val | (1ULL << 63)) : f_val; } diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 798cdad030..9025f42366 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -2700,7 +2700,6 @@ uint64_t helper_float_cvtd_s(CPUMIPSState *env, uint32_t fst0) uint64_t fdt2; fdt2 = float32_to_float64(fst0, &env->active_fpu.fp_status); - fdt2 = float64_maybe_silence_nan(fdt2, &env->active_fpu.fp_status); update_fcr31(env, GETPC()); return fdt2; } @@ -2790,7 +2789,6 @@ uint32_t helper_float_cvts_d(CPUMIPSState *env, uint64_t fdt0) uint32_t fst2; fst2 = float64_to_float32(fdt0, &env->active_fpu.fp_status); - fst2 = float32_maybe_silence_nan(fst2, &env->active_fpu.fp_status); update_fcr31(env, GETPC()); return fst2; } From patchwork Mon May 14 22:12:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135769 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp193507lji; Mon, 14 May 2018 15:22:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpoer85kiVHB4i2f+1cPoAlM6tIMzYupmABqCGzJRpzdecLUBfpTQV96qP/ks34y3VjVF1k X-Received: by 2002:aed:3224:: with SMTP id y33-v6mr11245971qtd.179.1526336532840; Mon, 14 May 2018 15:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336532; cv=none; d=google.com; s=arc-20160816; b=zocMDC82RpFEcVjXVINo7Fi1rkaLmk4ZnQN9nn+ELPJZs+1kL76NEONd1aF9gZcQBl A6ciPSrpaesS0RMig6vaQwHHYryIeDcWL2OmFJTOCGepcc+QGuia62Id8uk8FdwNnh6F Xbhj29IjYj0cFiu67Ln8nM2GTnm0zFv9hg5UE1sISXNodkG+Qnu7V3s8+Jq4aZ6Y3LOc Z1Qk6XXujs3wSjO+7MNZEGELGixkCCpGVlQXDYYAUl2DgGozLGoNKJF1UqtEBVLCu9IS KP3uJfjjqngA4EnSyWYKd9P4MZevdB6vgI2mdRvWeAo8jfHnTl7lNkAoK6gTT74YbNlI 1pKA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=lFbjHgIjVdntVwEG8TX8Zn/QYQH/a160DBSlPiGyBN4=; b=Zmo434cetyDc1kFobn/ZADTTD9KiwAmFBiVz91HbhUpRVYOgxDJi18GZUD5rCNj2JL hAqvzPA/UbyoWloz8VL2H8uYA2LEpqoN02LAp+3Ea6cIIs52Bi0pr6IT+I0LgNxF1Ikk Fv7XUZBL2CoTeoRJUO1pLuLEn/f4ROi8trn0P/JZVZORg85q4WJVyzyO1zZusD8lzsyR rsSgunVSjsMvkHpABGvPl+m9pnQMgsYfG9CWG45fLpZRHiaD2OSfWrfjgKUdh2sXyvfv zS4+ZNRyi4fqZl9M1gHkNp7gpbLC9FLk7n2mhyGLrnjBr/IVb1q6Lvmq6SkHhz/stUvs Lv4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O7YckEzO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i67-v6si5604203qkc.51.2018.05.14.15.22.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=O7YckEzO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILrA-0007RZ-6w for patch@linaro.org; Mon, 14 May 2018 18:22:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi5-00088c-BR for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi4-00087W-3c for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:49 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi3-000861-TF for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:48 -0400 Received: by mail-pf0-x244.google.com with SMTP id c10-v6so6658570pfi.12 for ; Mon, 14 May 2018 15:12:47 -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; bh=lFbjHgIjVdntVwEG8TX8Zn/QYQH/a160DBSlPiGyBN4=; b=O7YckEzOS93CP+o7AXg6CyjlcHA9jJ2BSUh3uz5RjL5LZxTWHhekG5PF0Zmupi4yHg yHH9oa0dHDuPew4iUP+MWbvu3QWFva1OBjHGFnB4Hlkv1CwNH6bdmsuelJbY4ShiFvDd L9GrWtcPRr86OWHEVLVsV5dfiwmPe1BoZuB0Y= 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; bh=lFbjHgIjVdntVwEG8TX8Zn/QYQH/a160DBSlPiGyBN4=; b=CwMOji/qc1zx8TyZvjzSqv52Oy+KxT84XqtB9RCCraF3vLFBN8Y1n1UcZK7ZDDhaJE WenTSjMMetmoVldGyf/oFuJgNekzRyVdkgHSY64Tbsc97EouDdC8TXKOQ5jjgGp86Bjg T2KC+by1WsEyUcGQli4u1CwDUnsVbbt9CYcqP2J2RvJJPSw9zxVUgFasI/u2xqXJAz2P KNd9cKQvNviEdp87v8EKy48KeIWe3XG4Jh/S6Nlq1XEJRiriWRVWevh7mO2PCWx+/Zu5 zEsb6XG0oh1edEU2w8a0exBIZI/yJnJIXKPmQ1RU8EBZaDliTMBuvsK1mzYGX+ki5dde zPAg== X-Gm-Message-State: ALKqPwf61TS+kFZEJgOz2ZWMoDzYJ1WMUyJa/ZGW7h5sQHX6v5RsorDy amZCj4ZTP/ohaCy/7LnQbUyHAgkomvY= X-Received: by 2002:a65:5008:: with SMTP id f8-v6mr6019205pgo.349.1526335966786; Mon, 14 May 2018 15:12:46 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:09 -0700 Message-Id: <20180514221219.7091-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v5 18/28] target/riscv: Remove floatX_maybe_silence_nan from conversions 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: peter.maydell@linaro.org, Palmer Dabbelt , alex.bennee@linaro.org, Sagar Karandikar , Bastian Koppelmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is now handled properly by the generic softfloat code. Cc: Palmer Dabbelt Cc: Sagar Karandikar Cc: Bastian Koppelmann Reviewed-by: Michael Clark Signed-off-by: Richard Henderson --- target/riscv/fpu_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.17.0 diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index abbadead5c..fdb87d8d82 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -279,14 +279,12 @@ uint64_t helper_fmax_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t rs1) { - rs1 = float64_to_float32(rs1, &env->fp_status); - return float32_maybe_silence_nan(rs1, &env->fp_status); + return float64_to_float32(rs1, &env->fp_status); } uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1) { - rs1 = float32_to_float64(rs1, &env->fp_status); - return float64_maybe_silence_nan(rs1, &env->fp_status); + return float32_to_float64(rs1, &env->fp_status); } uint64_t helper_fsqrt_d(CPURISCVState *env, uint64_t frs1) From patchwork Mon May 14 22:12:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135778 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp198450lji; Mon, 14 May 2018 15:28:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwhZxpzDtyY+opbLB/LbHeNHHCQiezL5kTfFqYoyDT8ojUjr/A+D4U5Msj1RkzAj9dBobh X-Received: by 2002:a37:6a84:: with SMTP id f126-v6mr10264331qkc.45.1526336929863; Mon, 14 May 2018 15:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336929; cv=none; d=google.com; s=arc-20160816; b=vV3BFjTY/XiHBW4MbFw1jBtGEufF5iMVPDWj8s9EPUHe6SLge3ghuKW6wPArOpVfXC xeHrZXRCdkgTV8mZuUApaw0cifjBH5nwqLIoJMIlc+Jag7IGEOT6BN08JJ0UBag9fqOd vSNzZOArXXahYJkguZilyuUNB6z3ctGtcwFZxoAkwWvy2xBApFfMr4xrk4b+QYQuv/ZY apXieL61qcXleAAoHjcdZiRSikYclaU4klvkV7uYeRL95Y+Jt5eKN1I8qCUSv/D7GKO/ 6otSj1zBx665avl9PSmhTE4SHxZakE69lqExJ4rr4E/ItK1q4Ft8S8pP7/yCCJ8JgpV9 hT5w== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=N/MQDXmC5P0rKEPWLGL6olcs6gD/4PAiety6G0UTpec=; b=w/QYsWRQMUE2+YhHaHy2FPEEh5AKU8JnoN25gdZSy/pJcKTStRoIu4qAYLXKSFziqn RNhV8YrY3/wwSJ5j6tW8nrIaQlRo0KKo4bTyq6pS5J2S0WTjl8vMLHlA78IXeU+huDUQ v9twSkT26Z0KGR/yWm68g3a+6onmhw8nI+CqNZm0V+6NNkZSUleeIqiS4PI7QgHrd77s T0W4ys4w003PgjeIVV+lU/jGB7WWDD4G4/Hr/Le+8EoxY9Z9prUXewbJ+SEhaD4f/K2S iwww7xrut4EcTBQ5gSgVCKWQ8yqGiibWTALxsknv6i/bvQ+vaU2YSVcoM0mxQzLAd0eM /44A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EwcG9ejW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n8-v6si3356244qtc.341.2018.05.14.15.28.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EwcG9ejW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILxZ-00050L-3g for patch@linaro.org; Mon, 14 May 2018 18:28:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi6-00089p-FE for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi5-0008A0-Cs for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:50 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:36605) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi5-00088s-6W for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:49 -0400 Received: by mail-pg0-x244.google.com with SMTP id z70-v6so6065153pgz.3 for ; Mon, 14 May 2018 15:12:49 -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; bh=N/MQDXmC5P0rKEPWLGL6olcs6gD/4PAiety6G0UTpec=; b=EwcG9ejWdyJWfKlpQmklMu8vZBOnL9752ihIsFo6JYbSm5oRChU6KIJeoQc//rlrtn dX8Ucb+Ccalu0SeF9af1Be3+fXBYGWkr4M1C0aT1qurXkGbVSJpDrsKIbA0DRs4557gV ZVQCfEJWYJGumhyzpjYcEBPOfjmskekaimsEM= 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; bh=N/MQDXmC5P0rKEPWLGL6olcs6gD/4PAiety6G0UTpec=; b=fQrtA+3vBxGKEjeYwRR3kZflLVZyd4QC55LtkQRzRB3ByMCsQygnPD/gPNdYMw7NeY q/vtlTwxZY67lgI1py/mSrhMsgXCeRp4Y8sP6IykgejmOyYOMQ7rzE2P6mRyzZBT2lKP s95hBVZWQh/bqR5EDZwwcF3NXYCW+DHC4qYUHWJO57UF0/jgK+bYFVgcYvD6fz3p9OVd 1wumyT/n70eJ0Tl6Elz+07d0HoAFGKACX5Nt6Tri1BhxlwW4lx7tPYSndeNf0mRUrNOA fbDWbGhNnfSdurfNuTESn+5PgyGmaLxK5Q/4XO0gx2DBEtnu03s/w05LemXI+swtxpuv aISw== X-Gm-Message-State: ALKqPwf5VlcXu14fi7iEj63vFPHLMhGXCib2I5JEgt8dW82vdqiVvVYW F0n5v8a/AeR8xRNoieFZ1ZLSvLeqCSU= X-Received: by 2002:a63:6d42:: with SMTP id i63-v6mr9934803pgc.161.1526335967979; Mon, 14 May 2018 15:12:47 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:10 -0700 Message-Id: <20180514221219.7091-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v5 19/28] target/s390x: Remove floatX_maybe_silence_nan from conversions 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: peter.maydell@linaro.org, alex.bennee@linaro.org, Alexander Graf Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is now handled properly by the generic softfloat code. Cc: Alexander Graf Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/fpu_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.17.0 diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c index 43f8bf1c94..5c5b451b3b 100644 --- a/target/s390x/fpu_helper.c +++ b/target/s390x/fpu_helper.c @@ -269,7 +269,7 @@ uint64_t HELPER(ldeb)(CPUS390XState *env, uint64_t f2) { float64 ret = float32_to_float64(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return float64_maybe_silence_nan(ret, &env->fpu_status); + return ret; } /* convert 128-bit float to 64-bit float */ @@ -277,7 +277,7 @@ uint64_t HELPER(ldxb)(CPUS390XState *env, uint64_t ah, uint64_t al) { float64 ret = float128_to_float64(make_float128(ah, al), &env->fpu_status); handle_exceptions(env, GETPC()); - return float64_maybe_silence_nan(ret, &env->fpu_status); + return ret; } /* convert 64-bit float to 128-bit float */ @@ -285,7 +285,7 @@ uint64_t HELPER(lxdb)(CPUS390XState *env, uint64_t f2) { float128 ret = float64_to_float128(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return RET128(float128_maybe_silence_nan(ret, &env->fpu_status)); + return RET128(ret); } /* convert 32-bit float to 128-bit float */ @@ -293,7 +293,7 @@ uint64_t HELPER(lxeb)(CPUS390XState *env, uint64_t f2) { float128 ret = float32_to_float128(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return RET128(float128_maybe_silence_nan(ret, &env->fpu_status)); + return RET128(ret); } /* convert 64-bit float to 32-bit float */ @@ -301,7 +301,7 @@ uint64_t HELPER(ledb)(CPUS390XState *env, uint64_t f2) { float32 ret = float64_to_float32(f2, &env->fpu_status); handle_exceptions(env, GETPC()); - return float32_maybe_silence_nan(ret, &env->fpu_status); + return ret; } /* convert 128-bit float to 32-bit float */ @@ -309,7 +309,7 @@ uint64_t HELPER(lexb)(CPUS390XState *env, uint64_t ah, uint64_t al) { float32 ret = float128_to_float32(make_float128(ah, al), &env->fpu_status); handle_exceptions(env, GETPC()); - return float32_maybe_silence_nan(ret, &env->fpu_status); + return ret; } /* 32-bit FP compare */ From patchwork Mon May 14 22:12:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135783 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp201517lji; Mon, 14 May 2018 15:32:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZosVXtMrhasBHaDPEP91Z4nT4QkqYjcvGPNCnccxUqbJjiCVKvGXXfArE/XNxToz9i9SeeW X-Received: by 2002:a37:5ac5:: with SMTP id o188-v6mr9879444qkb.295.1526337149490; Mon, 14 May 2018 15:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337149; cv=none; d=google.com; s=arc-20160816; b=yn/dLZ+5HTiSqfsKhSmSGIR/jJ1rzg8KFtF4SWhxcGatOjVyfhG7AWb5D/xnhyze3F 34f5XUBCeEAWHe+1sNm2TlpSSCXqT/edC5ujtpzl8LBTo6STjAjsQ7cRwLIV/mrqo8/n s3+/BRaWsATjVEf7VewYRpHeWbSWc5eyqabZMo+dA8xs+Q1BRJZQSKCqO70Qhje2M/6J Q68XsyBjCjbUEvEWEG2A1+S4Ofduc3geHPwqv25igQIAr4uiCJ9E5jgeblz2VOO5NJgU kRT9EPwvB+6CN//rg/RGEadkmSXeSvqH1GCBYw3oqmsKl6qxC3hWS0SUU2tnjCWtkMV2 8jQQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=9z4EoWnekLIhRQCMjbOL53uOBSiOY08v6fsPvwdooRE=; b=ue6RFOGiNOBFf+IrEOcTxtJdFWUQO2o/umNe43I0yMxbFRCiBMwAzknab3ABYlcMzW dQ5jIlFuXULS40HCwHwKM8pazEagTLDeWNUBy8OAGN9EGennhLQisT9MZ1PNSVFCCTGM T4zKe1BwxOFhfj82CC7gDnAvd+RSb6Y/HwQsoqsZ37DLVHTJShVPyWT6TAmBk6ftrCRr swvvXQfZxSYkt42PBpvm0s5TVKAja+ryoW3zhMKG5wPjW3QV/YGkQKage5jylao2hJ0D uyE5d7Us3sYUsdDh1kdlOtur4bBTf+R6QQFI3rYJWSpAgJJHgqxFC1O60DmtMjnblQZh afpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fzmOaYfY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m14-v6si9582758qvo.99.2018.05.14.15.32.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:32:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fzmOaYfY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:50293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIM16-0008KW-UF for patch@linaro.org; Mon, 14 May 2018 18:32:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILi7-0008BF-Qe for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi6-0008D8-KQ for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:51 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:43161) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi6-0008BM-Eh for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:50 -0400 Received: by mail-pg0-x241.google.com with SMTP id p8-v6so2538834pgq.10 for ; Mon, 14 May 2018 15:12:50 -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; bh=9z4EoWnekLIhRQCMjbOL53uOBSiOY08v6fsPvwdooRE=; b=fzmOaYfYonw1peGW5pSYesgsFxtBsoZdXwSn822MpCE/0s8zd/8iCa6VTrLver0M1a z0WceH7ScOg+XeBRe3mgUhYi3oE8r4ElsK+Vz7wozfB9ZHCxMmCgmt8uxP0trUL7UZ80 tATrtFY3tNohwp+N4wHkkY/Xaimw8jEr/YUnI= 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; bh=9z4EoWnekLIhRQCMjbOL53uOBSiOY08v6fsPvwdooRE=; b=rfnqBZXNdghenVWslyRO6dL1BDsUE7XYk2NijG3JtFQTMNdca4tman3zNq39e8mIr5 KMzTyLIX12w9yHy2P8y/ItlVvBJeOeUXEyrI4s+6C1Aup+w13t78Scmsl8d5QlD76Mav vp4DN9DJ6Tm97M5tvLs7DLcR7b//mvdP1SypTVztB/XVYAkPCGxkncx7Ieo7yiXu4gSi R0KHnU6038KPC4Cih8X0py4cl4p82VWkzRDlUhllciuQ7L1B5KlkZM6KfQbk3fmMy6HT 1gFFKslaxS28b4/CJ+zF6maJWVlFlZ4H7IDl8rdpMFhl3UfAMHTSYRSiFT/+kIrxTSvY 9ucA== X-Gm-Message-State: ALKqPweTM+WRRZO9vPvxjFUP9MACY0xH6xvXBCVKGLZLPhbkGL7eHXT+ kuNl5RCJpb6i+gNYbEsr/kAACm/flJk= X-Received: by 2002:a63:a312:: with SMTP id s18-v6mr9680477pge.187.1526335969247; Mon, 14 May 2018 15:12:49 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:11 -0700 Message-Id: <20180514221219.7091-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v5 20/28] fpu/softfloat: Use float*_silence_nan in propagateFloat*NaN 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have already checked the arguments for SNaN; we don't need to do it again. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 44 +++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 995a0132c6..4fa068a5dc 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -498,7 +498,7 @@ static float32 commonNaNToFloat32(commonNaNT a, float_status *status) | The routine is passed various bits of information about the | two NaNs and should return 0 to select NaN a and 1 for NaN b. | Note that signalling NaNs are always squashed to quiet NaNs -| by the caller, by calling floatXX_maybe_silence_nan() before +| by the caller, by calling floatXX_silence_nan() before | returning them. | | aIsLargerSignificand is only valid if both a and b are NaNs @@ -536,7 +536,7 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, { /* According to MIPS specifications, if one of the two operands is * a sNaN, a new qNaN has to be generated. This is done in - * floatXX_maybe_silence_nan(). For qNaN inputs the specifications + * floatXX_silence_nan(). For qNaN inputs the specifications * says: "When possible, this QNaN result is one of the operand QNaN * values." In practice it seems that most implementations choose * the first operand if both operands are qNaN. In short this gives @@ -788,9 +788,15 @@ static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status) if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return float32_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return float32_silence_nan(b, status); + } + return b; } else { - return float32_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return float32_silence_nan(a, status); + } + return a; } } @@ -950,9 +956,15 @@ static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status) if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return float64_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return float64_silence_nan(b, status); + } + return b; } else { - return float64_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return float64_silence_nan(a, status); + } + return a; } } @@ -1121,9 +1133,15 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return floatx80_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return floatx80_silence_nan(b, status); + } + return b; } else { - return floatx80_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return floatx80_silence_nan(a, status); + } + return a; } } @@ -1270,8 +1288,14 @@ static float128 propagateFloat128NaN(float128 a, float128 b, if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, aIsLargerSignificand)) { - return float128_maybe_silence_nan(b, status); + if (bIsSignalingNaN) { + return float128_silence_nan(b, status); + } + return b; } else { - return float128_maybe_silence_nan(a, status); + if (aIsSignalingNaN) { + return float128_silence_nan(a, status); + } + return a; } } From patchwork Mon May 14 22:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135776 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp197613lji; Mon, 14 May 2018 15:27:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrBxroapWcoAnyWUMAELTtwDUbPISq8/xKshpvc+LXV2r8am3ab8lGkvZp9rbt9lwQkuunP X-Received: by 2002:a0c:92af:: with SMTP id b44-v6mr11083076qvb.169.1526336870725; Mon, 14 May 2018 15:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336870; cv=none; d=google.com; s=arc-20160816; b=DKR+YyjrVDV/RfKkKAym7gLTxbhKJ8zW6Cg+OT2/cLCbT30/LgwD8B8WvdTZKWiUng x0n/lJv6Xh2cDfFsUQdvMRPkwW8LKcbdN1/+9V3WSn+STnoka/hwPVaGqk8fnFlMTshH jN+W3Z2pPpUok17FKVz4I/XzDj5OYRxYdODAsy9i3cSmq9sZ2/fQd+vlkk1or0IRoRKH Kz6YMj/3imeCia+BAUCYZn2gS478CCAAAXXAgOBGIIsXMp1cl1Aay25A7GIEKR9UwkWf izJxH7crKBmRwr8JlJS8Y3jwSTCCqq6dEvQrpIB2PPF7MnzUA9mez7Zh7dDE9WSSPKm7 gkCA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=B0Uh1jzxOOh72JWGxxTuSXYGeNK1unJxmboGYXUn8YQ=; b=g5sihqyybfXHvlrv/EGslIXU99gyd/+CUh0QclUEqV4wZPx1wy6hoPJwTHa/8/FvRN 8Zo+T6tyRSwuPyj93MOgOsG3GyPE2rlwGI2iymZfm9iIrDi6KElhyFDleucQpAEIvAw7 MH251fy2OAz6c6KMyf5lkgThzcPge/VTxP4SyMILLIRlmyKKYZr3yYl/H3oJmOwbMbQx N5iyz8bJOHK2HOUUhJvCAfdMk51iaRFvfXXLnD1cc1jI+IzLB5qomnyCP7OPssMb7zuK S+wTmDIZtZrdnKgfJfQ82wa9OqOk9JA/UR3mCWYchpf/7XZVFOHu50QdDfbg6Ctu8csD H9AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kwLuUYqe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y67-v6si4049553qky.323.2018.05.14.15.27.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kwLuUYqe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILwc-0003Iq-4L for patch@linaro.org; Mon, 14 May 2018 18:27:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiB-0008EQ-92 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi8-0008I9-A2 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:55 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:36603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi8-0008Fm-1U for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:52 -0400 Received: by mail-pg0-x241.google.com with SMTP id z70-v6so6065203pgz.3 for ; Mon, 14 May 2018 15:12:52 -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; bh=B0Uh1jzxOOh72JWGxxTuSXYGeNK1unJxmboGYXUn8YQ=; b=kwLuUYqelCeApgC2/82EFw58JgRfdbcIjaK/LV/qGFf+PZ2hrnrnS4UCPKPUePqt4J vaIZAs3R6Sx4Pwv06v5+pR8VZ/DGhpQWpF003+CKO5TQhQ2YqoIWW+or1tZXerfA81Nn 4vBlR1cx8F8yzZs58sf8WDhMzmLzUUGRV4zGc= 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; bh=B0Uh1jzxOOh72JWGxxTuSXYGeNK1unJxmboGYXUn8YQ=; b=TLjrZlyjb1f0D7AUWfj6pLgibLbIoV3eOK47vpT6kApRxURxLmTvj5v9qzjwHxd5mm nXZLLQmXno8MxAT7zWEkZYht7Resc889T3gglR10fsZKZZPfln1aVOJFu8xYFtherkU3 q4b0c80lgwCDhk7z8RGmZUjUBm/MtA7t8POaKgbjFOtOPI8MOG7/K+FYNsh2JE5u/lJM 7wSM+bLNtTGd0+SDGybIW9rkS6EQZuE8TbgjkfVWYpYvl2pb7+K/GeZO6hYuYo1W2xZS XSNYdi5EfYOLE0O/e3Z28bqcIjtbt1PwM0LYup96n+IjeMuaNlN6vvhIh/2f7x+Xrwf/ HxYA== X-Gm-Message-State: ALKqPwcfIRFt98ymgN2VV7V6MELuUdL86H0SWLA3xCldFDdTfy1F5Vtj lSY+1m/2YTZIbAq4bk+CEbmKe3EuVxk= X-Received: by 2002:a65:414c:: with SMTP id x12-v6mr9951469pgp.70.1526335970843; Mon, 14 May 2018 15:12:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:12 -0700 Message-Id: <20180514221219.7091-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [PATCH v5 21/28] fpu/softfloat: Remove floatX_maybe_silence_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These functions are now unused. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 63 -------------------------------------- include/fpu/softfloat.h | 5 --- 2 files changed, 68 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 4fa068a5dc..d7033b7757 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -364,19 +364,6 @@ float16 float16_silence_nan(float16 a, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN if the half-precision floating point value `a' is a -| signaling NaN; otherwise returns `a'. -*----------------------------------------------------------------------------*/ - -float16 float16_maybe_silence_nan(float16 a, float_status *status) -{ - if (float16_is_signaling_nan(a, status)) { - return float16_silence_nan(a, status); - } - return a; -} - /*---------------------------------------------------------------------------- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -438,18 +425,6 @@ float32 float32_silence_nan(float32 a, float_status *status) } #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN if the single-precision floating point value `a' is a -| signaling NaN; otherwise returns `a'. -*----------------------------------------------------------------------------*/ - -float32 float32_maybe_silence_nan(float32 a, float_status *status) -{ - if (float32_is_signaling_nan(a, status)) { - return float32_silence_nan(a, status); - } - return a; -} /*---------------------------------------------------------------------------- | Returns the result of converting the single-precision floating-point NaN @@ -864,18 +839,6 @@ float64 float64_silence_nan(float64 a, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN if the double-precision floating point value `a' is a -| signaling NaN; otherwise returns `a'. -*----------------------------------------------------------------------------*/ - -float64 float64_maybe_silence_nan(float64 a, float_status *status) -{ - if (float64_is_signaling_nan(a, status)) { - return float64_silence_nan(a, status); - } - return a; -} /*---------------------------------------------------------------------------- | Returns the result of converting the double-precision floating-point NaN @@ -1037,19 +1000,6 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN if the extended double-precision floating point value -| `a' is a signaling NaN; otherwise returns `a'. -*----------------------------------------------------------------------------*/ - -floatx80 floatx80_maybe_silence_nan(floatx80 a, float_status *status) -{ - if (floatx80_is_signaling_nan(a, status)) { - return floatx80_silence_nan(a, status); - } - return a; -} - /*---------------------------------------------------------------------------- | Returns the result of converting the extended double-precision floating- | point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the @@ -1204,19 +1154,6 @@ float128 float128_silence_nan(float128 a, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN if the quadruple-precision floating point value `a' is -| a signaling NaN; otherwise returns `a'. -*----------------------------------------------------------------------------*/ - -float128 float128_maybe_silence_nan(float128 a, float_status *status) -{ - if (float128_is_signaling_nan(a, status)) { - return float128_silence_nan(a, status); - } - return a; -} - /*---------------------------------------------------------------------------- | Returns the result of converting the quadruple-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index a6860e858d..69f4dbc4db 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -258,7 +258,6 @@ int float16_compare_quiet(float16, float16, float_status *status); int float16_is_quiet_nan(float16, float_status *status); int float16_is_signaling_nan(float16, float_status *status); float16 float16_silence_nan(float16, float_status *status); -float16 float16_maybe_silence_nan(float16, float_status *status); static inline int float16_is_any_nan(float16 a) { @@ -370,7 +369,6 @@ float32 float32_maxnummag(float32, float32, float_status *status); int float32_is_quiet_nan(float32, float_status *status); int float32_is_signaling_nan(float32, float_status *status); float32 float32_silence_nan(float32, float_status *status); -float32 float32_maybe_silence_nan(float32, float_status *status); float32 float32_scalbn(float32, int, float_status *status); static inline float32 float32_abs(float32 a) @@ -500,7 +498,6 @@ float64 float64_maxnummag(float64, float64, float_status *status); int float64_is_quiet_nan(float64 a, float_status *status); int float64_is_signaling_nan(float64, float_status *status); float64 float64_silence_nan(float64, float_status *status); -float64 float64_maybe_silence_nan(float64, float_status *status); float64 float64_scalbn(float64, int, float_status *status); static inline float64 float64_abs(float64 a) @@ -604,7 +601,6 @@ int floatx80_compare_quiet(floatx80, floatx80, float_status *status); int floatx80_is_quiet_nan(floatx80, float_status *status); int floatx80_is_signaling_nan(floatx80, float_status *status); floatx80 floatx80_silence_nan(floatx80, float_status *status); -floatx80 floatx80_maybe_silence_nan(floatx80, float_status *status); floatx80 floatx80_scalbn(floatx80, int, float_status *status); static inline floatx80 floatx80_abs(floatx80 a) @@ -816,7 +812,6 @@ int float128_compare_quiet(float128, float128, float_status *status); int float128_is_quiet_nan(float128, float_status *status); int float128_is_signaling_nan(float128, float_status *status); float128 float128_silence_nan(float128, float_status *status); -float128 float128_maybe_silence_nan(float128, float_status *status); float128 float128_scalbn(float128, int, float_status *status); static inline float128 float128_abs(float128 a) From patchwork Mon May 14 22:12:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135785 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp204061lji; Mon, 14 May 2018 15:35:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruptLSN0n+F1KRJXJlaxlomddz3xRS+jzfFpe7DCHSjmMEcHP/tTvLNreN3CX/XIY1HFCg X-Received: by 2002:a0c:bc90:: with SMTP id l16-v6mr10540312qvg.178.1526337345305; Mon, 14 May 2018 15:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337345; cv=none; d=google.com; s=arc-20160816; b=z5M+bIt1ESib3i9AsfXzmO0ikAeI1hl/rrq6ilOMXYsUOv1TC8GEr9OUvHTUeFiHS2 qXZ3CjOrXGTQdFzpPnbUOod6qGeOdoREVs6Rz3XJBnBdu0C3e7d+MEJFKytiOoJsnf7T N3OU9atnQeD+EHEoCMl/jcm/BW6Zo1T61rO1ItcMW5dZftAzh4jY1WtSOosLr7y++tHF u6FhgnBt8V4ueBnH6MaM4yisled9KIenfSWftpP64FcsOn6+KW1MUF9tFeVD7OTmTViN o5RPqxvyiQWtfNN0JJ7R0Zy6ApMekqterAc19UHhoAhxx4wGyv+y4o6G3E+2YdmxAfVl 0Nug== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=t7/aog2Cky4Dgm8gVOdXWM/mBfrK88ILxMNiYMKbySQ=; b=cAMjK0u/+I/w4KiHWjJ2qK5waUi5T9mL0c0eg4+M8QLcgXu6v/W5JdMnQLPKFc4Efl ufCrksJh34OemjUOvJgaAtEjREHzbcPIwmFncGcFYGOlY9f4OXINuLlHwZwTRr+flBFF NOkQaxgzRWdXmbspnixdBAR3Lg43rkLA4GIQ5KgVPSXXxzPhbLQeCHQqRTJFCalGAIQa Mi9S4y9c3+/Orvbh3pH4t7hMc3l3M8mqf3hnMtdQiM6feZ5JAtMz18sDdfZctZ5U0fjP /ukY/ymkFkZuAAYZH0XFnN9DDH5KoUE4f+BAC49zYDGZF1u4uJhExn9mzWz+2rIipJLN dXJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YvcqHjI/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z13-v6si2211915qvl.165.2018.05.14.15.35.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:35:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YvcqHjI/; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:50485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIM4G-0002lh-My for patch@linaro.org; Mon, 14 May 2018 18:35:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiB-0008Ev-OK for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILi9-0008LB-L2 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:55 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:45884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILi9-0008JX-BT for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:53 -0400 Received: by mail-pl0-x243.google.com with SMTP id bi12-v6so8144440plb.12 for ; Mon, 14 May 2018 15:12:53 -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; bh=t7/aog2Cky4Dgm8gVOdXWM/mBfrK88ILxMNiYMKbySQ=; b=YvcqHjI/SBE4oANPVDbI9Vb2vhSD/WKIbA6ZPSHOzq8QuFgkmjEW1QHeSpewb5/pIs wAwhF625nX2vSd+mAtPFR4XC7R5y0wrkrAeyf14NepTL4GxagnJpoH/WjaBcJbhVfjEX Vh07VuXtL9fuKplsN97rB+CUJQ4eS9pKpv56s= 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; bh=t7/aog2Cky4Dgm8gVOdXWM/mBfrK88ILxMNiYMKbySQ=; b=I/JIej8UEo6F9IfugsF/qHWsEVLjG/QCG+mib3cZiqBwHGwxgF0kwOhiPxb+Uo5R1U bZITKSBH9B6dCFsNRHfpHFnS1rRfB5p0fIggOSewg0YA9IRLy7CjowkFtfEZXUnU9Uvv ZVJGUApOdaqnjatLO+VcIRQonuBwjwS8CUwsri+gC3PSUo9IWm5AP/a5S4Yd7qoU0SZA Jj/4QzYK4Fq9eLWNQE7yAZvWyyJlJ5BWDvac9uhLaWdNhj2QGSXyPsQIA79iMHvgH11o jU4WghPgxlcBJKzxHSnalcMexJ1oxyKzI9mcdTQP+B+TuJJE3t9fzPqqtyYYsupgVnCJ QSoA== X-Gm-Message-State: ALKqPwdTg38vomD/rPZrinDetzpCxDAz+6HZXvB5FWfeW5dbv3ZZCTuC NXwEW61KtKCQCP9vy7XWTZppb9m2duY= X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr11737484plo.325.1526335972146; Mon, 14 May 2018 15:12:52 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:13 -0700 Message-Id: <20180514221219.7091-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v5 22/28] fpu/softfloat: Specialize on snan_bit_is_one 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: peter.maydell@linaro.org, alex.bennee@linaro.org, Alexander Graf , Guan Xuetao , Yongbok Kim , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Only MIPS requires snan_bit_is_one to be variable. While we are specializing softfloat behaviour, allow other targets to eliminate this runtime check. Cc: Aurelien Jarno Cc: Yongbok Kim Cc: David Gibson Cc: Alexander Graf Cc: Guan Xuetao Signed-off-by: Richard Henderson --- v5 - do not remove the set_snan_bit_is_one function - tidy the language in the snan_bit_is_one block comment --- fpu/softfloat-specialize.h | 68 ++++++++++++++++++++++------------- include/fpu/softfloat-types.h | 1 + target/hppa/cpu.c | 1 - target/ppc/fpu_helper.c | 1 - target/sh4/cpu.c | 1 - target/unicore32/cpu.c | 2 -- 6 files changed, 44 insertions(+), 30 deletions(-) -- 2.17.0 Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index d7033b7757..d1e06da75b 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -79,13 +79,31 @@ this code that are retained. * version 2 or later. See the COPYING file in the top-level directory. */ -#if defined(TARGET_XTENSA) /* Define for architectures which deviate from IEEE in not supporting * signaling NaNs (so all NaNs are treated as quiet). */ +#if defined(TARGET_XTENSA) #define NO_SIGNALING_NANS 1 #endif +/* Define how the architecture discriminates signaling NaNs. + * This done with the most significant bit of the fraction. + * In IEEE 754-1985 this was implementation defined, but in IEEE 754-2008 + * the msb must be zero. MIPS is (so far) unique in supporting both the + * 2008 revision and backward compatibility with their original choice. + * Thus for MIPS we must make the choice at runtime. + */ +static inline flag snan_bit_is_one(float_status *status) +{ +#if defined(TARGET_MIPS) + return status->snan_bit_is_one; +#elif defined(TARGET_HPPA) || defined(TARGET_UNICORE32) || defined(TARGET_SH4) + return 1; +#else + return 0; +#endif +} + /*---------------------------------------------------------------------------- | For the deconstructed floating-point with fraction FRAC, return true | if the fraction represents a signalling NaN; otherwise false. @@ -97,7 +115,7 @@ static bool parts_is_snan_frac(uint64_t frac, float_status *status) return false; #else flag msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1); - return msb == status->snan_bit_is_one; + return msb == snan_bit_is_one(status); #endif } @@ -118,7 +136,7 @@ static FloatParts parts_default_nan(float_status *status) #elif defined(TARGET_HPPA) frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { frac = (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; } else { #if defined(TARGET_MIPS) @@ -151,7 +169,7 @@ static FloatParts parts_silence_nan(FloatParts a, float_status *status) a.frac &= ~(1ULL << (DECOMPOSED_BINARY_POINT - 1)); a.frac |= 1ULL << (DECOMPOSED_BINARY_POINT - 2); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return parts_default_nan(status); } else { a.frac |= 1ULL << (DECOMPOSED_BINARY_POINT - 1); @@ -169,7 +187,7 @@ float16 float16_default_nan(float_status *status) #if defined(TARGET_ARM) return const_float16(0x7E00); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return const_float16(0x7DFF); } else { #if defined(TARGET_MIPS) @@ -195,7 +213,7 @@ float32 float32_default_nan(float_status *status) #elif defined(TARGET_HPPA) return const_float32(0x7FA00000); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return const_float32(0x7FBFFFFF); } else { #if defined(TARGET_MIPS) @@ -220,7 +238,7 @@ float64 float64_default_nan(float_status *status) #elif defined(TARGET_HPPA) return const_float64(LIT64(0x7FF4000000000000)); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return const_float64(LIT64(0x7FF7FFFFFFFFFFFF)); } else { #if defined(TARGET_MIPS) @@ -242,7 +260,7 @@ floatx80 floatx80_default_nan(float_status *status) r.low = LIT64(0xFFFFFFFFFFFFFFFF); r.high = 0x7FFF; #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { r.low = LIT64(0xBFFFFFFFFFFFFFFF); r.high = 0x7FFF; } else { @@ -274,7 +292,7 @@ float128 float128_default_nan(float_status *status) { float128 r; - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { r.low = LIT64(0xFFFFFFFFFFFFFFFF); r.high = LIT64(0x7FFF7FFFFFFFFFFF); } else { @@ -319,7 +337,7 @@ int float16_is_quiet_nan(float16 a_, float_status *status) return float16_is_any_nan(a_); #else uint16_t a = float16_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF); } else { return ((a & ~0x8000) >= 0x7C80); @@ -338,7 +356,7 @@ int float16_is_signaling_nan(float16 a_, float_status *status) return 0; #else uint16_t a = float16_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a & ~0x8000) >= 0x7C80); } else { return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF); @@ -356,7 +374,7 @@ float16 float16_silence_nan(float16 a, float_status *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return float16_default_nan(status); } else { return a | (1 << 9); @@ -375,7 +393,7 @@ int float32_is_quiet_nan(float32 a_, float_status *status) return float32_is_any_nan(a_); #else uint32_t a = float32_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a >> 22) & 0x1FF) == 0x1FE) && (a & 0x003FFFFF); } else { return ((uint32_t)(a << 1) >= 0xFF800000); @@ -394,7 +412,7 @@ int float32_is_signaling_nan(float32 a_, float_status *status) return 0; #else uint32_t a = float32_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((uint32_t)(a << 1) >= 0xFF800000); } else { return (((a >> 22) & 0x1FF) == 0x1FE) && (a & 0x003FFFFF); @@ -412,7 +430,7 @@ float32 float32_silence_nan(float32 a, float_status *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { # ifdef TARGET_HPPA a &= ~0x00400000; a |= 0x00200000; @@ -651,7 +669,7 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, return 3; } - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { /* Prefer sNaN over qNaN, in the a, b, c order. */ if (aIsSNaN) { return 0; @@ -786,7 +804,7 @@ int float64_is_quiet_nan(float64 a_, float_status *status) return float64_is_any_nan(a_); #else uint64_t a = float64_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a >> 51) & 0xFFF) == 0xFFE) && (a & 0x0007FFFFFFFFFFFFULL); } else { @@ -806,7 +824,7 @@ int float64_is_signaling_nan(float64 a_, float_status *status) return 0; #else uint64_t a = float64_val(a_); - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a << 1) >= 0xFFF0000000000000ULL); } else { return (((a >> 51) & 0xFFF) == 0xFFE) @@ -825,7 +843,7 @@ float64 float64_silence_nan(float64 a, float_status *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { # ifdef TARGET_HPPA a &= ~0x0008000000000000ULL; a |= 0x0004000000000000ULL; @@ -942,7 +960,7 @@ int floatx80_is_quiet_nan(floatx80 a, float_status *status) #ifdef NO_SIGNALING_NANS return floatx80_is_any_nan(a); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { uint64_t aLow; aLow = a.low & ~0x4000000000000000ULL; @@ -967,7 +985,7 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) #ifdef NO_SIGNALING_NANS return 0; #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a.high & 0x7FFF) == 0x7FFF) && ((a.low << 1) >= 0x8000000000000000ULL); } else { @@ -991,7 +1009,7 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return floatx80_default_nan(status); } else { a.low |= LIT64(0xC000000000000000); @@ -1105,7 +1123,7 @@ int float128_is_quiet_nan(float128 a, float_status *status) #ifdef NO_SIGNALING_NANS return float128_is_any_nan(a); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return (((a.high >> 47) & 0xFFFF) == 0xFFFE) && (a.low || (a.high & 0x00007FFFFFFFFFFFULL)); } else { @@ -1125,7 +1143,7 @@ int float128_is_signaling_nan(float128 a, float_status *status) #ifdef NO_SIGNALING_NANS return 0; #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return ((a.high << 1) >= 0xFFFF000000000000ULL) && (a.low || (a.high & 0x0000FFFFFFFFFFFFULL)); } else { @@ -1145,7 +1163,7 @@ float128 float128_silence_nan(float128 a, float_status *status) #ifdef NO_SIGNALING_NANS g_assert_not_reached(); #else - if (status->snan_bit_is_one) { + if (snan_bit_is_one(status)) { return float128_default_nan(status); } else { a.high |= LIT64(0x0000800000000000); diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 4e378cb612..2aae6a89b1 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -173,6 +173,7 @@ typedef struct float_status { /* should denormalised inputs go to zero and set the input_denormal flag? */ flag flush_inputs_to_zero; flag default_nan_mode; + /* not always used -- see snan_bit_is_one() in softfloat-specialize.h */ flag snan_bit_is_one; } float_status; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index c261b6b090..00bf444620 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -141,7 +141,6 @@ static void hppa_cpu_initfn(Object *obj) cs->env_ptr = env; cs->exception_index = -1; cpu_hppa_loaded_fr0(env); - set_snan_bit_is_one(true, &env->fp_status); cpu_hppa_put_psw(env, PSW_W); } diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 9ae418a577..d31a933cbb 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -3382,7 +3382,6 @@ void helper_xssqrtqp(CPUPPCState *env, uint32_t opcode) xt.f128 = xb.f128; } else if (float128_is_neg(xb.f128) && !float128_is_zero(xb.f128)) { float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSQRT, 1); - set_snan_bit_is_one(0, &env->fp_status); xt.f128 = float128_default_nan(&env->fp_status); } } diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 541ffc2d97..b9f393b7c7 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -71,7 +71,6 @@ static void superh_cpu_reset(CPUState *s) set_flush_to_zero(1, &env->fp_status); #endif set_default_nan_mode(1, &env->fp_status); - set_snan_bit_is_one(1, &env->fp_status); } static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) diff --git a/target/unicore32/cpu.c b/target/unicore32/cpu.c index 29d160a88d..68f978d80b 100644 --- a/target/unicore32/cpu.c +++ b/target/unicore32/cpu.c @@ -70,7 +70,6 @@ static void unicore_ii_cpu_initfn(Object *obj) set_feature(env, UC32_HWCAP_CMOV); set_feature(env, UC32_HWCAP_UCF64); - set_snan_bit_is_one(1, &env->ucf64.fp_status); } static void uc32_any_cpu_initfn(Object *obj) @@ -83,7 +82,6 @@ static void uc32_any_cpu_initfn(Object *obj) set_feature(env, UC32_HWCAP_CMOV); set_feature(env, UC32_HWCAP_UCF64); - set_snan_bit_is_one(1, &env->ucf64.fp_status); } static void uc32_cpu_realizefn(DeviceState *dev, Error **errp) From patchwork Mon May 14 22:12:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135788 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp206241lji; Mon, 14 May 2018 15:38:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr9+5ZeFfezz6ORZ97rHsWbNTXF9LJL71wqTpzrJcdKpE47noG9PFrhrNYFQ1bKmEgikNsK X-Received: by 2002:a37:1fea:: with SMTP id n103-v6mr10347162qkh.412.1526337528233; Mon, 14 May 2018 15:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337528; cv=none; d=google.com; s=arc-20160816; b=klaGk9dhdP/ib5YqMWsR8UHHxQLHpzqBy/mZJ1ixKwboHz2T81nKoa4rmXPp1fIEW2 0dAcHtvCh0BCGYTGff5g7kULa9ZeKWJ0s+jU6XZpIj4OKSg0ZWrB/nR962E1f1eMBjcj lFSSZL8ch2ouHIh5xscFKUQjyRtiYFiTvddQgVHNdlS555KCUx65EsBfaXyujU31jjKE nASpoTFAougfpllhWlkW/gz+h4+toDtC/uFblanq6Fsnt4h6wsK1ijiokohqpCdhQ3++ p7uyyUBWJN1UnWoT2UILJi6uqNbGf7pGPcLQNSEVaXqbWKK/v6w8jIeEBbrO6w9tIIf+ 0RHw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=pmLpbzFSlcK9txUGPmlidLMrXkASMO30TbCTe2kBrY8=; b=zRmwL6h+vtIhDYe7RT5P7j1OGQu//S5mvJyqUKT+57i2OtptDubx1swi1uN6z/ek4f 39BVBJKrN2lK7MsBBMP4TNHREl64XDF7D87iH0WVoUiAyUDRuw3saDMgEm3iovneW3XV 24COcODETAVhPuXFK921zErTz1CZdl4ln4wAt6QjXTiQeIGlqDbU+DMYBlf+XX4bOW6P CtccSYyNDejX+94LPRdi66N7RuCNeXj5QTAGe9SKZBMr6Q4RxgKjguXqpA77G55MT6tb JYI0xjsgCuu7wlISEgPCwZxIedn+Io4FF5LLGTEUQranbx6eQJQLbjFgRBcqgu8q38bX cW2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QR/7me5H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c40-v6si10529912qtk.393.2018.05.14.15.38.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:38:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QR/7me5H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:50622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIM7D-0005QX-Mv for patch@linaro.org; Mon, 14 May 2018 18:38:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiC-0008FG-4q for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiA-0008OR-Ss for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:56 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:39314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiA-0008Mh-N0 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:54 -0400 Received: by mail-pl0-x241.google.com with SMTP id c19-v6so8153578pls.6 for ; Mon, 14 May 2018 15:12:54 -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; bh=pmLpbzFSlcK9txUGPmlidLMrXkASMO30TbCTe2kBrY8=; b=QR/7me5Hn9fDOeuw7QuZu/251zQZWmoXsH6cPGv84psG6K4DID5bhMQnPRYvppOkfN Gg0mSSO2/VmlBq07TdJtEBASmZiMrN9zzv2pMtHGhp3skNAZ9qMmTtWyUe0ukWtGLEo6 /8ZMueCT8xmpnQ7bsVV4Lk2vdcud5l+9yWsng= 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; bh=pmLpbzFSlcK9txUGPmlidLMrXkASMO30TbCTe2kBrY8=; b=rOGFH8FL/odfxbArIEiXldMaeEWZE3Oi8KTi49mLAwPZRY5cJlCuKClkgRqSHgU8ve w5tUaIsC3BAS2dVQ1eSTJm5xdJvtehmoQQoUrQhKWrFMXplen/fEQ1cwLHIHrdttC6EK obyBCNILFgONuqiPFI8L9u7rkrD2nDAt+cetLJwuluBAjmPWv0H+kAll2vJAH49Skf6D QxWkc7AjkXXdqy59jnWLcOJYXnKadmc9p71QD3aMxyyEmXvBEDhVbQWTOf+h28/yl2pm ffBf9idI4l+PInK41JTwJUYbjutEyCAdmOv8rq0GclufZUbF3/OLBU8s5gYJ02dvMk8z RB1A== X-Gm-Message-State: ALKqPwfW4Gi1xs0C5THN5UJrXW8zWeM6AJjIvUfSzAAIovHACofWG9rE dTQSSU0S0lkYcJMhXcBZxbQi/Jo6hLg= X-Received: by 2002:a17:902:8a87:: with SMTP id p7-v6mr11372552plo.278.1526335973511; Mon, 14 May 2018 15:12:53 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:14 -0700 Message-Id: <20180514221219.7091-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v5 23/28] fpu/softfloat: Make is_nan et al available to softfloat-specialize.h 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We will need these helpers within softfloat-specialize.h, so move the definitions above the include. After specialization, they will not always be used so mark them to avoid the Werror. Signed-off-by: Richard Henderson --- fpu/softfloat.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) -- 2.17.0 Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée diff --git a/fpu/softfloat.c b/fpu/softfloat.c index e9e421728b..9934adbae5 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -181,6 +181,22 @@ typedef enum __attribute__ ((__packed__)) { float_class_snan, } FloatClass; +/* Simple helpers for checking if, or what kind of, NaN we have */ +static inline __attribute__((unused)) bool is_nan(FloatClass c) +{ + return unlikely(c >= float_class_qnan); +} + +static inline __attribute__((unused)) bool is_snan(FloatClass c) +{ + return c == float_class_snan; +} + +static inline __attribute__((unused)) bool is_qnan(FloatClass c) +{ + return c == float_class_qnan; +} + /* * Structure holding all of the decomposed parts of a float. The * exponent is unbiased and the fraction is normalized. All @@ -536,20 +552,6 @@ static float64 float64_round_pack_canonical(FloatParts p, float_status *s) return float64_pack_raw(round_canonical(p, s, &float64_params)); } -/* Simple helpers for checking if what NaN we have */ -static bool is_nan(FloatClass c) -{ - return unlikely(c >= float_class_qnan); -} -static bool is_snan(FloatClass c) -{ - return c == float_class_snan; -} -static bool is_qnan(FloatClass c) -{ - return c == float_class_qnan; -} - static FloatParts return_nan(FloatParts a, float_status *s) { switch (a.cls) { From patchwork Mon May 14 22:12:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135790 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp208132lji; Mon, 14 May 2018 15:41:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZom/8jceuKHK/nAoWN9TwW9X+HqR2PfhD4zEIMvkR3u/b9to73/0+ojSXTNjwXmXaE0i+Dv X-Received: by 2002:a0c:8815:: with SMTP id 21-v6mr10924614qvl.167.1526337684826; Mon, 14 May 2018 15:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337684; cv=none; d=google.com; s=arc-20160816; b=h45CC1chqhoKghZAeULbra5YRN6wkgYuuUQ5RlC4tdfFKl24JfCvoiX2hevxrxPGki t77CiKkzj8f5Mv2WyHw2lUWIl3ss9ISNtAyhKNA7V96Ui9RuV09HRAythfzA2nFHFRUg CYam5ITgt6tbVVcYkbexqUFLWpJ3Tl7cAvfnGnj41BCD3I65SG29uoTMKCpJa6ercYdA bhc60UTr1kCCl0yFHMXS/4mX+0qbUFsQIX0ffl9JGHytOdqeBUSTWieWBSo1s/nhI5cu HyCQVrR75xWBQXop03tD47SdEtlqQb34/YdSkFVzKgpVicRnwf8nG1Zq6JWEewpp1BfG wvfQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=AEMxNIHQs7jJxtdv+SUmM5dUZKPGuUubR9YypD1/cP8=; b=vS2OLYXPc44W5k92lmXAMfw1OhfrHOPqKt0jj8VNmxR0wNmo11MVSO7fuu0R0hgewf 0oFdBxiAM5IPkkeN5b3jNguydc2dO0gwscmpHFfmOKoQ4khBqUJyZ8yLYIuT/isMFca6 bE2exNddeqmZa0OMfTOYNKoMZU/wNt9t/IuOv45GJEWef6ckkaDdMTear197pD+gmmtw zt5AUFcSKBPMImQ9vhojLVQJx6eKSqX6zQT8F1I5/1es0mexolo7dbTJgDFeX1QKhWix OccwRV1Uj1E4l87mVgHdJYkYXf9Hg/5BI7rYdiVqtZP29XU78no/O+td/0toN+DYm/PV wsIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zrp17ppC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x2-v6si773640qka.136.2018.05.14.15.41.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:41:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Zrp17ppC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:50834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIM9k-0007w1-A0 for patch@linaro.org; Mon, 14 May 2018 18:41:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiE-0008GD-Di for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiC-0008SK-CB for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:58 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:33642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiC-0008QU-3h for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:56 -0400 Received: by mail-pl0-x241.google.com with SMTP id n10-v6so8155722plp.0 for ; Mon, 14 May 2018 15:12:56 -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; bh=AEMxNIHQs7jJxtdv+SUmM5dUZKPGuUubR9YypD1/cP8=; b=Zrp17ppCTT8eOqgRsutWvp67wAT/x6j3BTswt2EbR6QuxPl3ZU01wdeN8OG7u+UVGy AueKvGi2ptXcKAS6ENkFtBht3GaW9gz192gKI6D4q2BJMc406DFNDyyvY5ZjY88IkOnA CKe+hcAMknStb31tY51XRp60MdroUVQBiTh/Y= 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; bh=AEMxNIHQs7jJxtdv+SUmM5dUZKPGuUubR9YypD1/cP8=; b=Ntz9vBoiKV4Ju2Br73bh/+uJyFC6TaNRDxofqX5imhe6RGSnFoxit2nus3k9N/GlpH 7HPtxFzG6WlB+fbZTnyHV1a+ko1SDlwJosw/WRMBt+kh4DPpl71ERTxjB50nNdF1BkgE LG/OstD4l4ajoXt+hfmfJaypYXY4n9yN1YD1XxOK5wFaR29OGEShCw0rd17cm983COk6 h5MBOVdjNveuj3n5iNXJbF8qC1jgbNYUH+txRIz7o72Kbxf2kTpzosWDPgpKT3KJFteh OJSe28EuA2yHvm1X699/piK33wz+uCa60kWuRGpSex94ioBEGiGD8DS22O7piCEsHOo5 +T8Q== X-Gm-Message-State: ALKqPwdypgWMC6tF/AQhhZ7yQ3hJeqp1oGPY5/EMuUCjnnxZvIg7OUdN hierB6QYcIHsSB9xyJtVF/EAnc55A5k= X-Received: by 2002:a17:902:4303:: with SMTP id i3-v6mr11889953pld.394.1526335974681; Mon, 14 May 2018 15:12:54 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:15 -0700 Message-Id: <20180514221219.7091-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v5 24/28] fpu/softfloat: Pass FloatClass to pickNaN 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For each operand, pass a single enumeration instead of a pair of booleans. The commit also merges multiple different ifdef-selected implementations of pickNaN into a single function whose body is ifdef-selected. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 168 ++++++++++++++++++------------------- fpu/softfloat.c | 3 +- 2 files changed, 82 insertions(+), 89 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index d1e06da75b..2695183188 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -501,10 +501,10 @@ static float32 commonNaNToFloat32(commonNaNT a, float_status *status) | tie-break rule. *----------------------------------------------------------------------------*/ -#if defined(TARGET_ARM) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, +static int pickNaN(FloatClass a_cls, FloatClass b_cls, flag aIsLargerSignificand) { +#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) /* ARM mandated NaN propagation rules (see FPProcessNaNs()), take * the first of: * 1. A if it is signaling @@ -513,20 +513,6 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, * 4. B (quiet) * A signaling NaN is always quietened before returning it. */ - if (aIsSNaN) { - return 0; - } else if (bIsSNaN) { - return 1; - } else if (aIsQNaN) { - return 0; - } else { - return 1; - } -} -#elif defined(TARGET_MIPS) || defined(TARGET_HPPA) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ /* According to MIPS specifications, if one of the two operands is * a sNaN, a new qNaN has to be generated. This is done in * floatXX_silence_nan(). For qNaN inputs the specifications @@ -540,35 +526,21 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, * 4. B (quiet) * A signaling NaN is always silenced before returning it. */ - if (aIsSNaN) { + if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } -} -#elif defined(TARGET_PPC) || defined(TARGET_XTENSA) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ +#elif defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K) /* PowerPC propagation rules: * 1. A if it sNaN or qNaN * 2. B if it sNaN or qNaN * A signaling NaN is always silenced before returning it. */ - if (aIsSNaN || aIsQNaN) { - return 0; - } else { - return 1; - } -} -#elif defined(TARGET_M68K) -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ /* M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL * 3.4 FLOATING-POINT INSTRUCTION DETAILS * If either operand, but not both operands, of an operation is a @@ -583,16 +555,12 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, * a nonsignaling NaN. The operation then continues as described in the * preceding paragraph for nonsignaling NaNs. */ - if (aIsQNaN || aIsSNaN) { /* a is the destination operand */ - return 0; /* return the destination operand */ + if (is_nan(a_cls)) { + return 0; } else { - return 1; /* return b */ + return 1; } -} #else -static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag aIsLargerSignificand) -{ /* This implements x87 NaN propagation rules: * SNaN + QNaN => return the QNaN * two SNaNs => return the one with the larger significand, silenced @@ -603,13 +571,13 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, * If we get down to comparing significands and they are the same, * return the NaN with the positive sign bit (if any). */ - if (aIsSNaN) { - if (bIsSNaN) { + if (is_snan(a_cls)) { + if (is_snan(b_cls)) { return aIsLargerSignificand ? 0 : 1; } - return bIsQNaN ? 1 : 0; - } else if (aIsQNaN) { - if (bIsSNaN || !bIsQNaN) { + return is_qnan(b_cls) ? 1 : 0; + } else if (is_qnan(a_cls)) { + if (is_snan(b_cls) || !is_qnan(b_cls)) { return 0; } else { return aIsLargerSignificand ? 0 : 1; @@ -617,8 +585,8 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, } else { return 1; } -} #endif +} /*---------------------------------------------------------------------------- | Select which NaN to propagate for a three-input operation. @@ -752,18 +720,26 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; uint32_t av, bv; + FloatClass a_cls, b_cls; + + /* This is not complete, but is good enough for pickNaN. */ + a_cls = (!float32_is_any_nan(a) + ? float_class_normal + : float32_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls = (!float32_is_any_nan(b) + ? float_class_normal + : float32_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); - aIsQuietNaN = float32_is_quiet_nan(a, status); - aIsSignalingNaN = float32_is_signaling_nan(a, status); - bIsQuietNaN = float32_is_quiet_nan(b, status); - bIsSignalingNaN = float32_is_signaling_nan(b, status); av = float32_val(a); bv = float32_val(b); - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } @@ -779,14 +755,13 @@ static float32 propagateFloat32NaN(float32 a, float32 b, float_status *status) aIsLargerSignificand = (av < bv) ? 1 : 0; } - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return float32_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return float32_silence_nan(a, status); } return a; @@ -908,18 +883,26 @@ static float64 commonNaNToFloat64(commonNaNT a, float_status *status) static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; uint64_t av, bv; + FloatClass a_cls, b_cls; + + /* This is not complete, but is good enough for pickNaN. */ + a_cls = (!float64_is_any_nan(a) + ? float_class_normal + : float64_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls = (!float64_is_any_nan(b) + ? float_class_normal + : float64_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); - aIsQuietNaN = float64_is_quiet_nan(a, status); - aIsSignalingNaN = float64_is_signaling_nan(a, status); - bIsQuietNaN = float64_is_quiet_nan(b, status); - bIsSignalingNaN = float64_is_signaling_nan(b, status); av = float64_val(a); bv = float64_val(b); - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } @@ -935,14 +918,13 @@ static float64 propagateFloat64NaN(float64 a, float64 b, float_status *status) aIsLargerSignificand = (av < bv) ? 1 : 0; } - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return float64_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return float64_silence_nan(a, status); } return a; @@ -1075,15 +1057,22 @@ static floatx80 commonNaNToFloatx80(commonNaNT a, float_status *status) floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; + FloatClass a_cls, b_cls; - aIsQuietNaN = floatx80_is_quiet_nan(a, status); - aIsSignalingNaN = floatx80_is_signaling_nan(a, status); - bIsQuietNaN = floatx80_is_quiet_nan(b, status); - bIsSignalingNaN = floatx80_is_signaling_nan(b, status); + /* This is not complete, but is good enough for pickNaN. */ + a_cls = (!floatx80_is_any_nan(a) + ? float_class_normal + : floatx80_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls = (!floatx80_is_any_nan(b) + ? float_class_normal + : floatx80_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } @@ -1099,14 +1088,13 @@ floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) aIsLargerSignificand = (a.high < b.high) ? 1 : 0; } - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return floatx80_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return floatx80_silence_nan(a, status); } return a; @@ -1217,15 +1205,22 @@ static float128 commonNaNToFloat128(commonNaNT a, float_status *status) static float128 propagateFloat128NaN(float128 a, float128 b, float_status *status) { - flag aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN; flag aIsLargerSignificand; + FloatClass a_cls, b_cls; - aIsQuietNaN = float128_is_quiet_nan(a, status); - aIsSignalingNaN = float128_is_signaling_nan(a, status); - bIsQuietNaN = float128_is_quiet_nan(b, status); - bIsSignalingNaN = float128_is_signaling_nan(b, status); + /* This is not complete, but is good enough for pickNaN. */ + a_cls = (!float128_is_any_nan(a) + ? float_class_normal + : float128_is_signaling_nan(a, status) + ? float_class_snan + : float_class_qnan); + b_cls = (!float128_is_any_nan(b) + ? float_class_normal + : float128_is_signaling_nan(b, status) + ? float_class_snan + : float_class_qnan); - if (aIsSignalingNaN | bIsSignalingNaN) { + if (is_snan(a_cls) || is_snan(b_cls)) { float_raise(float_flag_invalid, status); } @@ -1241,14 +1236,13 @@ static float128 propagateFloat128NaN(float128 a, float128 b, aIsLargerSignificand = (a.high < b.high) ? 1 : 0; } - if (pickNaN(aIsQuietNaN, aIsSignalingNaN, bIsQuietNaN, bIsSignalingNaN, - aIsLargerSignificand)) { - if (bIsSignalingNaN) { + if (pickNaN(a_cls, b_cls, aIsLargerSignificand)) { + if (is_snan(b_cls)) { return float128_silence_nan(b, status); } return b; } else { - if (aIsSignalingNaN) { + if (is_snan(a_cls)) { return float128_silence_nan(a, status); } return a; diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 9934adbae5..43264fa1f6 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -580,8 +580,7 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s) if (s->default_nan_mode) { return parts_default_nan(s); } else { - if (pickNaN(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), + if (pickNaN(a.cls, b.cls, a.frac > b.frac || (a.frac == b.frac && a.sign < b.sign))) { a = b; From patchwork Mon May 14 22:12:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135779 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp200033lji; Mon, 14 May 2018 15:30:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpzPEhAXM6u1HIZC1uv0P8A7SWuWNozQluw3sZz5DR9cA2EE5HX89pjlFX9Aadi4pRlIIBw X-Received: by 2002:a0c:a94c:: with SMTP id z12-v6mr10803590qva.57.1526337045979; Mon, 14 May 2018 15:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337045; cv=none; d=google.com; s=arc-20160816; b=IXwyiKJh6g8BTudZvKGDfJ4Pc5Emit2HLI3mwjZb4E6HwhcBnw0ZU1DCkpewHrTLBW xWn1zhueJCl/oCxjXCz/xTyD43AqFDJJRVRG9T7gjGG8J0j53xBFNsN8/Rm/2ecjFKIC QCVCJCPyfHEnQ21nhGmfOMJTsNBjEK1J3kueA/aJTp9PnlxN/7W53HBLnDurz717b67o Twuum8sKnQ+YR7A1inf1CS0u5qTK4uDBaOzcNEJOd4mT3xDTqz0IyFlw68nVbIUfA3+b 5JkPI6kb0CnwFIOmBBP2N4hyrOJIJ+BAas59Y8gHfXkM88oqJ2rKQs4/vnhkVGYsTdqg 1Dbg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=6WuZ9p/7jNL+hLMOjd4yPOus0eQnm6/8jO4I9mebAGw=; b=dnNNCY5sEDyDoJuE35QzcPIxTJjHFy87nD2nJgS3Tq2KlgtovnyyRKOH0MYs0HR8Bw Ao7hI5Sv+2V+4t9y7yqUMmJocnT4nNX2iZpl2JLXsVYJCFyscSz2VaB4+3jOLCqmnmXu L+fiMyMDDHD3AYtdC8Ype+PeJurnaglsoSAb4/NoRrz6/y/CcYYm9b8jFFlwMLdnt69H U37bHBPSJX4SayG7tvXPZccf08B0ZJFSq/ppzLNjSbChmWXOcIUWvIsR1im6iT0JksLk PUSU54HcNM2IK7OXSeK5hmvjFjhvfzlQ1IcIz2VrN+gIAozxKM5cLdqsJo53YLV+wlaI XwmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YWW+5kIx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z132-v6si1871914qkz.36.2018.05.14.15.30.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:30:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YWW+5kIx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILzR-0005on-Bc for patch@linaro.org; Mon, 14 May 2018 18:30:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiF-0008GF-5f for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiD-0008Vn-M1 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:59 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:40810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiD-0008Tl-Dy for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:57 -0400 Received: by mail-pf0-x242.google.com with SMTP id f189-v6so6668320pfa.7 for ; Mon, 14 May 2018 15:12:57 -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; bh=6WuZ9p/7jNL+hLMOjd4yPOus0eQnm6/8jO4I9mebAGw=; b=YWW+5kIxaZXUUKq4PgJcLnv9QX1aexikvnpfJyULyC/kLpA0MvcYNlcpbG3wTYRR8l S7+YtUumN3VLQ0LYzRFME3js9X34rXlwO9SMwoWe1YRBu9RDHNxFQk1ILiwpxj89bf8h L692iDCQrhDQWNwCtdogUUA2kwW0C5oSlDr/0= 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; bh=6WuZ9p/7jNL+hLMOjd4yPOus0eQnm6/8jO4I9mebAGw=; b=mVh0/I9j8E0sAj3sOuNfw83lFZR+AI65YjaFlx3hxWVHF2XTc5jUWFvx/kWf6Cq6s3 y7wMYNpyUY9Ml0xr4BFqqzvd57w47fY1XskxYv2AeO9toq2LTN8lERBbLB3UESSltu3F 3mEAsMoLoc83DxiCztmwa3W2+wb6TpFAlzzf8Iey1womZ4zlLq6fNxz5FBovP+U4AR1m u9jbHtAx9bJxZy4SmH8B/+gNS4a7OtbrKhT+ndEOCAuPg8df+HIHTkaUuVH4aUBFnRpM DFP/qU6A6/XZZzxf7MzEm5vofsg6V5cTJZCxrLBZDG5SeBbSqzZOLWMIMfBdJ743Rc+k LOYg== X-Gm-Message-State: ALKqPwf1rLXWA+Wfl2+OB6FrUYoMipIFDOdSBWXr58MB4EiTpZ0/Xa6r /2xoYpiLy/7Mcvuv8VmhYrcZwfmezC8= X-Received: by 2002:a63:8849:: with SMTP id l70-v6mr10027306pgd.49.1526335976103; Mon, 14 May 2018 15:12:56 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:16 -0700 Message-Id: <20180514221219.7091-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v5 25/28] fpu/softfloat: Pass FloatClass to pickNaNMulAdd 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For each operand, pass a single enumeration instead of a pair of booleans. The commit also merges multiple different ifdef-selected implementations of pickNaNMulAdd into a single function whose body is ifdef-selected. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 70 +++++++++++++++----------------------- fpu/softfloat.c | 5 +-- 2 files changed, 28 insertions(+), 47 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 2695183188..0399dfe011 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -594,15 +594,14 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | information. | Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN *----------------------------------------------------------------------------*/ -#if defined(TARGET_ARM) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) +static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, + bool infzero, float_status *status) { +#if defined(TARGET_ARM) /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns * the default NaN */ - if (infzero && cIsQNaN) { + if (infzero && is_qnan(c_cls)) { float_raise(float_flag_invalid, status); return 3; } @@ -610,25 +609,20 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, /* This looks different from the ARM ARM pseudocode, because the ARM ARM * puts the operands to a fused mac operation (a*b)+c in the order c,a,b. */ - if (cIsSNaN) { + if (is_snan(c_cls)) { return 2; - } else if (aIsSNaN) { + } else if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsQNaN) { + } else if (is_qnan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } -} #elif defined(TARGET_MIPS) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ /* For MIPS, the (inf,zero,qnan) case sets InvalidOp and returns * the default NaN */ @@ -639,41 +633,36 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, if (snan_bit_is_one(status)) { /* Prefer sNaN over qNaN, in the a, b, c order. */ - if (aIsSNaN) { + if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsSNaN) { + } else if (is_snan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; - } else if (bIsQNaN) { + } else if (is_qnan(b_cls)) { return 1; } else { return 2; } } else { /* Prefer sNaN over qNaN, in the c, a, b order. */ - if (cIsSNaN) { + if (is_snan(c_cls)) { return 2; - } else if (aIsSNaN) { + } else if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsQNaN) { + } else if (is_qnan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } } -} #elif defined(TARGET_PPC) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer * to return an input NaN if we have one (ie c) rather than generating * a default NaN @@ -686,31 +675,26 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB */ - if (aIsSNaN || aIsQNaN) { + if (is_nan(a_cls)) { return 0; - } else if (cIsSNaN || cIsQNaN) { + } else if (is_nan(c_cls)) { return 2; } else { return 1; } -} #else -/* A default implementation: prefer a to b to c. - * This is unlikely to actually match any real implementation. - */ -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ - if (aIsSNaN || aIsQNaN) { + /* A default implementation: prefer a to b to c. + * This is unlikely to actually match any real implementation. + */ + if (is_nan(a_cls)) { return 0; - } else if (bIsSNaN || bIsQNaN) { + } else if (is_nan(b_cls)) { return 1; } else { return 2; } -} #endif +} /*---------------------------------------------------------------------------- | Takes two single-precision floating-point values `a' and `b', one of which diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 43264fa1f6..65e970eeb2 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -601,10 +601,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, s->float_exception_flags |= float_flag_invalid; } - which = pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), - is_qnan(c.cls), is_snan(c.cls), - inf_zero, s); + which = pickNaNMulAdd(a.cls, b.cls, c.cls, inf_zero, s); if (s->default_nan_mode) { /* Note that this check is after pickNaNMulAdd so that function From patchwork Mon May 14 22:12:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135777 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp198169lji; Mon, 14 May 2018 15:28:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo+BX3nI3FLLHQO1mMoa08210ne4i9mR64Xyr8nl4IRtgpWS/PzVJnpDN0v+Hvc+8r2qAPZ X-Received: by 2002:aed:3eee:: with SMTP id o43-v6mr10580666qtf.3.1526336909134; Mon, 14 May 2018 15:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526336909; cv=none; d=google.com; s=arc-20160816; b=syCTqvU7/OzBajH/nxDpKPCUVoi9oIQlWgdyNMyk+GqztIAdvcxlHEEltvGHpSjsW3 iYoqr2aDXBkEQUM4H8SLLij4Mu/+iBxihsVBUGZq6RYNQ7UkxBEIUuqjtXPv9v0C39vX s+jbGorLH9GNLuhQq3F2qFqESWRaV/mxSo7M3q5ORWKGL1dC+vV0Lyd55H0gcC47Mavl e1DqmYCA4yQ7By7PosW6NTlgWDuidQHmFOGcJOrhU79mZLwWjU4iczeuW2wzKR3mupZa e5bbv+dhWIR0lebn2oITlWY+RsLIdkmK4zyC6CbJmaN96+a1Gte0hZBEFJGlm6HLHY2H t+Ng== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=tSLVnkHv3Kd/+xdpFOzuYurgmMTBI9n4hg87yMUQ/60=; b=XUbqLOdrl5HF0P1p4G54V9UASJBc+REXRqqDQO0n4AFODI7pcotfViHP4aiBYTW8FG 9OV9yE6gacsMkK1gjo/kIoMrYhBZR2KgeNaMqDlpo/EkNDmN19rN4YPr9/nnFpcvN+3a 8naHlcTws7MFIvGCFMhjbAS9PX+7QOtiHsnknLWrdkOQJHhXvdyhwHEBiE0wJeElD01z GzGWfgbuxHnTk+idjHmypTs1/k4gGb8izd+yacUgR5JtKGtf4khRsfs8LyMB5tt7NpN7 yMYobtX5+JmncdHo2R584fWJaxn3kFUtXMd3w+8aFHRonE/XarmA1h+8VEvdhMYWJ3HV Y3hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GDXRGPmQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m25-v6si763808qtn.124.2018.05.14.15.28.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:28:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GDXRGPmQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:49976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILxE-0004jH-H2 for patch@linaro.org; Mon, 14 May 2018 18:28:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiG-0008HZ-Iz for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiF-00008a-3Z for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:00 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:37438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiE-00006M-Rg for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:59 -0400 Received: by mail-pf0-x244.google.com with SMTP id e9-v6so6669644pfi.4 for ; Mon, 14 May 2018 15:12:58 -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; bh=tSLVnkHv3Kd/+xdpFOzuYurgmMTBI9n4hg87yMUQ/60=; b=GDXRGPmQLnEoaRDsgrwT1pFP1KnURwDgwOy8M9nxL8KaUDY5a1y4Qz+O5nPaLk5moP 7ES3LNnYBZNmICYrbWuAZDwiSXqG/WztKL0Z4pVaAxRdANRcQCJn3hueFEVdxLjc3eoB daq8v08o2GqG2GEJDhTPrQPNXkb0IoWi0M73A= 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; bh=tSLVnkHv3Kd/+xdpFOzuYurgmMTBI9n4hg87yMUQ/60=; b=QzEsWzmzMGOB6RJRNx586lNyg1Z7DaJk/6PmquCoL6xNY+rHHQIb6J9IL1ratoE7kP YbV1nw4cBZNWmCZhPCG/XgpQrNhi31FaBctcsX2nPwVMqFJkwhldSTgTprblmRBxOm5F bdYw0+W0j9JqkBJA+RGiREaJlHNoFIUvnWmWTf8ehk4X21Lbx3RAOA7VF+TM71ZXCBQL VR27ydSdkcL4H8A78qtaZWSO37c7WnoRnjT+G5LXM5j+U//+zRb8XTmLCUagU4UPOdA5 46/OnjZA8erzITggVIP/wHmXBdIKqWVqC8WBVfSN9fjmZsIruyl/g9AtldEMk8mWLOuB OcjA== X-Gm-Message-State: ALKqPwcs+KW+O2h16QWPRrpz0IlIFvICy72f4in21wFcAfOwMCPItqrR WLqbK+0/jjz7yjwU7iaSDZ2CY5C4bFM= X-Received: by 2002:a63:5f11:: with SMTP id t17-v6mr8332307pgb.94.1526335977527; Mon, 14 May 2018 15:12:57 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:17 -0700 Message-Id: <20180514221219.7091-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v5 26/28] fpu/softfloat: Define floatN_default_nan in terms of parts_default_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Isolate the target-specific choice to 2 functions instead of 6. The code in float16_default_nan was only correct for ARM, MIPS, and X86. Though float16 support is rare among our targets. The code in float128_default_nan was arguably wrong for Sparc. While QEMU supports the Sparc 128-bit insns, no real cpu enables it. The code in floatx80_default_nan tried to be over-general. There are only two targets that support this format: x86 and m68k. Thus there is no point in inventing a value for snan_bit_is_one. Move routines that no longer have ifdefs out of softfloat-specialize.h. Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 105 +++---------------------------------- fpu/softfloat.c | 35 +++++++++++++ 2 files changed, 41 insertions(+), 99 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 0399dfe011..9d562ed504 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -179,94 +179,22 @@ static FloatParts parts_silence_nan(FloatParts a, float_status *status) return a; } -/*---------------------------------------------------------------------------- -| The pattern for a default generated half-precision NaN. -*----------------------------------------------------------------------------*/ -float16 float16_default_nan(float_status *status) -{ -#if defined(TARGET_ARM) - return const_float16(0x7E00); -#else - if (snan_bit_is_one(status)) { - return const_float16(0x7DFF); - } else { -#if defined(TARGET_MIPS) - return const_float16(0x7E00); -#else - return const_float16(0xFE00); -#endif - } -#endif -} - -/*---------------------------------------------------------------------------- -| The pattern for a default generated single-precision NaN. -*----------------------------------------------------------------------------*/ -float32 float32_default_nan(float_status *status) -{ -#if defined(TARGET_SPARC) || defined(TARGET_M68K) - return const_float32(0x7FFFFFFF); -#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) || \ - defined(TARGET_XTENSA) || defined(TARGET_S390X) || \ - defined(TARGET_TRICORE) || defined(TARGET_RISCV) - return const_float32(0x7FC00000); -#elif defined(TARGET_HPPA) - return const_float32(0x7FA00000); -#else - if (snan_bit_is_one(status)) { - return const_float32(0x7FBFFFFF); - } else { -#if defined(TARGET_MIPS) - return const_float32(0x7FC00000); -#else - return const_float32(0xFFC00000); -#endif - } -#endif -} - -/*---------------------------------------------------------------------------- -| The pattern for a default generated double-precision NaN. -*----------------------------------------------------------------------------*/ -float64 float64_default_nan(float_status *status) -{ -#if defined(TARGET_SPARC) || defined(TARGET_M68K) - return const_float64(LIT64(0x7FFFFFFFFFFFFFFF)); -#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) || \ - defined(TARGET_S390X) || defined(TARGET_RISCV) - return const_float64(LIT64(0x7FF8000000000000)); -#elif defined(TARGET_HPPA) - return const_float64(LIT64(0x7FF4000000000000)); -#else - if (snan_bit_is_one(status)) { - return const_float64(LIT64(0x7FF7FFFFFFFFFFFF)); - } else { -#if defined(TARGET_MIPS) - return const_float64(LIT64(0x7FF8000000000000)); -#else - return const_float64(LIT64(0xFFF8000000000000)); -#endif - } -#endif -} - /*---------------------------------------------------------------------------- | The pattern for a default generated extended double-precision NaN. *----------------------------------------------------------------------------*/ floatx80 floatx80_default_nan(float_status *status) { floatx80 r; + + /* None of the targets that have snan_bit_is_one use floatx80. */ + assert(!snan_bit_is_one(status)); #if defined(TARGET_M68K) r.low = LIT64(0xFFFFFFFFFFFFFFFF); r.high = 0x7FFF; #else - if (snan_bit_is_one(status)) { - r.low = LIT64(0xBFFFFFFFFFFFFFFF); - r.high = 0x7FFF; - } else { - r.low = LIT64(0xC000000000000000); - r.high = 0xFFFF; - } + /* X86 */ + r.low = LIT64(0xC000000000000000); + r.high = 0xFFFF; #endif return r; } @@ -285,27 +213,6 @@ floatx80 floatx80_default_nan(float_status *status) const floatx80 floatx80_infinity = make_floatx80_init(floatx80_infinity_high, floatx80_infinity_low); -/*---------------------------------------------------------------------------- -| The pattern for a default generated quadruple-precision NaN. -*----------------------------------------------------------------------------*/ -float128 float128_default_nan(float_status *status) -{ - float128 r; - - if (snan_bit_is_one(status)) { - r.low = LIT64(0xFFFFFFFFFFFFFFFF); - r.high = LIT64(0x7FFF7FFFFFFFFFFF); - } else { - r.low = LIT64(0x0000000000000000); -#if defined(TARGET_S390X) || defined(TARGET_PPC) || defined(TARGET_RISCV) - r.high = LIT64(0x7FFF800000000000); -#else - r.high = LIT64(0xFFFF800000000000); -#endif - } - return r; -} - /*---------------------------------------------------------------------------- | Raises the exceptions specified by `flags'. Floating-point traps can be | defined here if desired. It is currently not possible for such a trap diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 65e970eeb2..b5842f7b1c 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2092,6 +2092,41 @@ float64 __attribute__((flatten)) float64_sqrt(float64 a, float_status *status) return float64_round_pack_canonical(pr, status); } +/*---------------------------------------------------------------------------- +| The pattern for a default generated NaN. +*----------------------------------------------------------------------------*/ + +float16 float16_default_nan(float_status *status) +{ + return float16_pack_raw(parts_default_nan(status)); +} + +float32 float32_default_nan(float_status *status) +{ + return float32_pack_raw(parts_default_nan(status)); +} + +float64 float64_default_nan(float_status *status) +{ + return float64_pack_raw(parts_default_nan(status)); +} + +float128 float128_default_nan(float_status *status) +{ + FloatParts p = parts_default_nan(status); + float128 r; + + /* Extrapolate from the choices made by parts_default_nan to fill + * in the quad-floating format. If the low bit is set, assume we + * want to set all non-snan bits. + */ + r.low = -(p.frac & 1); + r.high = p.frac >> (DECOMPOSED_BINARY_POINT - 48); + r.high |= LIT64(0x7FFF000000000000); + r.high |= (uint64_t)p.sign << 63; + + return r; +} /*---------------------------------------------------------------------------- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 From patchwork Mon May 14 22:12:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135792 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp209412lji; Mon, 14 May 2018 15:43:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpau5487+J4F+iPQqo3xdCozAcMW4XTjYPlfja5f242XyCMS0xtVYk3/YIC1/8nMG2Ap5WL X-Received: by 2002:aed:356a:: with SMTP id b39-v6mr10748836qte.230.1526337795745; Mon, 14 May 2018 15:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337795; cv=none; d=google.com; s=arc-20160816; b=mWIL0qIwNeecuvNPmTpBzdxEOoOjlxDRDad/2OGKzPOnE3mYs/rqyrgNjp59256I+P +OzugQTW1KXGLA4G+guc1kqG9a0RQyr+5lpY6BYdntrJ9GL6gL4jnxFGXKxdYBVcqvbH ppTVLiV7bXiFjwVv3xIxpHkwP/mKhsD0X/7CQ8jf8rtC4lI0Ed7WGjcsxKcFVTvgCofS zrC3r/GqAFopAU6XOtcNN5xmEWGwvNsilpV/u7AzyRvdcLeBw6mj2KhmlmzMiTYxniqF AMxXCIebv8+zKCFLDpopQw+jek/o8mFfHmDQmjo4TGdnPXUollBOxBid4oUB0JB1Mr3M jcVw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=MmSgSLwT1JZjRsPCpF/ZgIgh9cLg8HFIxpF7qjon1YU=; b=IvymJ49EilB4SmV/IVWCdDRGXtvCk9k2VBZx4EKu1fhiXjEniPKq76xPoSPeQ5CDvo YQuJgkjKEICUV8LUO48LW+Ljp7FUzlNQy2aDN1MPz4wufHo/HvrDOtw4AMXdNjLn3QtL eUrmnqnQUtAcJk3cmHMABusuFE640nYME4fAadjkUqlIj9ICK5YPrTF6ih67yeJ0NpXM Zbl3o5T8HbmGM3OtJYmN3Z3MTm0RRlF/gW6FSzU8xlVprYt2kEasp32Ov2XXK3CxKxzT NkRKt6kJccpOt+tYRr2gYBREaoemDqTgRV8VirizU4FVNaLcSFEkEpbx95rTVw5VstLf b67Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QoxeagOy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u32-v6si131302qth.34.2018.05.14.15.43.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:43:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QoxeagOy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:50957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIMBX-0000x1-3G for patch@linaro.org; Mon, 14 May 2018 18:43:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiH-0008JU-G2 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiG-0000C8-8D for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:01 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:37436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiG-0000AG-1r for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:00 -0400 Received: by mail-pf0-x241.google.com with SMTP id e9-v6so6669675pfi.4 for ; Mon, 14 May 2018 15:13:00 -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; bh=MmSgSLwT1JZjRsPCpF/ZgIgh9cLg8HFIxpF7qjon1YU=; b=QoxeagOy7NvXSOcgbeZjM6UqSXCzSETKqOrfTtlfIXXjDnXaGMgxX7Fmf7/prulULO ZSnMHHW1ij9QUNUkZioPDX0OcqJOFeZ7sfb/3HFY04PFKSWXMGi2VC5YVB5PT3Vu8ccC FTZ62O4uZpUJ8Mhx8q0ZnKVs9Dmp8Q72iFCag= 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; bh=MmSgSLwT1JZjRsPCpF/ZgIgh9cLg8HFIxpF7qjon1YU=; b=e6L0jlWWKaD++stN9wSJIgCmNzwWLQEwcO1JXxfvlXuuCmAkO4CZnqlpxKxvvwvAwh 8Tq3KibdSqZ4i6cSmmeXwINHpUFSC0MNgSaq04wXZ28CqFLhvezlpUISa7fZQBH5JYQI +sIsqk/MgO0MDjKrBhkCBgv7kKImNytPlLWgIu2JKKqRqsxqN8aKZSa/uiTLIK3fqNWV LoOXS9s463t+b3cSMpov+QEn9h5Q0w6YLiXsSE8bu+b1ZnH1KmZVEcT6LbwUY13F6hWP fHZEdDPB7+ctH5KzYs9Wchh8FwkFQfmGDNzNI3xf6Wtz0AgJLU/zIp0FQHtYoGDV/Vp5 RrIw== X-Gm-Message-State: ALKqPwfGg4iSx8ZJjvu5AEgIemCUnDQMHLU16e35wVeY9AfT5L/dGOv+ ydyQ8DjbSBjicnJlVIK3Hk0SKgiJWTI= X-Received: by 2002:a65:508d:: with SMTP id r13-v6mr10018768pgp.134.1526335978831; Mon, 14 May 2018 15:12:58 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:18 -0700 Message-Id: <20180514221219.7091-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v5 27/28] fpu/softfloat: Clean up parts_default_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reduce the number of ifdefs. Correct the result for OpenRISC and TriCore (although TriCore fixed in target-specific code). Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 9d562ed504..ec4fb6ba8b 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -129,22 +129,29 @@ static FloatParts parts_default_nan(float_status *status) uint64_t frac; #if defined(TARGET_SPARC) || defined(TARGET_M68K) + /* !snan_bit_is_one, set all bits */ frac = (1ULL << DECOMPOSED_BINARY_POINT) - 1; -#elif defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_ALPHA) || \ - defined(TARGET_S390X) || defined(TARGET_RISCV) +#elif defined(TARGET_I386) || defined(TARGET_X86_64) \ + || defined(TARGET_MICROBLAZE) + /* !snan_bit_is_one, set sign and msb */ frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); + sign = 1; #elif defined(TARGET_HPPA) + /* snan_bit_is_one, set msb-1. */ frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2); #else + /* This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, + * S390, SH4, TriCore, and Xtensa. I cannot find documentation + * for Unicore32; the choice from the original commit is unchanged. + * Our other supported targets, CRIS, LM32, Moxie, Nios2, and Tile, + * do not have floating-point. + */ if (snan_bit_is_one(status)) { + /* set all bits other than msb */ frac = (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; } else { -#if defined(TARGET_MIPS) + /* set msb */ frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); -#else - frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); - sign = 1; -#endif } #endif From patchwork Mon May 14 22:12:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135780 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp200888lji; Mon, 14 May 2018 15:31:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZolwqRk9uKeMMEQtGUTOBlVF3ZHp8jOA2CcPTmkJwAkHmYLGDLK+y11n6HY9/UI4fLsvYv/ X-Received: by 2002:a0c:989b:: with SMTP id f27-v6mr10724718qvd.115.1526337103357; Mon, 14 May 2018 15:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337103; cv=none; d=google.com; s=arc-20160816; b=MzoxwkaTh/HF7Ld0Vcp314Kca2AZok9iCyuDCQEJRTx/LjOw53EJ84xa7i0YGYNxbP 6vamnpc/oulfdJjlSXCkMmjWSyLswh3oqONtQZWzTmkpK7o3GhP1mlzcfCzCElyly+9v HT3UhwohvhftCybf8NMqX/gyMtfLDmTBDXd7T/OvCaSwiVugsZx40/s3onzJ38x29fuI oz4p8HqS5jTdkfovBC0zyeBchhOpyn4AE6/ZQPAx1osBakIJDl8ZHNyWO9kTvJnIaj6m +AuvgA2yUrZL8EkHrVKo+AewQuBXnkA77gnLTYcoW76+4H9AQi0UddSyT+ecGPOPH02k ASjQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=1q8CvQLaVO8CGA7b0QttcxlJQ18Lc1p3qQpT+0UVsAo=; b=rmhRIXjPUl9qZ2MVJMwEjWQ98ExWPF3BRFM/YI9mKMJFUeZt8JwuNgf6WjCiylgdfD I8jWikqscfbj3xzaolmCY9LWsBwKJxqJmYlLtg9PBHM5QYtfef2vOFfnc6yQkABvJa2G RmgIPFccW4QFJ5Qcb1w6wojjNmDrIYcrQqfIMI+w7nf1M6NE4dXK//9Qj9lNptAdt91U a70tyLAynzXa/cmMLbjVIMxD5habibxOouqeuXC+NrMQ1EGL5rzGrHpzlFXV5DeLLtvx aQ5TeFwJYDY3peVXFs7+EJAVXCg6hmfFLU0rzGZ4m6bDng3jDxdio4WnnA1ffVG2lqs/ o9tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PLhE6j6R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e30-v6si3140479qtg.171.2018.05.14.15.31.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PLhE6j6R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:50038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIM0M-0007Nh-MF for patch@linaro.org; Mon, 14 May 2018 18:31:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiK-0008OZ-U5 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiH-0000GH-LU for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:04 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:42034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiH-0000EG-Cy for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:01 -0400 Received: by mail-pg0-x243.google.com with SMTP id p9-v6so6060659pgc.9 for ; Mon, 14 May 2018 15:13:01 -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; bh=1q8CvQLaVO8CGA7b0QttcxlJQ18Lc1p3qQpT+0UVsAo=; b=PLhE6j6RHwTeLpMhHWmfh/+n0R9IrFT1wBxKJYKvhijYAISElXJ4pj0U5jYKmBOlF4 th6lpZn7BEAt9slRPPNhxdmHmx/OgKxd99q4od6A/MwO+SLunpPdCDPDrso2GeLajAFd OENbHXvPQURChSLhb9Ax7Ym0zgMl8+w/Xi5lg= 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; bh=1q8CvQLaVO8CGA7b0QttcxlJQ18Lc1p3qQpT+0UVsAo=; b=IjSmxX1W2Ug+Qi2hBP4xnX+qJi3iquzPPyFjiZYc7R2NrjO3ZEITB2+oUp2TOZQHM0 BKWFvNuKjCqykyJu3oCvuZoxIo5Z8QfXzHNWT0fXVnPpluNN9enyyF4Ru1Zf8DOKoAEC ITThGx+TRrRMT627VWm/YHZXe89X93ZgUgsmLNQeV2SuZTHsVC7Gi7tmUv7eg8bJsBu/ qqME3EaCXM9iWISHAf/irr0ACG2wEFIgVmqbUikUKEdI0vroWSAcOtU1A7HQLxRT2NM4 Vt8+Nf4iCTocp+hrYYYqXmG5uNrNVazMaoaAhthDweb6oCbCPRagba7KLplIpbZbTPuh L3dQ== X-Gm-Message-State: ALKqPwc1PKmJlo+t2wmwqWzSb6oOnNqkBr8zP2DTV7kktnvSbiaE5ypG SpxxLUqBQh7AA9Yn266Mbnwlf03Qejw= X-Received: by 2002:a65:53ca:: with SMTP id z10-v6mr7727398pgr.413.1526335980058; Mon, 14 May 2018 15:13:00 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:19 -0700 Message-Id: <20180514221219.7091-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v5 28/28] fpu/softfloat: Define floatN_silence_nan in terms of parts_silence_nan 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Isolate the target-specific choice to 3 functions instead of 6. The code in floatx80_default_nan tried to be over-general. There are only two targets that support this format: x86 and m68k. Thus there is no point in inventing a mechanism for snan_bit_is_one. Move routines that no longer have ifdefs out of softfloat-specialize.h. Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 81 ++------------------------------------ fpu/softfloat.c | 19 +++++++++ 2 files changed, 23 insertions(+), 77 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index ec4fb6ba8b..16c0bcb6fa 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -278,24 +278,6 @@ int float16_is_signaling_nan(float16 a_, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN from a signalling NaN for the half-precision -| floating point value `a'. -*----------------------------------------------------------------------------*/ - -float16 float16_silence_nan(float16 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { - return float16_default_nan(status); - } else { - return a | (1 << 9); - } -#endif -} - /*---------------------------------------------------------------------------- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -334,30 +316,6 @@ int float32_is_signaling_nan(float32 a_, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN from a signalling NaN for the single-precision -| floating point value `a'. -*----------------------------------------------------------------------------*/ - -float32 float32_silence_nan(float32 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { -# ifdef TARGET_HPPA - a &= ~0x00400000; - a |= 0x00200000; - return a; -# else - return float32_default_nan(status); -# endif - } else { - return a | (1 << 22); - } -#endif -} - /*---------------------------------------------------------------------------- | Returns the result of converting the single-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid @@ -706,31 +664,6 @@ int float64_is_signaling_nan(float64 a_, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN from a signalling NaN for the double-precision -| floating point value `a'. -*----------------------------------------------------------------------------*/ - -float64 float64_silence_nan(float64 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { -# ifdef TARGET_HPPA - a &= ~0x0008000000000000ULL; - a |= 0x0004000000000000ULL; - return a; -# else - return float64_default_nan(status); -# endif - } else { - return a | LIT64(0x0008000000000000); - } -#endif -} - - /*---------------------------------------------------------------------------- | Returns the result of converting the double-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid @@ -886,16 +819,10 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) floatx80 floatx80_silence_nan(floatx80 a, float_status *status) { -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { - return floatx80_default_nan(status); - } else { - a.low |= LIT64(0xC000000000000000); - return a; - } -#endif + /* None of the targets that have snan_bit_is_one use floatx80. */ + assert(!snan_bit_is_one(status)); + a.low |= LIT64(0xC000000000000000); + return a; } /*---------------------------------------------------------------------------- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index b5842f7b1c..40b039ee5b 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2128,6 +2128,25 @@ float128 float128_default_nan(float_status *status) return r; } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the floating point value `a'. +*----------------------------------------------------------------------------*/ + +float16 float16_silence_nan(float16 a, float_status *status) +{ + return float16_pack_raw(parts_silence_nan(float16_unpack_raw(a), status)); +} + +float32 float32_silence_nan(float32 a, float_status *status) +{ + return float32_pack_raw(parts_silence_nan(float32_unpack_raw(a), status)); +} + +float64 float64_silence_nan(float64 a, float_status *status) +{ + return float64_pack_raw(parts_silence_nan(float64_unpack_raw(a), status)); +} + /*---------------------------------------------------------------------------- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 | and 7, and returns the properly rounded 32-bit integer corresponding to the