From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 54B7A3858C27 for ; Mon, 14 Mar 2022 09:46:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54B7A3858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:In-Reply-To:References:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jEjmon2MTE3P4G/1MME0ligavoG/j9OW8T/HUgKeyYA=; b=gMa9ZuoNy39jzmo+K2+i4M2AHe VS/ZrLzNh1DKsLxz5mHYJO1/ONPuoQ+ucBv/pigRNfui4KjIS+9odZMX25VGSfroHOn4bcUzzNVUh 3R1ZgJC452K7EbvP0cefM0/mCMcTAfBW4tdS2fOsvksHS/RpgGld5pPM6fpKj+f3gpG0MlaRQJEjs 6dYa1vzCzIK3/RJY0XkyqVl1jUrDmMBC59PFxdhk59nk2ryMR5dTQVSdkyiGWGaBIsrovFseU5hf9 9eztOtYaAJAiU53QIwSfyyu9rfXKIv04bcT6BtlUKtEN6HWKElDHFyBbK+lX5VGuMhrVHJj3l51K1 dXIxS6Lg==; Received: from host86-186-213-42.range86-186.btcentralplus.com ([86.186.213.42]:57374 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nThHd-0005T3-Jx; Mon, 14 Mar 2022 05:46:33 -0400 From: "Roger Sayle" To: "'Richard Biener'" Cc: "'Tom de Vries'" , "'Jeff Law'" , "'Tobias Burnus'" , , "'Jeff Law'" , References: <057201d81df1$50523bc0$f0f6b340$@nextmovesoftware.com> <65b25eab-a831-db0d-3332-43fde9879efd@codesourcery.com> <2e10cc50-9c3c-0e05-e651-6a3ce37228b8@codesourcery.com> <9023r58q-7n1-9pr0-769r-45oo426n3p9r@fhfr.qr> <7f9a2be7-61a8-952c-4a73-d51a3562e93e@gmail.com> <01d301d8377f$0d94a7d0$28bdf770$@nextmovesoftware.com> <86n5p192-pn67-6p5-3qs-so963p5586no@fhfr.qr> In-Reply-To: <86n5p192-pn67-6p5-3qs-so963p5586no@fhfr.qr> Subject: RE: PING**4 - [PATCH] middle-end: Support ABIs that pass FP values as wider integers. Date: Mon, 14 Mar 2022 09:46:28 -0000 Message-ID: <030501d83788$62a7be70$27f73b50$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJ9RK1A/mLmQI2lFVOi8QF0uUeM9QJFmsmeAlaF1F4CgsUINAJ5ebo1AdiZ858CFrmC0gHc60Z5AeNrb42q6j1dsA== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Mar 2022 09:46:36 -0000 Hi Richard, Thanks for asking. The issue is with 16-bit floating point HFmode, where clang on nvptx passes HFmode values in SImode registers, and for binary compatibility GCC needs to do the same. Their motivation is that for compatibility with older GPUs and the x86_64 host, HFmode parameters are treated like "unsigned int". Hence, libgcc functions like __sqrthf behave as though declared (are binary compatible with) "unsigned short __sqrthf(unsigned short)". As you point out, this also greatly simplifies soft-float, as both ABIs remain the same. Alas, the subreg approach doesn't work as we'd end up with (subreg:SI (subreg:HI (reg:HF)), though technically that is what this patch does, inserting a pair of conversion instructions. Until recently (subreg:SI (reg:HF)) did work, but that support was removed/cleaned-up, as we need sensible subreg semantics in the RTL passes. The proposed patch simply adds support back in the minimal places where changing FP/non-FP and precision at the same time is required: argument passing and return values. Hopefully this answers your question. An alternate viewpoint might be "is there a reason for GCC not to be able to support targets with slightly wacky parameter passing conventions". Thanks for thinking about this. Roger -- > -----Original Message----- > From: Richard Biener > Sent: 14 March 2022 09:09 > To: Roger Sayle > Cc: 'Tom de Vries' ; 'Jeff Law' ; > 'Tobias Burnus' ; richard.sandiford@arm.com; 'Jeff > Law' ; gcc-patches@gcc.gnu.org > Subject: RE: PING**4 - [PATCH] middle-end: Support ABIs that pass FP values as > wider integers. > > On Mon, 14 Mar 2022, Roger Sayle wrote: > > > > > I thought I'd add a few comments that might help reviewers of this patch. > > Most importantly, this patch should be completely safe, as both > > changes only trigger with FLOAT vs INT size mismatches which currently > > both ICE in the compiler a few lines later. Admittedly, this > > indicates something odd about a target's choice of ABI, but one > > alternative might be to issue a "sorry, unimplemented" error message > > rather than ICE, perhaps with a TODO or FIXME comment that support for > > mixed size FP/integer ABIs be added in future. > > > > The only (other?) possible point of contention is the (arbitrary) > > decision that when passing floating point values in a larger integer > > register, the code is hardwired to use zero-extension. This in theory > > could be turned into a target hook to support sign-extension, but > > given these are padding bits, zero seems appropriate. [On x86_64, if > > passing DFmode argument in a V2DFmode vector, say, it seems reasonable to > use movq and zero the high bits]. > > > > The final point is that at the moment, the only affected target is > > nvptx-none, as I don't believe any other backend specifies an ABI that > > requires passing floating point values in wider integer registers. > > Having said that, most targets don't yet support HFmode, and their ABI > > specifications haven't yet been updated as what to do in that > > eventuality. If they choose to treat these like HImode, they'll run > > into the same issues, as most ABIs pass HImode in wider word_mode registers. > > > > I hope this helps. If folks could air their concerns out loud, I can > > try my best to address those worries. > > First of all I'm not familiar with the ABI related code as all, so I refrained from > commenting. But now I've looked closer (still unfamiliar code). > > I suppose there's targets passing SFmode in a SImode GPR and DFmode in a > DImode GPR (all soft-float targets?), so that already works somehow. > Why does nvptx choose DImode for SFmode passing then? Can't it choose > (subreg:SI di:..) or so? Does it require zero-extending to DImode on the caller > side? It seems your expand_expr_real_1 code does not rely on that? So, why > does nvptx function_arg hook (?) insist on returning a DImode reg for an SFmode > argument rather than an SImode subreg of that? > > Richard. > > > > > Many thanks in advance (and thanks to Tobias and Tom for pushing for this). > > Roger > > -- > > > > > -----Original Message----- > > > From: Tom de Vries > > > Sent: 14 March 2022 08:06 > > > To: Jeff Law ; Richard Biener > > > ; Tobias Burnus > > > Cc: richard.sandiford@arm.com; Jeff Law ; gcc- > > > patches@gcc.gnu.org; Roger Sayle > > > Subject: PING**4 - [PATCH] middle-end: Support ABIs that pass FP > > > values as wider integers. > > > > > > On 3/2/22 20:18, Jeff Law via Gcc-patches wrote: > > > > > > > > > > > > On 2/28/2022 5:54 AM, Richard Biener via Gcc-patches wrote: > > > >> On Mon, 28 Feb 2022, Tobias Burnus wrote: > > > >> > > > >>> Ping**3 > > > >>> > > > >>> On 23.02.22 09:42, Tobias Burnus wrote: > > > >>>> PING**2 for the ME review or at least comments to that patch, > > > >>>> which fixes a build issue/ICE with nvptx > > > >>>> > > > >>>> Patch: > > > >>>> https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590139. > > > >>>> html (for gcc/cfgexpand.cc + gcc/expr.cc) > > > >>>> > > > >>>> (There is some discussion by Tom and Roger about the BE in the > > > >>>> patch thread, which only not relate to the ME patch. But there > > > >>>> is no ME-patch comment so far.) > > > >>> The related BE patch has been already committed, but to be > > > >>> effective, it needs the ME patch. > > > >> I'm not sure I'm qualified to review this - maybe Richard is. > > > > I'd initially ignored the patch as it didn't seem a good fit for > > > > stage4, subsequent messages changed my mind about it, but I never > > > > went back to take a deeper look at Roger's patch. > > > > > > Ping. > > > > > > [ FWIW, I'd appreciate it if a response came before the end of stage > > > 4, such that I have some time left to deal with fallout in case the > > > patch is not approved. ] > > > > > > Thanks, > > > - Tom > > > > -- > Richard Biener > SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, > Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)