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; } } } From patchwork Thu Apr 12 11:58:38 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: 133267 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1612533ljb; Thu, 12 Apr 2018 05:04:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx499QQlFediKpeYK+34yMmJ0+TfywTC2kzsA8X/k8uvv3tcQzi/FYx4AFUj8VlddS/nL+7C+ X-Received: by 10.55.207.148 with SMTP id v20mr768671qkl.194.1523534646684; Thu, 12 Apr 2018 05:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523534646; cv=none; d=google.com; s=arc-20160816; b=p9Xb5SYgDlMh7D/kQID0e7gOPYdXxJTvDzemVGnsKDaJxSFQV35KTZHbEP+k/U0VCO xzvvbgHTvdEVON0fu7FqZKYT/HSwwce4AuWUKRBLvSav1rzILTu9LyxtSrItgbbezQ98 kpWdWtSdzeKMSaXwuBWF+IuguPhOsNwnjbFbpgQEWDJEQWHg5ShRhaQNAVjK3ydkHjmH Z+jhiFaf1Rt1TVyWEOCBXG2EPuv5fPHYpPS7s8xm+R9eE41gt/lhUI3xZf98kQXdxEeT 4t7YeSpCXmXwPIir0MrnWzh1A1I2g0UV8A5sHUTQTjgLqC4a7mlHrRl89zKsjRNAaktY AxQQ== 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=zORy7m/tcclQukMW6u8ezjH8aTgfgPfMYUyweIvFVkM=; b=0LdHuo0Db3goH30yHIUomtEKcWWIu8B/eaTKO8tA2PLzBOMRbJV2glenP9hhlFUOb+ MEqoNhpNr1ZqTx+7V5/LFrG9Y+t+cM61wigZzHvAvB7spYBGBT44sJG0Hus1471tRNcu lwtiUkZ24+Uf6mxX/4qNnKH1pxNcu/WoxbJuu4o/x5L0PBNjoSOTZ6vFC1/tG34GpBRF XKtQf55Os9f0zduIkPeVg8XWXHmhqeNWzTm3+qQP+VQ+ex7TKFoDzqpuXEUHQtlicB0+ FnDUsUGarLAICP/gmEP1svyMqKU4CSYeEgs2Wq6EQnxQCVMRFL+pyfYCxPi8MV/T0GCq 1KNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LARHiR+3; 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 139si1552457qkl.61.2018.04.12.05.04.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 12 Apr 2018 05:04:06 -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=LARHiR+3; 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]:33948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6axS-0002BG-7B for patch@linaro.org; Thu, 12 Apr 2018 08:04:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f6asI-0007LM-9J for qemu-devel@nongnu.org; Thu, 12 Apr 2018 07:58:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f6asE-0007Py-HM for qemu-devel@nongnu.org; Thu, 12 Apr 2018 07:58:46 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:52877) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f6asE-0007PS-Bx for qemu-devel@nongnu.org; Thu, 12 Apr 2018 07:58:42 -0400 Received: by mail-wm0-x243.google.com with SMTP id g8so10970732wmd.2 for ; Thu, 12 Apr 2018 04:58:42 -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=zORy7m/tcclQukMW6u8ezjH8aTgfgPfMYUyweIvFVkM=; b=LARHiR+3tF4taGCszteexNFGAl6y1cqQCeEsT5o/SPvxRcUiEV6tKKKSQeqI9dusTk KIeBUxxBOds6XgAmu5iPjJdG6Hd9WL0jC+A5UGXUDWZF3hgNf9y5w/qIHSK/Is524AXK 78fpbbtEr2kPHRpN07TQ30QDxjmJ0aPHJu+DM= 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=zORy7m/tcclQukMW6u8ezjH8aTgfgPfMYUyweIvFVkM=; b=CqwNL0ecTDTkMK8MBx0/sc9viWAVQfcKpDXP/gl8JBq3GcPr5r+YvIK3dVnMEsDhja KcdR1MySR/S4U3R2FHQPY3aeNV8im0a4li0xIb/rF1eB/SPaRb7DgLxYxb7dj/F9z1FV oPh3j4AvJHhTwNHfsvLNvxwEyH48+nONusUq8SvN06w7V+v/4QWQ2fhivMHoYAsaDpt1 QNygDcV4d0C4+gtsVA3D50w3OVjg3084IIv0NYlYzAo6PzdZ77e1eq9AVX67u1E3QsZ6 SuBsc7EUDJOtVIRwFRnJSXs1zDwpEYP6aMkOLuBtD8fE8UlTYXV/YEfCabhQdPoQW96P hthQ== X-Gm-Message-State: ALQs6tAXYFrHLUyJg0B3MSg8JGjX3jCN596XbMjFrlnm16I1fHSdhhO3 TSnI27/gvCf6O6fE7CoMfgR0/Q== X-Received: by 10.28.212.84 with SMTP id l81mr484527wmg.151.1523534321192; Thu, 12 Apr 2018 04:58:41 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s49sm4711034wrc.36.2018.04.12.04.58.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 04:58:40 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7E6873E0402; 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:38 +0100 Message-Id: <20180412115838.10208-3-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:c09::243 Subject: [Qemu-devel] [PATCH v1 2/2] fpu/softfloat: raise float_invalid for NaN in float_to_int 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: Bastian Koppelmann , =?utf-8?q?Alex_Be?= =?utf-8?b?bm7DqWU=?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Fixes https://bugs.launchpad.net/qemu/+bug/1759264 Signed-off-by: Alex Bennée Cc: Bastian Koppelmann --- fpu/softfloat.c | 1 + 1 file changed, 1 insertion(+) -- 2.17.0 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 9b99aa6ec8..ddc77c273c 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1344,6 +1344,7 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, case float_class_qnan: case float_class_dnan: case float_class_msnan: + s->float_exception_flags = orig_flags | float_flag_invalid; return max; case float_class_inf: return p.sign ? min : max;