From patchwork Thu Apr 12 11:58:37 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: 133266 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1609261ljb; Thu, 12 Apr 2018 05:01:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/hLiB8zGFmgY0rvyMXir4ClcBu+j1qYK8jhBtavnWhTj3tV9IcGRVAT4Bj5R3sZIf6G174 X-Received: by 2002:a25:7451:: with SMTP id p78-v6mr226866ybc.426.1523534482048; Thu, 12 Apr 2018 05:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523534482; cv=none; d=google.com; s=arc-20160816; b=uKDrUNNj6uRjPFNpyW2eO5gTCMFis43YkbJvmA+g4XRm/lFjJanFaCzmveBviuClRL YOBFXRFNMvXNxu3vGEZsjZrVPNi0fRA08a/AGHYdNTpZRpFRxypwgPdvickELfCm2gYj O/mFlv6f84X5KMdqSJyuCHmyAtCDKb/S+rPqHLyoQIqJGw71+b7OjviuFxIQaVg3zOXm dMFoVs/Xd4K/brCkwbkdg5s6FVFEV7/tlSnNXaieERjTLA9h0ZOeF+0edeRQMnd3GaEz PvC4dBKEoOtvvyLM3JaqoMqMODvNKK4f3WSVl+6nNZEs8GZ9wr6Ljt9LUVjYW6/t20WP +ETA== 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=spuZBOmpX6VoeOtVjTSiNSYfqbcGoqnpnp2SIesX5uor18GC/DaHTiSK2vYFv3Fm8w mtrihdY4/yPq2loyFXk+s3c7sD4dpQrNJGQhxBsWo2Yn/6PQNDwUizpBWlwZ3rI4wJN8 +V03nNqwpf9DUiw7wK5v8TzKoVR+CHOFaXTU81PAoygF169hYVScgbTl+cVV0SnPxsfp iqCPSd2QrBntadAqjad2T2GP6AaLcOOMEeIOWmyOBwQWj/mPb1vv8pkVC2xTeRu4tORW pZf8UqTWWBTeyFe0rkyjOOPZdabRAOgjFWAxfLSu0S5jqMYWa6a2piqilmouEjAu0R6I o68w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TSfN6QMV; 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 p184si742394qkd.73.2018.04.12.05.01.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 12 Apr 2018 05:01: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=TSfN6QMV; 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]:33625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6aun-0008Fi-Gu for patch@linaro.org; Thu, 12 Apr 2018 08:01:21 -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) 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-Received: by 10.223.136.24 with SMTP id d24mr585930wrd.127.1523534319583; Thu, 12 Apr 2018 04:58:39 -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) From: =?utf-8?q?Alex_Benn=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 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_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; } } }