From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sender4-pp-o91.zoho.com (sender4-pp-o91.zoho.com [136.143.188.91]) by sourceware.org (Postfix) with ESMTPS id 017333857C7A; Sat, 20 Feb 2021 22:17:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 017333857C7A ARC-Seal: i=1; a=rsa-sha256; t=1613859430; cv=none; d=zohomail.com; s=zohoarc; b=IC/6c4BGda1l9I3suyG8wd7MGe8n5cL8ChUWBPVKJFZJRbQdvPKy/GqMqV9RyEVYmd1Nmj3y0ENXgAbkTsfToAUGKZKoHIWebhGXGfBS/wUGWsX7/rAC2E17EYF6yOxS7q2ZZv9+WYVDhPdyOEvCCMGuVKu1MI2l1MOD/omEWIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613859430; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nkz65huMYk7+rH/iksJuNui9NcNfowWqAM3XNSdcAPQ=; b=DlzBA/UjX5Fx4RmdRoumnHPnmeoEiGARB/00gfmEL3nq7pHJyNdul0oiZWi6CvTGvOZm4gASg0GNBNWmbJiS/A0HeAslV5rfNgciWqwHcbIc80YoNgg53VkJsMQoa/QGzZBHupkA+RHQdi4/7htWI73fkvunRD7ieElyioSDteI= 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= header.from= Received: from localhost (38.87.1.99 [38.87.1.99]) by mx.zohomail.com with SMTPS id 1613859428272240.5454898173872; Sat, 20 Feb 2021 14:17:08 -0800 (PST) Date: Sat, 20 Feb 2021 17:17:06 -0500 From: Antoni Boucher To: Tom Tromey Cc: Antoni Boucher via Gcc-patches , jit@gcc.gnu.org Subject: Re: [PATCH] libgccjit: Handle truncation and extension for casts [PR 95498] Message-ID: <20210220221706.ewfq2b3i2mzx4ice@bouanto-desktop.localdomain> References: <20200713003002.bs5hwv4gav6ml5rt@bouanto-laptop.localdomain> <874ki6txcc.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <874ki6txcc.fsf@tromey.com> X-ZohoMailClient: External X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2021 22:17:33 -0000 Hi. Thanks for your feedback! See answers below: On Sat, Feb 20, 2021 at 11:20:35AM -0700, Tom Tromey wrote: >>>>>> "Antoni" == Antoni Boucher via Gcc-patches writes: > >Antoni> gcc/jit/ >Antoni> PR target/95498 >Antoni> * jit-playback.c: Add support to handle truncation and extension >Antoni> in the convert function. > >Antoni> + switch (dst_code) >Antoni> + { >Antoni> + case INTEGER_TYPE: >Antoni> + case ENUMERAL_TYPE: >Antoni> + t_ret = convert_to_integer (dst_type, expr); >Antoni> + goto maybe_fold; >Antoni> + >Antoni> + default: >Antoni> + gcc_assert (gcc::jit::active_playback_ctxt); >Antoni> + gcc::jit::active_playback_ctxt->add_error (NULL, "unhandled conversion"); >Antoni> + fprintf (stderr, "input expression:\n"); >Antoni> + debug_tree (expr); >Antoni> + fprintf (stderr, "requested type:\n"); >Antoni> + debug_tree (dst_type); >Antoni> + return error_mark_node; >Antoni> + >Antoni> + maybe_fold: >Antoni> + if (TREE_CODE (t_ret) != C_MAYBE_CONST_EXPR) >Antoni> + t_ret = fold (t_ret); >Antoni> + return t_ret; > >It seems weird to have a single 'goto' to maybe_fold, especially inside >a switch like this. > >If you think the maybe_fold code won't be reused, then it should just be >hoisted up and the 'goto' removed. This actually depends on how the support for cast between integers and pointers will be implemented (see below). If we will support truncating pointers (does that even make sense? and I guess we cannot extend a pointer unless we add the support for uint128_t), that label will be reused for that case. Otherwise, it might not be reused. So, please tell me which option to choose and I'll update my patch. >On the other hand, if the maybe_fold code might be reused for some other >case, then I suppose I would have the case end with 'break' and then >have this code outside the switch. > > >In another message, you wrote: > >Antoni> For your question, the current code already works with boolean and >Antoni> reals and casts between integers and pointers is currently not >Antoni> supported. > >I am curious why this wasn't supported. It seems like something that >one might want to do. I have no idea as this is my first contribution to gcc. But this would be indeed very useful and I opened an issue about this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95438 >thanks, >Tom Thanks!