From nobody Tue Feb 10 22:17:55 2026 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523534432311349.53686349884856; Thu, 12 Apr 2018 05:00:32 -0700 (PDT) Received: from localhost ([::1]:33625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6atr-0008Fi-6K for importer@patchew.org; Thu, 12 Apr 2018 08:00:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6asH-0007LH-ML for qemu-devel@nongnu.org; Thu, 12 Apr 2018 07:58:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6asD-0007Od-AY for qemu-devel@nongnu.org; Thu, 12 Apr 2018 07:58:45 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:40101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6asD-0007Mw-2y for qemu-devel@nongnu.org; Thu, 12 Apr 2018 07:58:41 -0400 Received: by mail-wr0-x244.google.com with SMTP id v60so940575wrc.7 for ; Thu, 12 Apr 2018 04:58:40 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id f22sm2209515wmc.3.2018.04.12.04.58.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 04:58:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6CA483E0365; Thu, 12 Apr 2018 12:58:38 +0100 (BST) 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=coFQ2xswQsFEuLwdZm8aY7T7ZboMuDSq8UFNZ8FMz/8=; b=TSfN6QMVYD1GfOSp7ohyAfi1uUNDv+t6UHGm7zhjOEzGJYYLEiPhVBCesAHTy78YaM QanYNn4w1POB8eBSOgWkzC8jOGNYvCufG/QgdVC/CE1yI1OPTYyf+lslzjVVy3QeEAse CL3DEmQFbr6C7zp8Un9oapL+9Mbng2R9i+i1w= 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=coFQ2xswQsFEuLwdZm8aY7T7ZboMuDSq8UFNZ8FMz/8=; b=Y8uf+KvhbDE+YYKMVUxEaVHPpnYkhBGeV5XyuVr/7D1RFXCiYNAyIbRTPaPVDRCK+Q n0I0rAPB12kCShlZVsvNWHL1XkLZb9TYO28oLihT7SkHKO1RC8L8hlEyFT+PCUbKJqy7 4g/ni47uK5cv6rA4X6ZeU4xeaK4hSxWFk/3ZjTJRrFioe6Q7bObeXIoGBmRnO6gy2mQP RhpTTdBWdoZwHHA8he+mxjjhkglmz5wbogjojGumbXdJfgy9z8OSl/9JqWtRpqNokWhk mRNx9t3DCwD3+WS2OSUyG7CQeeJLs+9gJnMiXoZNG5B9JeopLeS7HC+VDpjOoEVOi0QJ LJPA== X-Gm-Message-State: ALQs6tAdt04bBzhVHWJoya77T1uaAc39lWzBIzuZ+RkRNnPWekRhoK20 /i8fJIK7URbeVkV/pHIFwWwtFw== X-Google-Smtp-Source: AIpwx4+g8Yn31w3D6OUEk8cIcqvBymTN/Co/O/mujKguz5eYX7MUOBUNyBlRRcFDlYQIgbg71b43bw== X-Received: by 10.223.136.24 with SMTP id d24mr585930wrd.127.1523534319583; Thu, 12 Apr 2018 04:58:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 12 Apr 2018 12:58:37 +0100 Message-Id: <20180412115838.10208-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180412115838.10208-1-alex.bennee@linaro.org> References: <20180412115838.10208-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v1 1/2] 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: "Emilio G. Cota" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: "Emilio G. Cota" 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. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Alex Benn=C3=A9e --- fpu/softfloat.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index b46dccc63e..9b99aa6ec8 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.17.0