From patchwork Mon Jul 23 20:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10541049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46C42112E for ; Mon, 23 Jul 2018 21:17:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C4D284C7 for ; Mon, 23 Jul 2018 21:17:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 253D8284DC; Mon, 23 Jul 2018 21:17:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7C7D284C7 for ; Mon, 23 Jul 2018 21:17:44 +0000 (UTC) Received: from localhost ([::1]:36708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiD9-00053q-TB for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 17:17:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKB-0003Q4-St for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKA-00056V-QR for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:55 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:42734) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKA-00055l-L5; Mon, 23 Jul 2018 16:20:54 -0400 Received: by mail-oi0-x241.google.com with SMTP id n84-v6so3469947oib.9; Mon, 23 Jul 2018 13:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xmopYi/nNf6wdml7iVdwwr/MlVD9CKCWQdp5ypLE2TI=; b=Oza78fsPzFXGvZgyyzN1ZGhAyTX4tX4NFhFJBaSRVhsCJEkMGOlUG2sCl0UU7HPnFN hCE98e6fMLSUGphJxqobhcRq4CrB2tm9mLcsBtMTLWZQXON0csMbJiVNPfMnrprzFwUX sQfiwPozqtNC4WLAUXwYg8lHg7FTMCGo8T6eA53VXg4ouKcb0X3CXKUqBvqCVOjiH1cZ 6hmsYzojHIeLTNOlX/UfN+9iANwLj+qkc4HsFiIYyzGglCQysQTWWqirc4NkcijWGjt4 7TTDCMkaCWqJGnMFXxLUL4tEz3vXzfvasme/M2L5eQXPtzTQdKhBxROqzh5CXCAcQpc3 JLeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xmopYi/nNf6wdml7iVdwwr/MlVD9CKCWQdp5ypLE2TI=; b=G5fJTgfNnb2qKSS9bDYUiXuQ8Xpev5lgEsfIVwaxb8k4Z3CzFlJ7iRc0WmihUM/GMh IZRgUOZA+OiyLLR7oFxDyxnxNK25FRAV4339MO64xxYaBVTePwzQuS90VnzaP+ZO07bV kepT7ybmGVGJXVuuMBvDsXUQgWz9utNtBbIIZj/VXxOb5O3IhBK5AYW7N3HhE/ln+Y98 nDaM7jsZ6EapirEsW9By98hfF+R3my2eT6SGXa/KuFSMtWr6bclsxgTSiaINLgbCH+V+ Ivxc530oqP3a6GelUdu17FFtl7mmoI9kJD7R5XHvwg0+vFUfT7siRNB+z+/6V9u6IL+I ZH7g== X-Gm-Message-State: AOUpUlE8Y7yT0S6L15j1Xk3Zo0WedvAG7s2CCKLZMclOTSXmxuJYV331 x9tYruLEijzl+piQNJTizD1wKbolMTml2Q== X-Google-Smtp-Source: AAOMgpeOGZHhxi4TqjJHifW3DEH66QjP86DNUGA8+50GPL0BIqvvFN4/8gnCXGe0o/cp4aEJTg3slg== X-Received: by 2002:aca:5155:: with SMTP id f82-v6mr329457oib.272.1532377253517; Mon, 23 Jul 2018 13:20:53 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s124-v6sm6811118oia.51.2018.07.23.13.20.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:52 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:14 -0500 Message-Id: <20180723201748.25573-66-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 65/99] softfloat: Handle default NaN mode after pickNaNMulAdd, not before 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell It is implementation defined whether a multiply-add of (0,inf,qnan) or (inf,0,qnan) raises InvalidaOperation or not, so we let the target-specific pickNaNMulAdd function handle this. This means that we must do the "return the default NaN in default NaN mode" check after the call, not before. Correct the ordering, and restore the comment from the old propagateFloat64MulAddNaN() that warned about this corner case. This fixes a regression from 2.11 for Arm guests where we would incorrectly fail to set the Invalid flag for these cases. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Tested-by: Alex Bennée Message-id: 20180504100547.14621-1-peter.maydell@linaro.org (cherry picked from commit 1839189bbf89889076aadf0c793c1b57977b28d7) Signed-off-by: Michael Roth --- fpu/softfloat.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 70e0c40a1c..8401b37bd4 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -602,34 +602,42 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s) static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, bool inf_zero, float_status *s) { + int which; + if (is_snan(a.cls) || is_snan(b.cls) || is_snan(c.cls)) { s->float_exception_flags |= float_flag_invalid; } + which = pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), + is_qnan(b.cls), is_snan(b.cls), + is_qnan(c.cls), is_snan(c.cls), + inf_zero, s); + if (s->default_nan_mode) { + /* Note that this check is after pickNaNMulAdd so that function + * has an opportunity to set the Invalid flag. + */ a.cls = float_class_dnan; - } else { - switch (pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), - is_qnan(c.cls), is_snan(c.cls), - inf_zero, s)) { - case 0: - break; - case 1: - a = b; - break; - case 2: - a = c; - break; - case 3: - a.cls = float_class_dnan; - return a; - default: - g_assert_not_reached(); - } + return a; + } - a.cls = float_class_msnan; + switch (which) { + case 0: + break; + case 1: + a = b; + break; + case 2: + a = c; + break; + case 3: + a.cls = float_class_dnan; + return a; + default: + g_assert_not_reached(); } + a.cls = float_class_msnan; + return a; }