From patchwork Fri Apr 13 14:03:33 2018 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: 133378 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp766337ljb; Fri, 13 Apr 2018 07:04:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+kDnELMB4otypuwUwK/4H/3N77/zNT3Eca1OvEQDME5fgTinYgOPCIW4y30ZR+XEzcw6Mi X-Received: by 10.55.120.197 with SMTP id t188mr4370997qkc.344.1523628291019; Fri, 13 Apr 2018 07:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523628291; cv=none; d=google.com; s=arc-20160816; b=LvmnGJ9mPDxOzqYwgcg6IrXVSnUicD+W6DG2NO2QbD/ia9DlwqLXYW7bV7H6a+fS8R NiJp0iFDccdBnjU/RZ+ZkifKWtqIos7vFJVTkXYbEuFDu+KtDWOBB3bJbv7A4iPHSLjH XLPoVdw+qKVk3C91h+S/jdwZCbgzF0GBGPAykB6G1DoAMzdK4sQs8ZEzRhiVYyx6GtBx 3dPO4y79DAOSW9ZNmhJbgT3ejHsZfPt6XkvdoLSbz/WL/ZRlKW5KYTcO6tEwGsKwxrb4 0BqK8dfhPvlB773l76tWkCqDRmg+OF2CL+Frg/BKxP4XacTBTZzfnu/EN7E2TyL/b0u0 8raA== 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=coFQ2xswQsFEuLwdZm8aY7T7ZboMuDSq8UFNZ8FMz/8=; b=q2vANDIOy9Tyg94E1zn92bIrPfeMbPCvcxyKhUAs/5/IUex/vBq3O/I4dqOW66IK+p AJEqdUcgrdUW+drTkYAzcealPBHVbIsMd7+cc9gtd1aqdZbRhg/wU7+stJo4l2Q3aHay DX8XVv+fzHrT7W2PsKZj5jEubghA/uKshgvJw2eKGpFcEPhuGSV4V785wTr24MEXKSGl 4debfkg86+pHm9gTKvoSwbndoRbV67DO5HQ5jS9pZczd3HhVX/VaIbUTyjsf02mU+oSa YJMYStBzaCLpByX5mzlbpIHJid2JpSXfzQf/KnKXmrxlUGbcVktrPRIrcKmX5d4E+lia LMZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RM71Dfla; 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 z11si230058qti.256.2018.04.13.07.04.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Apr 2018 07:04: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=RM71Dfla; 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]:55944 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6zJq-0003ka-GP for patch@linaro.org; Fri, 13 Apr 2018 10:04:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6zIl-000372-8F for qemu-devel@nongnu.org; Fri, 13 Apr 2018 10:03:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6zIg-0000bi-SI for qemu-devel@nongnu.org; Fri, 13 Apr 2018 10:03:43 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:36467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6zIg-0000bT-LE for qemu-devel@nongnu.org; Fri, 13 Apr 2018 10:03:38 -0400 Received: by mail-wr0-x243.google.com with SMTP id q13so4996193wre.3 for ; Fri, 13 Apr 2018 07:03: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=coFQ2xswQsFEuLwdZm8aY7T7ZboMuDSq8UFNZ8FMz/8=; b=RM71DflaqJFQVrf5lMV94dD25QxBCnjDzVtaCh/vNMwBXnXP4hYq9zGXvqVLH3ar20 65S1x+Q43HFMqyr8+bxnQXv9WO+FzRvxo096tCfcT+PQdRZbGNlaY9352oOHH+FHbdcO L3EuM80e3RcsF9PaAajmaF4qVHIVQ6rHlKVYw= 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=XiF8s5JsmDe2OM4Lz1YSJWobgkEDJLodZvRl5G3nedGs9uQuwueH5bxMJi4nGReNmF LjPCDU214ilHAJvqiNMQIqV/faBWveX2fScZkOj6qIcX98UwQmOyOcbG34fl0pCWnuUP QKH+UBQxGUgFYiySXygwXKCZbeHliB0Nppnv3IpeQ55MRKWRqTqrWSVTvG8FkfgRD8p/ ebaDbRImXtak+JzsRDeDuLr/EEs7sdvAY80k7yG7svF/dHgvY1iax947sIGvV45rSYtr pB6vijJeJRoFKLdferWeSZ+Xq4Dnpx+Gd88q1CrfLbcTvalgaaLtW/5AerHFTaXE+kvg 26yw== X-Gm-Message-State: ALQs6tBeGYBGHdQLtW95HkOW2avGQozkTZKhr7CfTXUYTHyOrFB5DYN2 ixjyq1UUgiSsU9B/Nc0R3/NVxMBJDuw= X-Received: by 10.28.113.22 with SMTP id m22mr3714130wmc.115.1523628217483; Fri, 13 Apr 2018 07:03:37 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l34sm5550517wre.14.2018.04.13.07.03.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Apr 2018 07:03:35 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2BCB93E0619; Fri, 13 Apr 2018 15:03:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Fri, 13 Apr 2018 15:03:33 +0100 Message-Id: <20180413140334.26622-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180413140334.26622-1-alex.bennee@linaro.org> References: <20180413140334.26622-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:400c:c0c::243 Subject: [Qemu-devel] [PATCH v2 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_Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée --- fpu/softfloat.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- 2.17.0 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, FloatParts b, bool ismin, return pick_nan(a, b, s); } else { int a_exp, b_exp; - bool a_sign, b_sign; switch (a.cls) { case float_class_normal: @@ -1735,20 +1734,22 @@ static FloatParts minmax_floats(FloatParts a, FloatParts b, bool ismin, break; } - a_sign = a.sign; - b_sign = b.sign; - if (ismag) { - a_sign = b_sign = 0; + if (ismag && (a_exp != b_exp || a.frac != b.frac)) { + bool a_less = a_exp < b_exp; + if (a_exp == b_exp) { + a_less = a.frac < b.frac; + } + return a_less ^ ismin ? b : a; } - if (a_sign == b_sign) { + if (a.sign == b.sign) { bool a_less = a_exp < b_exp; if (a_exp == b_exp) { a_less = 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; } } }