From patchwork Fri Feb 22 20:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159079 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2188051jaa; Fri, 22 Feb 2019 13:01:23 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia+1pxbyLs+bEbuzRS1gwZ3ZtkQklG0VF8vKoY0pe4e1D3yuLPkzXt7iAmdISb6YtLPDqZI X-Received: by 2002:a25:2d43:: with SMTP id s3mr5244465ybe.67.1550869283211; Fri, 22 Feb 2019 13:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550869283; cv=none; d=google.com; s=arc-20160816; b=ruAmTqL5zf4FSWOgWo89FzqXEHi9pyhp+LCHtaMjtQKPxzOcOeZ3UOnUigagozAerV 9sPUovZ67VHdgeLARvFvzKrUtIxU9oPzNPaimNAB6xC3DydHVKCaXbk85k2kLSfED71r U/kLe9kTG2qKbaU/ewee68kvh0s1ycud7jxxaL9S34gRuIc9NPxSZByBAaqQVUxMtBVW Tn6utwubonqUuM/BuQpLsXEaZ4oUOZZEn9Jq5KolDQ1cIkyO8KZhM8EPdrxfOoom7pz+ bjIx6QJOufYM7yKygl3qfMcRoBEL0GEAguuHw1ko/AYsGWsan+8xqpTeK/3o5IkIc+2v 3Dhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=kYAXsuLgDRoQZZBEVPpoAgxZdoO5asAwCUtHutk2yoc=; b=SowT08cD/BYGENGpToxqzHpcYc/NqnASPXErgFDkkyNRh2U+CGxv0qjvvXbruoVAzO iCfQvH1cGa9k2xON+BMEs3ltQyRXVvfexoOBIplLxjlD6Z2nghLPUixLdaOv9BEYk6f+ EjzFb9yvtt0cbLwqwX9B63knH57evN2DUkoWN1FZhthXnr/ozggQtkIvAmxpBkmkXU1D xZZFMsAUvRS8nVD8TQpzaW03UaFV6NiA3Bz2s5VyyFNH1XlVXsVK64+vM7UtV7nnUxHs +A58e2VCHk4MyoO7hMcc5Cn7ARs0waXBg2pOnJGQjuwiv80srvzF1vz/tnbptCMlQ8mh os/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TDIinfmG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 187si1499485ybq.104.2019.02.22.13.01.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 13:01:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TDIinfmG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHwg-0006V6-Mc for patch@linaro.org; Fri, 22 Feb 2019 16:01:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHrr-00035y-W3 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgt-0006qL-Hu for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:04 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgt-0006op-5p for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:03 -0500 Received: by mail-wr1-x442.google.com with SMTP id f14so3784704wrg.1 for ; Fri, 22 Feb 2019 12:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kYAXsuLgDRoQZZBEVPpoAgxZdoO5asAwCUtHutk2yoc=; b=TDIinfmGaqLr53U/D7U2z1giUr3y2GWmK2NiTt49bn/KMBu9On8dK4cBtUR+TLjmSO wx/FgQeQ/FfGRRPCSsB0wMQV2zbqOtp8pdSIGIejWtHAaHt5VqOnLFb8IX9GEmyWk+qR T0Ry4lFl8HcBK0XR2SG+Cvfz08rsMAcFdtTKFI9Enfb416iQHngDqRwilDviH/i4/Est 2x0XFvIzd6xYKSOlTuo80FrIAEoLAfo9kFlwKTq/l59ZaymKfUfNVYUQd7kmLybJYhTS g1HR2f47wSbTe/T1A2tMqs8kQBSr+JfVSH/h4Rq9d47gHpZHik7fSfKzg1QFgcL8YM1F DIwg== 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=kYAXsuLgDRoQZZBEVPpoAgxZdoO5asAwCUtHutk2yoc=; b=taLEbAxcwb6VQ4FoFH7+E5+/2dPyDWqEuedh+ZvgZq70kbwX/QASGkTQnXQZxp9nh9 u6mbmyoVSDYaaL6j1lBGdCHXkEBldnC6swH6mBoRjWj4hIhZDmwuXvvKPmmCvOVDddyb rzibI3tgxt08huBmHm+xsevftl2/fqAnud25S+r72RnABsRy9S6JdLtYddOpXYq60A0S q7aVwdf8V9nUlhcUxYxAM3KuMY+vDHmg9bb1AJuzXsXavND6lh54KJ85Dw1WJ2nzF2/b blFvvMxL9TvDz1Gblhy2ZXFvUYb5a/H9vZu3LRy702fDjWP8KXt/JW8KuNz21SEdKY3I u02g== X-Gm-Message-State: AHQUAuZ6ZMJDOd+5SZ/NkJ10kCbJ/DA3PNwaOn3x4+jRDKDHDtKl4Y3K tl8QxM59DELbukhJkEii5rZssQ== X-Received: by 2002:a5d:540f:: with SMTP id g15mr4565819wrv.126.1550868302004; Fri, 22 Feb 2019 12:45:02 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h13sm1892486wrs.42.2019.02.22.12.45.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:00 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7FA2A1FF82; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:44:55 +0000 Message-Id: <20190222204500.24434-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v1 1/6] tests: Ignore fp test outputs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-s390x@nongnu.org, "Emilio G . Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Commit 2cade3d wired up new tests, but did not exclude the new *.out files produced by running the tests. Signed-off-by: Eric Blake Reviewed-by: Emilio G. Cota Signed-off-by: Alex Bennée --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 diff --git a/tests/.gitignore b/tests/.gitignore index 72c18aaab0..f2bf85c8c4 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -5,6 +5,7 @@ benchmark-crypto-hmac check-* !check-*.c !check-*.sh +fp/*.out qht-bench rcutorture test-* From patchwork Fri Feb 22 20:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159081 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2189949jaa; Fri, 22 Feb 2019 13:03:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IbPxb/W5m+PRywlpqlRQvL/H6xNUh4CHt+Ym/2QGgVblCR2/59RKJGmmri7O7LioLpwDWbM X-Received: by 2002:a81:71c5:: with SMTP id m188mr5046549ywc.353.1550869391498; Fri, 22 Feb 2019 13:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550869391; cv=none; d=google.com; s=arc-20160816; b=nor1FuHw8F6FZFaW6osxmZc0EEWrz/SYJm7phH9eVYw331fBcbilWEW3v4F9AAIH4J coRNJXWmA6ElhIy8ymKYus5IJVljY9wH/ywKG11EDXOwLwkBLxXw2HEHT7PjWesYj8Yt Wpc+ZBEsMre2fQZKBI4+prcam5MTLHBAqvIVOCwo3XuvfG71OzCQttSlAWQ9B2ktLKVU myYiwHtNTygOSIU/I+bf2n5K1H44INquR4g+Gsh+OB+R2k0Cp7WY0F/t16Dl219MC5rW Um/kYHv70wDLHadY8wtEudIa2QNBjZCK1/RTp1QxKXRBPUzdGm5Jj2R47/78yYJEp0O+ wWxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=QX9vHdvwnrQQIzWiNBjC4sjIDTbes6ab8cLrV+4UWjE=; b=rwzba86F04El58aptm6TEYKQKoYCh+MRZ1OigZ/KXmC/dfujujlBH6awaHph62Gy8n D3a+eYvyACWcatbwNI5lGTyjcl/h5HhVtIVGMke1qjQXi5AhVUN1euYUHqvOT2QZP8Ot gi56ix6VHlu5cxDAIodfGuB09Z6T/Ifr2/iozLJCF2hM3sIXXNvay3e7oP9kb4xorRbW bwdLRGXCZMdSPcCJ0X2PbC/Pq4w1SUeUvbLS5fONt8wEKyHCyBX5Q3AN/CgzIcTZG/sb ZffuzFAVGR5nyigNorIGZVaZCWbA9thEHel3tqvn2o/pjJGtghbGVc9s9qgPrkev+fez lFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aeqSN+qU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v3si1526757ybc.35.2019.02.22.13.03.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 13:03:11 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aeqSN+qU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHyR-0008Rk-4i for patch@linaro.org; Fri, 22 Feb 2019 16:03:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHrl-00035y-3m for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgu-0006rf-B7 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:05 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46007) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgu-0006q7-0I for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:04 -0500 Received: by mail-wr1-x442.google.com with SMTP id w17so3717702wrn.12 for ; Fri, 22 Feb 2019 12:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QX9vHdvwnrQQIzWiNBjC4sjIDTbes6ab8cLrV+4UWjE=; b=aeqSN+qUQ6/xXRZWAc7MMqxYQxQ4U4ENwIhvqQfC17B5SOGqNqWY780HKOFKtubUlT pI0KtCJ72NnCM5ynsumxoPU6aX3R2eosRl0D0nioUpe8Np0z6BQMeqhD0fM8oTYJO+uX XrwscjXhdxZ4DizCohxGnzAjlyOAsTeh3BbZ2KmAiNp5semM/D99T+nMDCGWJ5xym//Z CBS5AC5asCggG6JHwGPN3PFAAM0XKf0Mqjh9LaAlqesdgUMAUkxx5UM8o9LaMQc0eslq Vf1amoAWgkJYBnBPmUgVFOMZqduGx0XY391ngaTjXO3jbgkZGIlrD/0iJfGI7oqneRMn S/TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QX9vHdvwnrQQIzWiNBjC4sjIDTbes6ab8cLrV+4UWjE=; b=CendGVMWCewCRv2f8FWK+swAhK6110yOsLM7J6iBuzLIeTl1LNSMsxiq7UmrSzWXtN TZhf3XL056vPmu5pz5LUenN8RpxnVgkIFL1AGhlTtZgKX0qoD4BsA0zxcGiEgLZ+3TSz 1OwK/aLhFIyw9SZOLLxV1atN3fAi/51K/3o0VxSVCL/KlD8GdemkLspmgCvHzDSAqWg5 lkM5yo89hQ9CISwjRRNQuNhF+v5MbyhVDN71mb0GOULdg6essNhfwGq085wARw2Umftf fNfSjUrrYqmEtygVKafWkfHwJ98i3HFmLSXXA2r004Cvsn90K+PWKVJaEQv/DtsvMmJ9 BnlQ== X-Gm-Message-State: AHQUAuaoQbyfNThR31mgz2OJxp0m0P6Wyollq+VZJKwqYrdUG8NFRPbV jcitSz8tNVwDlZSJ7YHqyJ82lQ== X-Received: by 2002:adf:f9c4:: with SMTP id w4mr4447894wrr.218.1550868302887; Fri, 22 Feb 2019 12:45:02 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j15sm2559894wrt.1.2019.02.22.12.45.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:00 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8B5F11FF83; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:44:56 +0000 Message-Id: <20190222204500.24434-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v1 2/6] softfloat: add float128_is_{normal, denormal} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-s390x@nongnu.org, Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Needed on s390x, to test for the data class of a number. So it will gain soon a user. A number is considered normal if the exponent is neither 0 nor all 1's. That can be checked by adding 1 to the exponent, and comparing against >= 2 after dropping an eventual overflow into the sign bit. While at it, convert the other floatXX_is_normal functions to use a similar, less error prone calculation, as suggested by Richard H. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- include/fpu/softfloat.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 38a5e99cf3..3ff5215b81 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -466,7 +466,7 @@ static inline int float32_is_zero_or_denormal(float32 a) static inline bool float32_is_normal(float32 a) { - return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000; + return (((float32_val(a) >> 23) + 1) & 0xff) >= 2; } static inline bool float32_is_denormal(float32 a) @@ -622,7 +622,7 @@ static inline int float64_is_zero_or_denormal(float64 a) static inline bool float64_is_normal(float64 a) { - return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53; + return (((float64_val(a) >> 52) + 1) & 0x7ff) >= 2; } static inline bool float64_is_denormal(float64 a) @@ -940,6 +940,16 @@ static inline int float128_is_zero_or_denormal(float128 a) return (a.high & 0x7fff000000000000LL) == 0; } +static inline bool float128_is_normal(float128 a) +{ + return (((a.high >> 48) + 1) & 0x7fff) >= 2; +} + +static inline bool float128_is_denormal(float128 a) +{ + return float128_is_zero_or_denormal(a) && !float128_is_zero(a); +} + static inline int float128_is_any_nan(float128 a) { return ((a.high >> 48) & 0x7fff) == 0x7fff && From patchwork Fri Feb 22 20:44:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159077 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2185959jaa; Fri, 22 Feb 2019 12:59:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IZCYX36hiZlT7QlSTvPVjCRYLJqF6M6TO5Q3rxAfLOiWAnPhJB2D1rleIWBi00pfPOGIE5K X-Received: by 2002:a81:3642:: with SMTP id d63mr5005603ywa.148.1550869153953; Fri, 22 Feb 2019 12:59:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550869153; cv=none; d=google.com; s=arc-20160816; b=W+nmQelbd20Szfbcl0i7wM6JJleaw2l/LV6o1DkLnTO5GACYiwjbpSIo2mUkPW60qd f65KgtPB6/V8Gcd7AjbVlogGMVjbZLtZm422AdzSl1bLDhqrO237wbDsdR7n7Y5U5cFA p6uiHvzQlQDS7F7yICWU/R4AvuwE53sxsdnw8P/XXEKtWpKsclq76KLdEiCKdCwD6JCD 2mL6/1Oh/XC7mdqzm/ZpJIM2De/jcOBWO4ss6eEq+aJrRqml0E2z3RnsVFC2Qj1fK9Fy Y0Df6vf9X6YcpjvpwGfM0d5guvvjbs/bl7963HrBfL1e1oQCbcAKvCEi/GkCGOexM6jA x0mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=PH41D0K99rFgQCuzKch0t4SrvJqgrHW/zgeCIlULUOo=; b=lVhbN3iENXt5Zurx8Dlf5w3wkcx2x2gGVwJ3bw6z/bEHnyivQJ75vWVzCKkOJaWEGt f0sK/TO/QK7I4MikXEJeXcBEtGtirlM6RBsiMZtje7hNTA54YwxZirLSnNXEu9y8px89 zfEjPOY4xG0pv9pNECrSNtALGEbVbn3buem7q1+//o7emB+GZdyEuWyqYbNxXL6yV6sb rlK1gaWQ09CXmunYMehbMJMVPNP112Luf1cdE8gIvJmXu8cbEGffVjnUdBCKUBXu/kHi SPE7XctkzTX0mM9Kvmw+FuOXNnVREGtyFXhKlfSGvf4aPBHlHkk6VGncHyWz9/EMJ9vo l0Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=U3iVtHo8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q81si1618476ybq.377.2019.02.22.12.59.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 12:59:13 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=U3iVtHo8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHub-0005gD-4O for patch@linaro.org; Fri, 22 Feb 2019 15:59:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHrc-0003Fi-Th for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgv-0006tC-Jo for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:06 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:54591) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgv-0006sF-Bj for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:05 -0500 Received: by mail-wm1-x344.google.com with SMTP id a62so3111595wmh.4 for ; Fri, 22 Feb 2019 12:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PH41D0K99rFgQCuzKch0t4SrvJqgrHW/zgeCIlULUOo=; b=U3iVtHo8cpwt0ZYYZey9VHSBxz+aOcFA5+zVp7K6xs4PGigVvGWvOwh907iqcs3WLQ Jl8WLFRD4Uvk5PUm5bCuUHmo6sB4cDXc/TLAuf3Y+vISUG7817sRdK76GYZxGXY1W0ET vm3IA/JCfwsOl5zEuFAhvViotS29w17yUSGGzy9tbN+Wx84b9AYrbPNjHtnJL4EuoOIT NHEu2NgHTZSUyP1m3RiJZjA9Ju306J9J2IgtukWpYqkdwEpq8lMIYr8jus4u16GlrMTc YNKGayV9TyYhgPqp35CprY0jrBiBcFbzAc6hb0G0DqjnCr0JRrfcLZxdTiBZw21mcqdh V+8g== 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=PH41D0K99rFgQCuzKch0t4SrvJqgrHW/zgeCIlULUOo=; b=phII/5r6oIGooKKrSB5IAvRq//EzNnUs/IGdcEoq0L9K9JHze4jYm2kBzCIBOM2KPn oNLLBLCYKEca2uKGGIHYTg+g/ZlvfgaOjxFm/k1QOmG5TaLNuYsFu3ewrKri+K2sDuqE JvCoPBFZT6Him0BthQgUT5Up91Sy1M4TZ4yIUt5jpOeFAyScytBeiIPOnOcvkk83ZawX 53KZycH2sleqC2OrbuVGjlshQnJKd/G9fPhUcz7qukKmNwPcAFpX/DouH98lR+b7lgUC zpcKaALLj1g2dK1BVQ6IGAaiOFhl1aazT8d2lToGeN7YSQd6dhSPQQWZTs97ckRAxMQW 5iIA== X-Gm-Message-State: AHQUAuYjGo5oQfZ4mDmAWCV0ssYqnlRn3cSHV8aG8Bg9xZQrPsCXVPJc Jzk61FJZlKhKuZR+kTWeGw1mbg== X-Received: by 2002:a7b:cc18:: with SMTP id f24mr3871535wmh.42.1550868304351; Fri, 22 Feb 2019 12:45:04 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r70sm1451052wme.46.2019.02.22.12.45.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:02 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 971B81FF86; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:44:57 +0000 Message-Id: <20190222204500.24434-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v1 3/6] softfloat: Implement float128_to_uint32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-s390x@nongnu.org, Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Handling it just like float128_to_uint32_round_to_zero, that hopefully is free of bugs :) Documentation basically copied from float128_to_uint64 Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- fpu/softfloat.c | 29 +++++++++++++++++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 30 insertions(+) -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 9132d7a0b0..c69cd6b5d1 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -6792,6 +6792,35 @@ uint32_t float128_to_uint32_round_to_zero(float128 a, float_status *status) return res; } +/*---------------------------------------------------------------------------- +| Returns the result of converting the quadruple-precision floating-point value +| `a' to the 32-bit unsigned integer format. The conversion is +| performed according to the IEC/IEEE Standard for Binary Floating-Point +| Arithmetic---which means in particular that the conversion is rounded +| according to the current rounding mode. If `a' is a NaN, the largest +| positive integer is returned. If the conversion overflows, the +| largest unsigned integer is returned. If 'a' is negative, the value is +| rounded and zero is returned; negative values that do not round to zero +| will raise the inexact exception. +*----------------------------------------------------------------------------*/ + +uint32_t float128_to_uint32(float128 a, float_status *status) +{ + uint64_t v; + uint32_t res; + int old_exc_flags = get_float_exception_flags(status); + + v = float128_to_uint64(a, status); + if (v > 0xffffffff) { + res = 0xffffffff; + } else { + return v; + } + set_float_exception_flags(old_exc_flags, status); + float_raise(float_flag_invalid, status); + return res; +} + /*---------------------------------------------------------------------------- | Returns the result of converting the quadruple-precision floating-point | value `a' to the single-precision floating-point format. The conversion diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 3ff5215b81..3ff3fa5224 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -878,6 +878,7 @@ int64_t float128_to_int64(float128, float_status *status); int64_t float128_to_int64_round_to_zero(float128, float_status *status); uint64_t float128_to_uint64(float128, float_status *status); uint64_t float128_to_uint64_round_to_zero(float128, float_status *status); +uint32_t float128_to_uint32(float128, float_status *status); uint32_t float128_to_uint32_round_to_zero(float128, float_status *status); float32 float128_to_float32(float128, float_status *status); float64 float128_to_float64(float128, float_status *status); From patchwork Fri Feb 22 20:44:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159080 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2188507jaa; Fri, 22 Feb 2019 13:01:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IYqdvpgFkBsWEu9ZoZcNuobCy63Buw2ZevzxaI1HZBqi2xUDYIi5rS40En561Pd6ZqVf+IL X-Received: by 2002:a25:4f04:: with SMTP id d4mr5373006ybb.138.1550869309448; Fri, 22 Feb 2019 13:01:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550869309; cv=none; d=google.com; s=arc-20160816; b=jQGtH+bSKIRHNe5fC8kNYEtvAlRfI8I/InxcE+zbT0mEQgWIh7dleyjj3DzMUiomoO iZt5T3thXwtMlAZxoSzpWLY4Sv6uIshPRUUInKMF1utF3/L2MhXtob2j5sQ+AyUuHApi PcWuZmOkDqfthcgyXTiu9SiKWF8QlKmAlkGG019d0jcVvm7bAdfIYgqdqUiMhizS53Ap OP/ugpWwANtAS+5/n6UT7u/ZK74Xy60vHqa9dDFZVTqdOa1EqhRDuGYlsAKMn74fPZWd 8wB8AVa9njmE7MGduWgMJ422EPYms0iIEtgOzOKwrw93DMN5E+M2ulVrNMxMThAu/Wc5 LQkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7H5qrKyPnUHzhUw0KCPZrtdEbkrKMyIV+FaO4FKGkUU=; b=JPjvRUGGRKc/kpfbVuUXDQRXJrRvUpV4+L3StlUJSzqKe2eNd+t4AFa86SM7t+EcFT Er6JcjLpzPSU6w1yeKf05uIwelGv9O0nxH53JVQLMxTDKuAfPVIho83EvpvIpDeOTPC0 UWSYVLbNCLuv5dWdUwGXGjzFBfodTT9DExoUpAuuQF64eHEaDkQRyt3ta14Wl4rL3uyx xdheD1ORognt81/ty/MX8EP3YikJ7csFm9fTlEtkR2sMkqXmnTS3r5raPK8YGRtusEZr cySQpoDq1FmIFYiblzboaKMbNFrME/i2XZ244bJm4Hr+WLOOtl/MxJMFL6SIxK9IllCS AWNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XYxVRzQj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p9si1661389ybm.28.2019.02.22.13.01.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 13:01:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XYxVRzQj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHx7-0007ma-2L for patch@linaro.org; Fri, 22 Feb 2019 16:01:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHrf-0003HB-Vu for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgv-0006sd-1x for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:05 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgu-0006rN-Po for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:04 -0500 Received: by mail-wm1-x341.google.com with SMTP id j125so3123907wmj.1 for ; Fri, 22 Feb 2019 12:45:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7H5qrKyPnUHzhUw0KCPZrtdEbkrKMyIV+FaO4FKGkUU=; b=XYxVRzQjVYaGXW3mwHuwdt/Tt7hLxdYxrDb0dyZZxXnaEC3kslTRFxSMr7phb/0j6w eejReXPly/rXmzcCAVpok/vZ7mUMypPkq9AfOZ+DXfsQkiL+jHOc26IayKjTyKfW/SNS QcMJmHi6Q62Cgswr7WiWg4Ffio3ul+6OiqUGV2BbOKRZNuWhbpX+6/LVk4ZL1tTLOUil HcgcCYyRak+n07K1Yqx3KsVEIZn1QzL44NyZCuR2k/ls9Zx1rBSIi7e6Fi6tMfIyRf4/ Gz+A0EDSH7oWZINsBtP9qIdeYXZKsXC2AANk/o5w6lbcufQdo4fAY6qfN4yGhA78UXbq D0Rw== 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=7H5qrKyPnUHzhUw0KCPZrtdEbkrKMyIV+FaO4FKGkUU=; b=mY0DjzMUNQH2lsULCsx9/K9vE49MHMnGYmtdcOr2WEROqoCzxlImm7BV8bMo9wLgGS 7geolb1KFUdCVN6Yx0EPZ/0hhK0Tb5V1qvGhYbYBjng/HtaCABcSHL7VWaZxwxTb10ft kJpzKR1OX0Ag73Hf9xhPnIYk/TNa4GWB1XiCqx4ng0/zPAwWfNKbQaesPMozn80ADrEQ zG3L3ldbjScWX2D6TV+5YfC78+SobcVzv7LlfmoGGR9+eNByfvEljb54xj+RS4cwb8vj VoDwL0sDtaTVOGrRa+WsSdugfK+ko9gUp1TJjYNJ0WTvT2ojTfMTH1nD8jv9qQs8wxwT mvuQ== X-Gm-Message-State: AHQUAuaUYXNDcw7T4pjBwmNhj1Ez9C7PV7vaeRcQKoGQk1MDMlHFNBNZ PL9t2L1BBhhRA89lcJf0UJRewWb3gTg= X-Received: by 2002:a1c:a3c3:: with SMTP id m186mr3595538wme.16.1550868303539; Fri, 22 Feb 2019 12:45:03 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d21sm5780168wrc.44.2019.02.22.12.45.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:02 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A28ED1FF87; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:44:58 +0000 Message-Id: <20190222204500.24434-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32 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: qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Needed to test: softfloat: add float128_is_{normal,denormal} Signed-off-by: Alex Bennée --- tests/fp/fp-test.c | 3 ++- tests/fp/wrap.inc.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c index 2a35ef601d..4114f346a9 100644 --- a/tests/fp/fp-test.c +++ b/tests/fp/fp-test.c @@ -622,7 +622,8 @@ static void do_testfloat(int op, int rmode, bool exact) test_ab_extF80_z_bool(true_ab_extF80M_z_bool, subj_ab_extF80M_z_bool); break; case F128_TO_UI32: - not_implemented(); + test_a_f128_z_ui32_rx(slow_f128M_to_ui32, qemu_f128M_to_ui32, rmode, + exact); break; case F128_TO_UI64: test_a_f128_z_ui64_rx(slow_f128M_to_ui64, qemu_f128M_to_ui64, rmode, diff --git a/tests/fp/wrap.inc.c b/tests/fp/wrap.inc.c index d3bf600cd0..0cbd20013e 100644 --- a/tests/fp/wrap.inc.c +++ b/tests/fp/wrap.inc.c @@ -367,6 +367,7 @@ WRAP_80_TO_INT_MINMAG(qemu_extF80M_to_i64_r_minMag, WRAP_128_TO_INT(qemu_f128M_to_i32, float128_to_int32, int_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_i64, float128_to_int64, int_fast64_t) +WRAP_128_TO_INT(qemu_f128M_to_ui32, float128_to_uint32, uint_fast32_t) WRAP_128_TO_INT(qemu_f128M_to_ui64, float128_to_uint64, uint_fast64_t) #undef WRAP_128_TO_INT From patchwork Fri Feb 22 20:44:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159075 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2183946jaa; Fri, 22 Feb 2019 12:56:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IbVPJ04aIR/pEvo26xNR+5xf/QTaH1GP/9csXMMGMQMzgeKy0dOW6Y94ozQKgo7v0Hx3OZE X-Received: by 2002:a81:a786:: with SMTP id e128mr409153ywh.261.1550868996733; Fri, 22 Feb 2019 12:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550868996; cv=none; d=google.com; s=arc-20160816; b=g7C+G0ZGTDX/MVdW6Ebk9fgiZ2bQPD4c9W+z3ay6dJ4aAVWvqQFJc3KvnATMsYUk1X CTNjA+HVyfjdCyosSsgZKUbmIk19TmxDyjSZMhVhbd6QOjs6adfFL8+o6oIL+kkHYQGY RVo9HrXwMmgV+IC4XKcJI5q09AR+LgzIO4zQNvb32CmBiH1jXVjiICWVifGXKiseMlGz rv2Q2JcqFt9cAyd/6jeOwENZV8nqdOGbyUKUtvWAkX+swgo/iGJNFr1zmuhgg50i3BbT Fc5V3ltVyWjMVH/wrMZ0LToqJ6HkCCSeJdYl4VEXC8zhr7lsqEV26NsVI/Fn5JjSx5xu gMNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=KXHtqzyTgzr/IEYjnPpKDEyWD58lU3YNGD6QhuOFRHo=; b=KiEsKUzAQrQhIFjdaXuxKrZs0gzfDaXsW2L9o4ee6kYS9a87qGuTt01Bzq/wRouLbN lqHN40QgOvfEBagyApJQO3zUah/mCNmuaTrd3xc5sdbknO5dSiB5lnD6T7NVoQtjRBIP YwU2Tipooik3zMnylCILzqrllEl/zhR7vtEii75YcFHSxTc5feG4ZaU7HqOyYx+ry02C ad2+VrFM3ibKEdy0c493LeJLkbqTdv6fALnb/mJLB9PJuD/UKTTKvGd7zIiAr9kI5j1f q3+Z2M4t6WlCE1Q+fLrYrM1oeRFGF4VJfhGFHacmnHP6xnekgQUt06e5XOocAOiV+vrg C0cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZlvJdwen; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k9si1488278ybp.41.2019.02.22.12.56.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 12:56:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZlvJdwen; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHs4-0003UM-6c for patch@linaro.org; Fri, 22 Feb 2019 15:56:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHra-0003HB-MU for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgx-0006vP-M7 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:08 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgx-0006u8-19 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:07 -0500 Received: by mail-wr1-x443.google.com with SMTP id d17so3725638wre.10 for ; Fri, 22 Feb 2019 12:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KXHtqzyTgzr/IEYjnPpKDEyWD58lU3YNGD6QhuOFRHo=; b=ZlvJdwenGPxULpPXPHiot5mA6q1JkKhHgseQJeCpaH8pQ6BSaZHPr7oVyoB0lL1vE9 MHWpBqvYdxnCTnT8ARLdk+GczIQKlRJSv6uRa+sRbmweEWqQarSBA2VXHxqftX5/3Q/g wSHRmFN9C+gGvi2eeQWYnd8vc2d+SE5U+CRElMO3ovyTLkbJZ27iCZsOOPGA64AQizqr kRzMdGOoLZWge7dZhOXtWoqjy8DT4I1aYXPiKciDJ7bIti2R4jQjNj7lTHp0Ejmk5CwE 6g+vlV5sO3uuSd2xqPs74IG3xpmJ7IiVeA4KR6Nq7VHJA9kGfFsTTiEjIKQ86KoQlaWf hygg== 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=KXHtqzyTgzr/IEYjnPpKDEyWD58lU3YNGD6QhuOFRHo=; b=lvjfQehPwVZ/jdTsiPtwtFGCitKVC7rFCYa0n5ne1sJOl2BzQpjNTw+qHRv7za6T53 jt2NbIuZXdda7v2lNTan5H3WvizbigkeK1VBTsYKJl597KkSz9VZhwHbui3bkfmuFUgp rQNJ8Jp5tLX8LbXOSFbOYf1TRGuxjbjlgvXpWff/JPNzwB7n6ZVy495u8UwLGYGLBVPb pDTgLshF6NJUv/GAzRDYOFXM/YR17z2r0RJJtO6XQYX+ca5SawdHXTgxrr0bRmISC5uU 0O5ElFNh/Wm9pC/ChpV5Xrf6tCI6aWNZGrcdASq+/HNbi2GUOH6ZQACAva6CiwNW0gvO cgmg== X-Gm-Message-State: AHQUAuaynqxCFbFMq62dw1a2ZNAtTFuPZjxLHxlNB6N02Jt4f//iHOgb KrXGqJFuNtaFyl5nfqQ2IWNd11cOvGc= X-Received: by 2002:a5d:6446:: with SMTP id d6mr3605844wrw.72.1550868306088; Fri, 22 Feb 2019 12:45:06 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h126sm2021166wmf.2.2019.02.22.12.45.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:02 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE5831FF88; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:44:59 +0000 Message-Id: <20190222204500.24434-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint 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: qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We've just added f128_to_ui32 and we missed out the f128_to_ui64 tests last time. Signed-off-by: Alex Bennée --- tests/Makefile.include | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson diff --git a/tests/Makefile.include b/tests/Makefile.include index 3741f8f6dd..060f765b0e 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -909,8 +909,7 @@ test-softfloat = $(call quiet-command, \ # Conversion Routines: # FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken) -# ui32_to_f128 (not implemented), f128_to_ui32 (not implemented) -# extF80_roundToInt (broken) +# ui32_to_f128 (not implemented), extF80_roundToInt (broken) # check-softfloat-conv: $(FP_TEST_BIN) $(call test-softfloat, \ @@ -939,9 +938,11 @@ check-softfloat-conv: $(FP_TEST_BIN) f16_to_ui32 f16_to_ui32_r_minMag \ f32_to_ui32 f32_to_ui32_r_minMag \ f64_to_ui32 f64_to_ui32_r_minMag \ + f128_to_ui32 f128_to_ui32_r_minMag \ f16_to_ui64 f16_to_ui64_r_minMag \ f32_to_ui64 f32_to_ui64_r_minMag \ - f64_to_ui64 f64_to_ui64_r_minMag, \ + f64_to_ui64 f64_to_ui64_r_minMag \ + f128_to_ui64 f128_to_ui64_r_minMag, \ float-to-uint) $(call test-softfloat, \ f16_roundToInt f32_roundToInt \ From patchwork Fri Feb 22 20:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 159076 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2183969jaa; Fri, 22 Feb 2019 12:56:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IYeVQDfGiyFFz+qE65H+Wf0cxgDeWC6wILySiRL2g312cmzdEhcp3bvlrljAe2RmC067LxK X-Received: by 2002:a81:388a:: with SMTP id f132mr4771259ywa.98.1550868998715; Fri, 22 Feb 2019 12:56:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550868998; cv=none; d=google.com; s=arc-20160816; b=aGpCJoOwImdQBG2EHv3p3MrtVzNeVLeI0M+XYzA2ZOWFpeo0YHv64fkXKnmBj79J2Z iHmJSZqobGGxjsDiQGwPDD6hNLN10evXUHPh5FyvKaal+5iGfKF8O219C33gkc1V6Noh pzKWSdf8tzaRr+xYNrp5bRBnaJWL+EI6U2Qmv6HyRqIcPD6Bilc2UD34BpGQCVHa6/eT m9AGaoIRE8mD+x2HEGZEz4HupA5UKgsSHjlttOlAiN3HCJ2DkC0EVZa4KQEXW1SQdA9q QhKKMoOqcHzhZFmX9DO3bMw/JcM9eGv7Q4n2UTwTpq1s64EPnHcuxkr/kLXVPfVX5qpn 7CTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Yzy7H0G0WI09NToG/3M3PGsN3ZzXzNj17W3uLaSVmn8=; b=Y4b/6pj/a7CXBecvsVnsvbdvxBgXA30XjCcsASmCRgYtg/LFOaP0n4h8tN3ZPLxd40 YlP/kp1pKi0Gotr6Wei8OI1BYF5ApqbI9KJz/K0DbQJw3ZdyMbAlZSw4b6EgxhjYPouR TpxhMcc+xfmISuXkI9UP8UtITMSrlFE2ItcOSbBktooqFU3GqkeJFIJNko8H2R0H7BqD zvN1eNX11+KtK3NQctqyyU981G60zFlQJuA7l7V2nc8fJ4iSUdX3C04saElIH6vh8r2g vbw3iHwTWUJIANtHrPCcepW3SodEe1VHZRUwVZA7ClCnWkBE1We+6tGuOO0u1Hkicc8S kaBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TTW8adxK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p184si1558133ywd.141.2019.02.22.12.56.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Feb 2019 12:56:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TTW8adxK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:56777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHs6-0003W4-55 for patch@linaro.org; Fri, 22 Feb 2019 15:56:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxHra-00035y-NE for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:56:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxHgw-0006uU-O0 for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:07 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:46009) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxHgw-0006tR-FU for qemu-devel@nongnu.org; Fri, 22 Feb 2019 15:45:06 -0500 Received: by mail-wr1-x444.google.com with SMTP id w17so3717774wrn.12 for ; Fri, 22 Feb 2019 12:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yzy7H0G0WI09NToG/3M3PGsN3ZzXzNj17W3uLaSVmn8=; b=TTW8adxKnR8a0Bp1JszQ2R4sCzVra12LpI/YHx7rXEdU/EudNZtKEAZ5uRHrLAD5hh ZIRUv6A+0P62a82KSnw+fGh5m7swM9YkS1BFZtkhxdcsAu5GLwh4ywSBoBvzWN3mFoSg 0N+blZBn/TkYvUupdnEfjj/mWujz8tifkkjTLA47g1o+Uii3GHksve0/8au8QvBnq6hE stME2Sxv1KRqyxUDE1nnRQPt/hoq4XfDCfVvoYU4aqgvibYDcsbWfVoJ0wa2L+0Sii/N IQLG2if/xF5xNRyeBjzgVtPnoh3EJSIsHO6121SC1FvQoSfIiiG19voN5iZY+cW1Ndqs GpSA== 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=Yzy7H0G0WI09NToG/3M3PGsN3ZzXzNj17W3uLaSVmn8=; b=dlIOv5M9D8KeMpK9E5WYW0pNbkJF2U2rbFpGiE9MJss1p/XtpwwhApq9ZS4tQIrMvB xSWpsqPtiqX8Qu8A1brJVZEerf8/wSK8pUQXsPHNzln1esD8a9pisWBux43Nh8Bdmfz6 //hFDrO53b1H9gUG7w0VcD401uymBm3uF2pnl3Oof7YEqiZ3laR9j0dGB4PR2I3EoWkU veSeQOv3J5gJphxX04xV+PZfDG0ie7u/6FbmL9diCKGeMKpl9vRhDRVVniNelnXErd/f 4Lg0fP/FREbkk/qU9T15XneKK/xrCXcPZ3XnvvWJCGdt/+AuaAgiiu7+Ld4/n6PGnPgN QobA== X-Gm-Message-State: AHQUAubUS+OyPzRYHCK9E/whOvF8OwlYB/Mq2YxyzUsxbWf/CmwxL5U7 NDk5/CQps7JxEpobWZSTdzwa+Q== X-Received: by 2002:a05:6000:1152:: with SMTP id d18mr4481308wrx.128.1550868305153; Fri, 22 Feb 2019 12:45:05 -0800 (PST) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id v20sm1730953wmj.2.2019.02.22.12.45.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 12:45:02 -0800 (PST) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BA55E1FF89; Fri, 22 Feb 2019 20:45:00 +0000 (UTC) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 20:45:00 +0000 Message-Id: <20190222204500.24434-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222204500.24434-1-alex.bennee@linaro.org> References: <20190222204500.24434-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-s390x@nongnu.org, Richard Henderson , David Hildenbrand Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Previously this was only supported for roundAndPackFloat64. New support in round_canonical, round_to_int, float128_round_to_int, roundAndPackFloat32, roundAndPackInt32, roundAndPackInt64, roundAndPackUint64. This does not include any of the floatx80 routines, as we do not have users for that rounding mode there. Signed-off-by: Richard Henderson Message-Id: <20190215170225.15537-1-richard.henderson@linaro.org> Tested-by: David Hildenbrand Signed-off-by: Alex Bennée --- fpu/softfloat.c | 64 ++++++++++++++++++++++++++++++++++++++++++---- tests/fp/fp-test.c | 43 ++++++++++++++++++++++++------- 2 files changed, 93 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index c69cd6b5d1..99c7cc2c3d 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -696,6 +696,7 @@ static FloatParts sf_canonicalize(FloatParts part, const FloatFmt *parm, static FloatParts round_canonical(FloatParts p, float_status *s, const FloatFmt *parm) { + const uint64_t frac_lsb = parm->frac_lsb; const uint64_t frac_lsbm1 = parm->frac_lsbm1; const uint64_t round_mask = parm->round_mask; const uint64_t roundeven_mask = parm->roundeven_mask; @@ -731,6 +732,10 @@ static FloatParts round_canonical(FloatParts p, float_status *s, inc = p.sign ? round_mask : 0; overflow_norm = !p.sign; break; + case float_round_to_odd: + overflow_norm = true; + inc = frac & frac_lsb ? 0 : round_mask; + break; default: g_assert_not_reached(); } @@ -778,9 +783,14 @@ static FloatParts round_canonical(FloatParts p, float_status *s, shift64RightJamming(frac, 1 - exp, &frac); if (frac & round_mask) { /* Need to recompute round-to-even. */ - if (s->float_rounding_mode == float_round_nearest_even) { + switch (s->float_rounding_mode) { + case float_round_nearest_even: inc = ((frac & roundeven_mask) != frac_lsbm1 ? frac_lsbm1 : 0); + break; + case float_round_to_odd: + inc = frac & frac_lsb ? 0 : round_mask; + break; } flags |= float_flag_inexact; frac += inc; @@ -1988,6 +1998,9 @@ static FloatParts round_to_int(FloatParts a, int rmode, case float_round_down: one = a.sign; break; + case float_round_to_odd: + one = true; + break; default: g_assert_not_reached(); } @@ -2021,6 +2034,9 @@ static FloatParts round_to_int(FloatParts a, int rmode, case float_round_down: inc = a.sign ? rnd_mask : 0; break; + case float_round_to_odd: + inc = a.frac & frac_lsb ? 0 : rnd_mask; + break; default: g_assert_not_reached(); } @@ -3314,6 +3330,9 @@ static int32_t roundAndPackInt32(flag zSign, uint64_t absZ, float_status *status case float_round_down: roundIncrement = zSign ? 0x7f : 0; break; + case float_round_to_odd: + roundIncrement = absZ & 0x80 ? 0 : 0x7f; + break; default: abort(); } @@ -3368,6 +3387,9 @@ static int64_t roundAndPackInt64(flag zSign, uint64_t absZ0, uint64_t absZ1, case float_round_down: increment = zSign && absZ1; break; + case float_round_to_odd: + increment = !(absZ0 & 1) && absZ1; + break; default: abort(); } @@ -3424,6 +3446,9 @@ static int64_t roundAndPackUint64(flag zSign, uint64_t absZ0, case float_round_down: increment = zSign && absZ1; break; + case float_round_to_odd: + increment = !(absZ0 & 1) && absZ1; + break; default: abort(); } @@ -3526,6 +3551,8 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig, case float_round_down: roundIncrement = zSign ? 0x7f : 0; break; + case float_round_to_odd: + roundIncrement = zSig & 0x80 ? 0 : 0x7f; default: abort(); break; @@ -3536,8 +3563,10 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig, || ( ( zExp == 0xFD ) && ( (int32_t) ( zSig + roundIncrement ) < 0 ) ) ) { + bool overflow_to_inf = roundingMode != float_round_to_odd && + roundIncrement != 0; float_raise(float_flag_overflow | float_flag_inexact, status); - return packFloat32( zSign, 0xFF, - ( roundIncrement == 0 )); + return packFloat32(zSign, 0xFF, -!overflow_to_inf); } if ( zExp < 0 ) { if (status->flush_to_zero) { @@ -3555,6 +3584,13 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig, if (isTiny && roundBits) { float_raise(float_flag_underflow, status); } + if (roundingMode == float_round_to_odd) { + /* + * For round-to-odd case, the roundIncrement depends on + * zSig which just changed. + */ + roundIncrement = zSig & 0x80 ? 0 : 0x7f; + } } } if (roundBits) { @@ -6987,6 +7023,15 @@ float128 float128_round_to_int(float128 a, float_status *status) add128(z.high, z.low, 0, roundBitsMask, &z.high, &z.low); } break; + case float_round_to_odd: + /* + * Note that if lastBitMask == 0, the last bit is the lsb + * of high, and roundBitsMask == -1. + */ + if ((lastBitMask ? z.low & lastBitMask : z.high & 1) == 0) { + add128(z.high, z.low, 0, roundBitsMask, &z.high, &z.low); + } + break; default: abort(); } @@ -6998,7 +7043,7 @@ float128 float128_round_to_int(float128 a, float_status *status) status->float_exception_flags |= float_flag_inexact; aSign = extractFloat128Sign( a ); switch (status->float_rounding_mode) { - case float_round_nearest_even: + case float_round_nearest_even: if ( ( aExp == 0x3FFE ) && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) @@ -7011,14 +7056,17 @@ float128 float128_round_to_int(float128 a, float_status *status) return packFloat128(aSign, 0x3FFF, 0, 0); } break; - case float_round_down: + case float_round_down: return aSign ? packFloat128( 1, 0x3FFF, 0, 0 ) : packFloat128( 0, 0, 0, 0 ); - case float_round_up: + case float_round_up: return aSign ? packFloat128( 1, 0, 0, 0 ) : packFloat128( 0, 0x3FFF, 0, 0 ); + + case float_round_to_odd: + return packFloat128(aSign, 0x3FFF, 0, 0); } return packFloat128( aSign, 0, 0, 0 ); } @@ -7051,6 +7099,12 @@ float128 float128_round_to_int(float128 a, float_status *status) z.high += roundBitsMask; } break; + case float_round_to_odd: + if ((z.high & lastBitMask) == 0) { + z.high |= (a.low != 0); + z.high += roundBitsMask; + } + break; default: abort(); } diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c index 4114f346a9..7d0faf2b47 100644 --- a/tests/fp/fp-test.c +++ b/tests/fp/fp-test.c @@ -125,17 +125,42 @@ static void not_implemented(void) static bool blacklisted(unsigned op, int rmode) { - /* odd has only been implemented for a few 128-bit ops */ + /* odd has not been implemented for any 80-bit ops */ if (rmode == softfloat_round_odd) { switch (op) { - case F128_ADD: - case F128_SUB: - case F128_MUL: - case F128_DIV: - case F128_TO_F64: - case F128_SQRT: - return false; - default: + case EXTF80_TO_UI32: + case EXTF80_TO_UI64: + case EXTF80_TO_I32: + case EXTF80_TO_I64: + case EXTF80_TO_UI32_R_MINMAG: + case EXTF80_TO_UI64_R_MINMAG: + case EXTF80_TO_I32_R_MINMAG: + case EXTF80_TO_I64_R_MINMAG: + case EXTF80_TO_F16: + case EXTF80_TO_F32: + case EXTF80_TO_F64: + case EXTF80_TO_F128: + case EXTF80_ROUNDTOINT: + case EXTF80_ADD: + case EXTF80_SUB: + case EXTF80_MUL: + case EXTF80_DIV: + case EXTF80_REM: + case EXTF80_SQRT: + case EXTF80_EQ: + case EXTF80_LE: + case EXTF80_LT: + case EXTF80_EQ_SIGNALING: + case EXTF80_LE_QUIET: + case EXTF80_LT_QUIET: + case UI32_TO_EXTF80: + case UI64_TO_EXTF80: + case I32_TO_EXTF80: + case I64_TO_EXTF80: + case F16_TO_EXTF80: + case F32_TO_EXTF80: + case F64_TO_EXTF80: + case F128_TO_EXTF80: return true; } }