Message ID | ce5b809b30de16c037120c35859e5180903aa949.camel@zoho.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> 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 <ouuuleilei@gmail.com> (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 <ouuuleilei@gmail.com>; 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=<bouanto@zoho.com> 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: <ce5b809b30de16c037120c35859e5180903aa949.camel@zoho.com> Subject: [PATCH] libgccjit: Fix float playback for cross-compilation From: Antoni Boucher <bouanto@zoho.com> To: "jit@gcc.gnu.org" <jit@gcc.gnu.org>, "gcc-patches@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== Content-Type: multipart/mixed; boundary="=-JTSo2Bvs+8TaQMUL9Jjg" 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=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 |
Series |
libgccjit: Fix float playback for cross-compilation
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Antoni Boucher
Jan. 11, 2024, 11:42 p.m. UTC
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.
Comments
On Thu, 2024-01-11 at 18:42 -0500, Antoni Boucher wrote: > 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. I took a look, and I don't see a better way; it seems weird to go through a string stage. Ideally there would be a real_from_host_double, but I don't see one. Is there a cross-platform way to directly access the representation of 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. Sorry, can you clarify what you mean by "a difference of one decimal" above? > Also, I'm not sure how to write a test this fix. Any ideas? I think we don't need cross-compilation-specific tests, we should just use and/or extend the existing coverage for gcc_jit_context_new_rvalue_from_double e.g. in test-constants.c and test-types.c We probably should have test coverage for "awkward" values; we already have coverage for DBL_MIN and DBL_MAX, but we don't yet have test coverage for: * quiet/signaling NaN * +ve/-ve inf * -ve zero Thanks Dave
Thanks for the review! On Wed, 2024-01-24 at 13:10 -0500, David Malcolm wrote: > On Thu, 2024-01-11 at 18:42 -0500, Antoni Boucher wrote: > > 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. > > I took a look, and I don't see a better way; it seems weird to go > through a string stage. Ideally there would be a > real_from_host_double, but I don't see one. > > Is there a cross-platform way to directly access the representation > of > a host double? I have no idea. > > > 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. > > Sorry, can you clarify what you mean by "a difference of one decimal" > above? Let's say the Rust core tests expected the value "1.23456789", it instead got the value "1.2345678" (e.g. without the last decimal). Not sure if this is expected. Everything works fine for x86-64; this just happened for m68k which is not well supported for now in Rust, so that might just be that the test doesn't work on this platform. > > > Also, I'm not sure how to write a test this fix. Any ideas? > > I think we don't need cross-compilation-specific tests, we should > just > use and/or extend the existing coverage for > gcc_jit_context_new_rvalue_from_double e.g. in test-constants.c and > test-types.c > > We probably should have test coverage for "awkward" values; we > already > have coverage for DBL_MIN and DBL_MAX, but we don't yet have test > coverage for: > * quiet/signaling NaN > * +ve/-ve inf > * -ve zero Is this something you would want for this patch? > > Thanks > Dave >
David: Ping. On Thu, 2024-01-25 at 16:04 -0500, Antoni Boucher wrote: > Thanks for the review! > > On Wed, 2024-01-24 at 13:10 -0500, David Malcolm wrote: > > On Thu, 2024-01-11 at 18:42 -0500, Antoni Boucher wrote: > > > 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. > > > > I took a look, and I don't see a better way; it seems weird to go > > through a string stage. Ideally there would be a > > real_from_host_double, but I don't see one. > > > > Is there a cross-platform way to directly access the representation > > of > > a host double? > > I have no idea. > > > > > > 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. > > > > Sorry, can you clarify what you mean by "a difference of one > > decimal" > > above? > > Let's say the Rust core tests expected the value "1.23456789", it > instead got the value "1.2345678" (e.g. without the last decimal). > Not sure if this is expected. > Everything works fine for x86-64; this just happened for m68k which > is > not well supported for now in Rust, so that might just be that the > test > doesn't work on this platform. > > > > > > Also, I'm not sure how to write a test this fix. Any ideas? > > > > I think we don't need cross-compilation-specific tests, we should > > just > > use and/or extend the existing coverage for > > gcc_jit_context_new_rvalue_from_double e.g. in test-constants.c and > > test-types.c > > > > We probably should have test coverage for "awkward" values; we > > already > > have coverage for DBL_MIN and DBL_MAX, but we don't yet have test > > coverage for: > > * quiet/signaling NaN > > * +ve/-ve inf > > * -ve zero > > Is this something you would want for this patch? > > > > > Thanks > > Dave > > >
From 8ddfd4abbe6e46efc256030c2d010f035cd9ecf0 Mon Sep 17 00:00:00 2001 From: Antoni Boucher <bouanto@zoho.com> 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 <double> (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