From nobody Wed Jul 31 07:30:15 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WYkJl65gfz5RNPV; Wed, 31 Jul 2024 07:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WYkJl5Zh5z4mdr; Wed, 31 Jul 2024 07:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722411015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jEAtOuYA5I/0PBep4FzYOUQUSPoMVODvfEp6ob3c/As=; b=erH6da/cgQ4/8aySOk4lD9wTY6dusjsFiwuxCuxPBo+jer9NOVPvZc354sO9x2UwZO3CxE eJ9JtMKWsCxiI0kxHeZI/tk0aNkd/44Pi3920MiAAGp1n82zmsQmS70Z+CMM7TNWAMG9w9 3cquuKGeQI2c6DBM3prE+alWfvg0pU2uiC1kbTpyY43ad0xLY/x4Mlwym/7B4LDlnpNs1u /3y2rUiSp4itaFK9/wGcvy8ps45JfJcQlEy8BBmcV5FpVY+5RutM0oWXbUYizENboT73HI WUnPPhHoc4ged9TpoT+EjHQ0/CbFORxWz8xOUA1chlf+gWWJ/KcwBhl9LjlEoQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722411015; a=rsa-sha256; cv=none; b=B/42tftm5qquxreETqA9hlzpnYRCEjiHh/AxwitLHAutoN3Nx7IRWBB5oa6pyqhoUodIdZ Cq3CYR5H5o+qVLug/TwfZlnmSpdED59kXi3SlK1JNCsLBD2PDrTYfHQBG79RGmJ1dfp5kZ Fnen5diU4460stoh2MOrq6aKojuBCdO+6T0wRaSLzYpR0JVvslcDwRZFXLa4v6WfkXIyho 6zNRamM7WhllEhtQnB7Bk+7aN8vWxJ3QKGfc3qnX1eDrZqQobT3HEMzwz81qklxZZLYlzT QmxTUmO0qnmSA6ct67JfT2Cot57DlFkz2xo7kH+n3DiHwO7jqPuSnrk2DfUjGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722411015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jEAtOuYA5I/0PBep4FzYOUQUSPoMVODvfEp6ob3c/As=; b=Vzx4pBGVvH4SyS3ihucuJX/NVZgaqiNDlR2PQDPg8kmVNhuoFpP9cN+l+Cn4zheS6Ys4Vu vyQwfi5ZjBeT+wJwQCDS3/BYtbqSyh9DNISNfaELKmn+Yd1HNFGcDlTnsLKeNO7J1b3Ca2 Wkd3yW8KnevJNdSUF0gwqtEYq4kuY+JshlCRuAGmkbWxvldYAYiKhNj9LuD4rlOjO+TuXu SvNJgMIAZHj2ECf0xsw/OVqsynylMR7DDLe1ZP4uefsSscQvYHBo6ZY67ZCxe+1YbNp51u FfGii4NivY+n3RtUXzmPIzDHcI40zkXO8zMJoWwTphMQ2kksV8raVIAPuMpIAg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WYkJl5BBMzs8D; Wed, 31 Jul 2024 07:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46V7UFc3064453; Wed, 31 Jul 2024 07:30:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46V7UF3m064445; Wed, 31 Jul 2024 07:30:15 GMT (envelope-from git) Date: Wed, 31 Jul 2024 07:30:15 GMT Message-Id: <202407310730.46V7UF3m064445@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 96ff33484ee5 - stable/14 - Merge commit c80c09f3e380 from llvm-project (by Dimitry Andric): List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 96ff33484ee5f44bc3ac743ce235d23495465904 Auto-Submitted: auto-generated The branch stable/14 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=96ff33484ee5f44bc3ac743ce235d23495465904 commit 96ff33484ee5f44bc3ac743ce235d23495465904 Author: Dimitry Andric AuthorDate: 2024-07-28 11:13:37 +0000 Commit: Dimitry Andric CommitDate: 2024-07-31 07:29:47 +0000 Merge commit c80c09f3e380 from llvm-project (by Dimitry Andric): [CalcSpillWeights] Avoid x87 excess precision influencing weight result Fixes #99396 The result of `VirtRegAuxInfo::weightCalcHelper` can be influenced by x87 excess precision, which can result in slightly different register choices when the compiler is hosted on x86_64 or i386. This leads to different object file output when cross-compiling to i386, or native. Similar to 7af3432e22b0, we need to add a `volatile` qualifier to the local `Weight` variable to force it onto the stack, and avoid the excess precision. Define `stack_float_t` in `MathExtras.h` for this purpose, and use it. This is the version of the fix for PR276961 that landed upstream. PR: 276961 Reported by: cperciva MFC after: 3 days (cherry picked from commit 1a4b8325f6e3a45c77188343da504fe04495cc46) --- contrib/llvm-project/llvm/include/llvm/Support/MathExtras.h | 8 ++++++++ contrib/llvm-project/llvm/lib/CodeGen/CalcSpillWeights.cpp | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/contrib/llvm-project/llvm/include/llvm/Support/MathExtras.h b/contrib/llvm-project/llvm/include/llvm/Support/MathExtras.h index aa4f4d2ed42e..afb4fa262152 100644 --- a/contrib/llvm-project/llvm/include/llvm/Support/MathExtras.h +++ b/contrib/llvm-project/llvm/include/llvm/Support/MathExtras.h @@ -644,6 +644,14 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { return UX > (static_cast(std::numeric_limits::max())) / UY; } +/// Type to force float point values onto the stack, so that x86 doesn't add +/// hidden precision, avoiding rounding differences on various platforms. +#if defined(__i386__) || defined(_M_IX86) +using stack_float_t = volatile float; +#else +using stack_float_t = float; +#endif + } // End llvm namespace #endif diff --git a/contrib/llvm-project/llvm/lib/CodeGen/CalcSpillWeights.cpp b/contrib/llvm-project/llvm/lib/CodeGen/CalcSpillWeights.cpp index f3cb7fa5af61..fa7ef669ec11 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/CalcSpillWeights.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/CalcSpillWeights.cpp @@ -22,6 +22,7 @@ #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/CodeGen/VirtRegMap.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -256,7 +257,9 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start, return -1.0f; } - float Weight = 1.0f; + // Force Weight onto the stack so that x86 doesn't add hidden precision, + // similar to HWeight below. + stack_float_t Weight = 1.0f; if (IsSpillable) { // Get loop info for mi. if (MI->getParent() != MBB) { @@ -283,11 +286,9 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start, Register HintReg = copyHint(MI, LI.reg(), TRI, MRI); if (!HintReg) continue; - // Force hweight onto the stack so that x86 doesn't add hidden precision, + // Force HWeight onto the stack so that x86 doesn't add hidden precision, // making the comparison incorrectly pass (i.e., 1 > 1 == true??). - // - // FIXME: we probably shouldn't use floats at all. - volatile float HWeight = Hint[HintReg] += Weight; + stack_float_t HWeight = Hint[HintReg] += Weight; if (HintReg.isVirtual() || MRI.isAllocatable(HintReg)) CopyHints.insert(CopyHint(HintReg, HWeight)); }