From patchwork Thu Jan 11 23:42:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoni Boucher X-Patchwork-Id: 187515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1792557dyi; Thu, 11 Jan 2024 15:43:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVBebKS/GKQXi1rTa9d4TJ92PyC9zlsbtowKvAGDWtnH/rgTM7dQxd3hrhaF13lhUpreVX X-Received: by 2002:a05:620a:111c:b0:783:445b:5717 with SMTP id o28-20020a05620a111c00b00783445b5717mr641180qkk.73.1705016621119; Thu, 11 Jan 2024 15:43:41 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1705016621; cv=pass; d=google.com; s=arc-20160816; b=zbY2WJuZaRFl7N/xgoS6FUGqSRDUXAIOtme5Mh2R0xQxvNx6x8i/NdtjYfbUWgbWFM N9K6JLyiTJn+KH0L86w/HrI5cMEjnFKngyBC3H3YiVOpoqKPhiUFsdjyP6bXseCi/n8I Z/GK7bzWPVS0WVLJXbZnAHhNQ+tsUYFCh+rBdGEs3pmqc69PJQgh/eMMQqVChX6wyV7m ZLcrid2AgqWBx1lNMNyGU3ECVtJBpsEpCRz593fx8ulYEqYFKMz5wWI8QEq1BdvcCiEi P7cENJ5pzEDyybqtc8BKLwPy+8e5c1nvg8mx3JLWk84tKa8u7PjpIqto7D8lfRya1BFz XGWw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id:mime-version :user-agent:autocrypt:date:to:from:subject:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=8wpuYW/YtpkcdM5AuZ7RgMW5xPdbU5te3JFIAYti2y8=; fh=czqxGZch5Vgice/quVb40eaDbwlGuL9Rbdl1KDXzwKY=; b=svO63SmFoVehCxGJY9ZC3ClTOURaEhW6rkGonFzD1qAMjeookB2l1pjiEr15zrH7RX 9aC6eGLGzWtlA6UrJU4gji0ZGOnz7mtJ7lDTEJRBVxk3R3smSGvhVsE52zc8uQYa//eU /iT2cBYSYwmm0HiDiFfAwBJlpFh/cM01z4JbyYja5xZSQUi5SUIRTL+RB7fXnOfSHm10 ZvqLNK9alNxmBnS5AMaS2wolLisUiSJjolZAYPiz2LHg8yyVrogr9XS7eF+eHLpT/TtB jYYs/YuQLCLf6wUzuSigp5o2o3P9GmPmbf1Xq8U1IZ+T9VP6AfprdOEcLGMqZ9hc69v7 3a8g== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=IdkInMUR; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id e25-20020a05620a209900b007833b7a1170si1868252qka.588.2024.01.11.15.43.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 15:43:41 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@zoho.com header.s=zm2022 header.b=IdkInMUR; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=zoho.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D11E13858432 for ; Thu, 11 Jan 2024 23:43:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from sender4-pp-o90.zoho.com (sender4-pp-o90.zoho.com [136.143.188.90]) by sourceware.org (Postfix) with ESMTPS id 8A92D3858D1E; Thu, 11 Jan 2024 23:42:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A92D3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=zoho.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zoho.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8A92D3858D1E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=136.143.188.90 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1705016572; cv=pass; b=H+2NLAacwjB8VFR9iBpylbY3/c35rIGCStneq956jaE8H1WtW1fXV8FnDqUGhioCvkHAz7YJrh7nsd/Kffx8biTQ3sr0ZyExeGnS+Eo+LLi4Xfy5db5rXU5ETPP9wVsjOIQ8iKS94sdU2nIhjTAEtiv7fg7lUSb0b9NMIPSQszM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1705016572; c=relaxed/simple; bh=aB8WNJYUg7d09L3jhukJAf8ch43oZLeoiRN++rbloDQ=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=HkbPD0YzR37Uj5jUkwG+lChlUTv0HtvU3kUjBkic5KtPzEcy9Z+DvFXf7fancnmxz7KWH/IzGkLfCQiPjaouVByb4k+8UsGqI9+RvZ1tvYiVwL0SJcOIGf0LjflvIOHGMNHqpekmljVef4hlhVU/pnQ8NbIp8CeXMC9ElTwm3VI= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; t=1705016567; cv=none; d=zohomail.com; s=zohoarc; b=QBdw++3XFH1vtGyRp5WkFQbkpDTAEFvoi0MYJVJcSo5M1wQPUcffj27BM/8cZaXlQSfQ9cwx8UnXMiu3te/AA+YpwCIU4uneP2wrAU0YTtsOMzCxQxnCjnsds+awhbZPw1iEu+AwXbsIlellRJEwKaGSVhkZ/ttHzOYpFQi3BkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705016567; h=Content-Type:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=8wpuYW/YtpkcdM5AuZ7RgMW5xPdbU5te3JFIAYti2y8=; b=asVSdCdDGXpfSFU5ZJJfFEVbfYB+6GcZXpXftIGjhBGdoaess3UoUT2whHZ8lKGvYtL/EI5uIXx4PQ24uWs9fwJaCrJpPt4Ryc9FcB59yNdOo1O1IKKEOREJFSiPA6LJq+PngOO5z3hNMkTRjcjDusXDb1LR3ASKLpz8bvjL4Mc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=bouanto@zoho.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1705016567; s=zm2022; d=zoho.com; i=bouanto@zoho.com; h=Message-ID:Subject:Subject:From:From:To:To:Date:Date:Content-Type:MIME-Version:Feedback-ID:Message-Id:Reply-To:Cc; bh=8wpuYW/YtpkcdM5AuZ7RgMW5xPdbU5te3JFIAYti2y8=; b=IdkInMUR3ThpZvTQ9aRgYIfsm9G/lz8MMCLXkmemDPRyniQj9ChCCwYenWj1xBQs 3PrEQOIXnHZ7bVGEd0qxYYtyd2Z+aj47IW5R21YV8HH8e+upJ87+XvkcFuqkPYJNugJ OreV0UfGctqNJoJMtYR+I++mjbCUTWKIfFVhmgqU= Received: from [192.168.1.172] (38.87.11.6 [38.87.11.6]) by mx.zohomail.com with SMTPS id 1705016565169760.5985109224463; Thu, 11 Jan 2024 15:42:45 -0800 (PST) Message-ID: Subject: [PATCH] libgccjit: Fix float playback for cross-compilation From: Antoni Boucher To: "jit@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" Date: Thu, 11 Jan 2024 18:42:43 -0500 Autocrypt: addr=bouanto@zoho.com; prefer-encrypt=mutual; keydata=mQENBFOSMLQBCADO5aw6Ys8thMQUNzrwAnfJX2wbgWiz0pQ01DjYj22eeIpChkoZn6LWdt4dieq30u2rFi/yQzJ02foHwI2+aL9rU6xz/x4TwqyRJQGMOqklNc3R+pdXmH4WDQkQDWmLxvc07vu+zb8Tx5A6pMDh4J2ncCEhLEUcH39Yq/yg4eBnFwUX6N7kakvHrnScGNqhnSFCacoJeMJUAR+1G7VBSBd++jmnHLnx3mj7QkRZVECJUw2zqiv1yReCC6GU4SvqLjdqm5ZGeoWOqD/NHjBRoEeOVjzp6M/qOjjWRbkJVqmvgfcD8UytSSqqboR35YFT4L+rZt2ri3T12MJb3i5syCAXABEBAAG0IUFudG9uaSBCb3VjaGVyIDxib3VhbnRvQHpvaG8uY29tPokBVgQTAQgAQAIbIwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QM4FCRLMEZoACgkQRVeGAwR4zcFBQQf/afttJrA/puADQZhrDfkgr0MFvq6iB+GCy1b8BkXimk1TOXTPt87YLehSeijNu3JkYhl5eRc87BNfU9J87KfI/KIy6hZxqlDXk16FhW9bw/7wYEA0hpb3MUn7xLElXDT0ZHaD+KTe8Oun7qfzgx5RlL6r/WODf3CkSpO085R/rfeBqDEx9mVlhDWgq6Az3CZoD+3CqiCKVqmDuHTWz4kwrd9AM5eVcLvvLKnZIdoIp+G5Ao6BvaGlZyfenN1iOSjLy2NXNt4MnUt0lUYEP5KSIIRhHQ8xkUbj7eWUmaahkxhNb3fH3sAPwGnRZrPpb4rgYzNmSk63wWMh9M2xk+rLb7kBDQRTkjC0AQgAumZzsAV/UFWI+dpzebQfma36kKYZZFuseant5sq/HWP553XQ/U6ttJiKyN5MpCqtxvCAoRplf42YhlHuFqgf73WJxoJ6Y+sdyqoBSwlR+ gzAneAmsa8gmmY0wawH0Z2leazjKuS7mJjVEQZg0ZGsiCVRGeRnDqFGzDEzDc9ngWKSoTq0fKzlGy1X85OrtmUrvEbhSo6HP+FoeunHkIqrxu3w3vDoFEXxVQlKI6V3I4nCz5n6DB8WR3L7nsiiTnOiGirPw1ngvWFLW86kkA4FJpayc8Xl3va3SLY+2y4yuROboX2DVI4AC/Qeug/mDiBicPxkP6YfUartQRMe6obkEQARAQABiQE8BBgBCAAmAhsMFiEEOELC4Uw1Jeb66YE6RVeGAwR4zcEFAlz4QRsFCRLMEecACgkQRVeGAwR4zcE56ggAgTgrJInBKC+7552Dpccuo6Clh3wZfjlNLv9/6r5lKEbaNzaTrfhPiAP4WgnluIUmj8amOFLFJpj+BAVNOXpZ4D2R3o9ch8z7fot+fW4Yw+PKIxH4I2xEys8ndoEB3aiQwHjKcGIhkIU7uyMJFQr2aWjdTY0gmXw0YZueHOSLgo7uX4XKxB8fEO/yto/Tff2YBAAq+AtNwt+Gh5YS9rZw7rwUTWMi84yVOlc+zRE79E9NJkvdTwX7IJYo64VzIRNfgHsn7QNdVzuM1XIFHl+Glk6cIlI8s6BO7nEoCn3hTF104fQTAO3fEs+XXZOKXo2lk8faowEoPq5r58StrV0nyg== User-Agent: Evolution 3.50.2 MIME-Version: 1.0 X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-1.1.0/204.902.92 Feedback-ID: rr080112285e2d7bf7e9330f41de1c665d00004955cd6947d1942ab840596793835b537ab089d8ef7c426eb289:zu080112260d3eac6d2bfbd18effe29499000028e03fb1b2f36c52f0fa8f971e3b789da255c3749ed9a361:rf0801123294e70fbe89391226a63fb16900008537ce5b8d92a205321404c43d5258f21bcc0616bfcd6e25a56202c3411b0e5d386c7a90:ZohoMail X-ZohoMailClient: External X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787839508657402950 X-GMAIL-MSGID: 1787839508657402950 Hi. This patch fixes the bug 113343. I'm wondering if there's a better solution than using mpfr. The only other solution I found is real_from_string, but that seems overkill to convert the number to a string. I could not find a better way to create a real value from a host double. If there's no solution, do we lose some precision by using mpfr? Running Rust's core library tests, there was a difference of one decimal, so I'm wondering if there's some lost precision, or if it's just because those tests don't work on m68k which was my test target. Also, I'm not sure how to write a test this fix. Any ideas? Thanks for the review. From 8ddfd4abbe6e46efc256030c2d010f035cd9ecf0 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 21 Oct 2023 11:20:46 -0400 Subject: [PATCH] libgccjit: Fix float playback for cross-compilation gcc/jit/ChangeLog: PR jit/113343 * jit-playback.cc (new_rvalue_from_const): Fix to have the correct value when cross-compiling. --- gcc/jit/jit-playback.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index dddd537f3b1..9cb27ee4ef3 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "gcc.h" #include "diagnostic.h" #include "stmt.h" +#include "realmpfr.h" #include "jit-playback.h" #include "jit-result.h" @@ -932,22 +933,16 @@ new_rvalue_from_const (type *type, // FIXME: type-checking, or coercion? tree inner_type = type->as_tree (); + mpfr_t mpf_value; + + mpfr_init2 (mpf_value, 64); + mpfr_set_d (mpf_value, value, MPFR_RNDN); + /* We have a "double", we want a REAL_VALUE_TYPE. - real.cc:real_from_target appears to require the representation to be - split into 32-bit values, and then sent as an pair of host long - ints. */ + realmpfr.cc:real_from_mpfr. */ REAL_VALUE_TYPE real_value; - union - { - double as_double; - uint32_t as_uint32s[2]; - } u; - u.as_double = value; - long int as_long_ints[2]; - as_long_ints[0] = u.as_uint32s[0]; - as_long_ints[1] = u.as_uint32s[1]; - real_from_target (&real_value, as_long_ints, DFmode); + real_from_mpfr (&real_value, mpf_value, inner_type, MPFR_RNDN); tree inner = build_real (inner_type, real_value); return new rvalue (this, inner); } -- 2.43.0