From nobody Tue Oct 28 02:06:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522128982573715.7195846332834; Mon, 26 Mar 2018 22:36:22 -0700 (PDT) Received: from localhost ([::1]:60487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0hHK-0000Cl-BR for importer@patchew.org; Tue, 27 Mar 2018 01:36:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0hFI-0007PE-8J for qemu-devel@nongnu.org; Tue, 27 Mar 2018 01:34:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0hFD-0005Lh-C8 for qemu-devel@nongnu.org; Tue, 27 Mar 2018 01:34:08 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:42483) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0hFD-0005KG-8g for qemu-devel@nongnu.org; Tue, 27 Mar 2018 01:34:03 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id D6BA620D41; Tue, 27 Mar 2018 01:34:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 27 Mar 2018 01:34:01 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 903881029A; Tue, 27 Mar 2018 01:34:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=+2zjgiHrgoYGHJ AoJZHmWCLjueLLWXv7MQTXwXe2ZFg=; b=N3T35+ysRAKoXyWlAwbVWSw6awEfFj cjkalzh1nEgClx+7MbO248j5l2bKr5Mhp5vhG2GpXve/f2urh7BRJKBQ9++lC6rv ndJfBTFLU1ebUBF7NeN2L1tCiZ+k7sCgj1K+d5i4SdC89fY+JtAzOQYx49KSYWZS gGrN+IVNUCAuE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=+2zjgiHrgoYGHJAoJZHmWCLjueLLWXv7MQTXwXe2ZFg=; b=Czeh10CH /T1zkwXBDBsrkYUFtd94kkX/KneuLLWUKJ35YwDeBAv9CzkzKbCkr/7xQZTv8JW6 X/XdVuJtPTtqRj8+1s9YfczIpGXAGcRL6PgnexaK+jMN1hRwb+JPd2zEMag3tIQI FaGA5cEU6XP98Q2uKJ32Ze6/UOAgelzxUw4iWvc16ZNu71QKc+OX2mJW/6LSHbdJ IUye1XnU8XdlOHvgLVqW8+uN293zOdRXsQqYqvGoX8Vi1ui0RoOIDJuQsL+vcBhy IWRYQJF1ngco4ZvUnYig91Z4q7LWP/dDZeQn3YhdKn4d4N3KOpf13bLu/s36oLnd YEmI/Mfi6nocrQ== X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 27 Mar 2018 01:33:49 -0400 Message-Id: <1522128840-498-4-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522128840-498-1-git-send-email-cota@braap.org> References: <1522128840-498-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH v2 03/14] softfloat: fix {min, max}nummag for same-abs-value inputs 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 , Mark Cave-Ayland , Richard Henderson , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before 8936006 ("fpu/softfloat: re-factor minmax", 2018-02-21), we used to return +Zero for maxnummag(-Zero,+Zero); after that commit, we return -Zero. Fix it by making {min,max}nummag consistent with {min,max}num, deferring to the latter when the absolute value of the operands is the same. With this fix we now pass fp-test. Signed-off-by: Emilio G. Cota --- fpu/softfloat.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6e16284..6803279 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1704,7 +1704,6 @@ static FloatParts minmax_floats(FloatParts a, FloatPa= rts b, bool ismin, return pick_nan(a, b, s); } else { int a_exp, b_exp; - bool a_sign, b_sign; =20 switch (a.cls) { case float_class_normal: @@ -1735,20 +1734,22 @@ static FloatParts minmax_floats(FloatParts a, Float= Parts b, bool ismin, break; } =20 - a_sign =3D a.sign; - b_sign =3D b.sign; - if (ismag) { - a_sign =3D b_sign =3D 0; + if (ismag && (a_exp !=3D b_exp || a.frac !=3D b.frac)) { + bool a_less =3D a_exp < b_exp; + if (a_exp =3D=3D b_exp) { + a_less =3D a.frac < b.frac; + } + return a_less ^ ismin ? b : a; } =20 - if (a_sign =3D=3D b_sign) { + if (a.sign =3D=3D b.sign) { bool a_less =3D a_exp < b_exp; if (a_exp =3D=3D b_exp) { a_less =3D a.frac < b.frac; } - return a_sign ^ a_less ^ ismin ? b : a; + return a.sign ^ a_less ^ ismin ? b : a; } else { - return a_sign ^ ismin ? b : a; + return a.sign ^ ismin ? b : a; } } } --=20 2.7.4