From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 48C4F3858D38 for ; Fri, 30 Sep 2022 19:44:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 48C4F3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664567064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/m7mhuPOaMsjniMDrA0kaKYaTk9Bbqi+3y6NIBHAWW8=; b=Ar+OzY/YiJ1s+/DEy+nkaOvqJp7Fr85dIbRPSX4lL6hdr1EWvZQczW8emdNLqPa4v+oeFP sP0h8J47kLaI+Vn1YcNRdkYy7hVAi+9XzKTsEHSwkXu5VNtfkjTRD9nuYRVWh5ue92gPpp Q8Ng8JAECp/QqRdzXt/2Zg34WhGfTf8= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-632-vd-iErokPfC9crTob4Mq4A-1; Fri, 30 Sep 2022 15:44:18 -0400 X-MC-Unique: vd-iErokPfC9crTob4Mq4A-1 Received: by mail-qt1-f200.google.com with SMTP id fx6-20020a05622a4ac600b0035a70ba1cbcso3654571qtb.21 for ; Fri, 30 Sep 2022 12:44:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=/m7mhuPOaMsjniMDrA0kaKYaTk9Bbqi+3y6NIBHAWW8=; b=uAwegf7+H5aDZrZs9CPoncw8Wqfru1qi1B9y6VGpfEi6JvPDeb99O4FVr8aGcaOttN iJ/D3no4ESyTZTEA9ja4dlYXv3fi0p8pvwzSNuUI3OphVNpadFVyzs3vjXC50j4zDJuY KvW3MgfxZiRCazaROdqKjrYP+xRrYPSbrT/DsWXPF+9iejw0HJYOiis7i5GtGfsjVT0b RHMiYMxJ0WAIFVB2KzRvwkUMSg/ct4L+QmBHKT4nH/PdOeaJWcfcxea+cs0/eWDJyxYH gklhOnZIkRxeZ4bymofJPBZWW0g5TAKo/YRJbmkyuswCqOfAHabst5FVcpzxMymjIvll JgAw== X-Gm-Message-State: ACrzQf2bnal4ed3SmpRBtdoatgnBLPj4Ktw+w/b67XAOGhJgG9FU1y/k GLfQqN0G0tHSavgjc2sEhFZkUvd6FBOB3sCblbgBW6WmiF8Ydh5l16Tlz5AJJIShVziHyfNXgDF r6CV+sWejBdrZ283rSA== X-Received: by 2002:a37:648f:0:b0:6d1:debe:4c9a with SMTP id y137-20020a37648f000000b006d1debe4c9amr1957941qkb.502.1664567058171; Fri, 30 Sep 2022 12:44:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PYRfy+e5Q9HTSpJKMx/OViAmGzchd0CALSsPrpMMKidKJrR2m2lXR/P7aGz0/I42gZ5UiMA== X-Received: by 2002:a37:648f:0:b0:6d1:debe:4c9a with SMTP id y137-20020a37648f000000b006d1debe4c9amr1957930qkb.502.1664567057806; Fri, 30 Sep 2022 12:44:17 -0700 (PDT) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id g15-20020a05620a40cf00b006ce3fcee2bdsm3689431qko.50.2022.09.30.12.44.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Sep 2022 12:44:17 -0700 (PDT) Message-ID: <4451b58d-d270-3f07-6748-fa82abd444a6@redhat.com> Date: Fri, 30 Sep 2022 15:44:16 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH] arm, aarch64, csky: Fix C++ ICEs with _Float16 and __fp16 [PR107080] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, Richard Earnshaw , Kyrylo Tkachov , richard.sandiford@arm.com References: <60f5d708-a233-2c36-6f74-ae064fdf6ffd@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 9/30/22 13:13, Jakub Jelinek wrote: > On Fri, Sep 30, 2022 at 09:54:49AM -0400, Jason Merrill wrote: >>> Note, there is one further problem on aarch64/arm, types with HFmode >>> (_Float16 and __fp16) are there mangled as Dh (which is standard >>> Itanium mangling: >>> ::= Dh # IEEE 754r half-precision floating point (16 bits) >>> ::= DF _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits) >>> so in theory is also ok, but DF16_ is more specific. Should we just >>> change Dh to DF16_ in those backends, or should __fp16 there be distinct >>> type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ? >> >> You argued for keeping __float128 separate from _Float128, does the same >> argument not apply to this case? > > Actually, they already were distinct types that just mangled the same. > So the same issue that had to be solved on i?86, ia64 and rs6000 for > _Float64x vs. long double is a problem on arm and aarch64 with _Float16 > vs. __fp16. > The following patch fixes it. > >>> And there is csky, which mangles __fp16 (but only if type's name is __fp16, >>> not _Float16) as __fp16, that looks clearly invalid to me as it isn't >>> valid in the mangling grammar. So perhaps just nuke csky's mangle_type >>> and have it mangled as DF16_ by the generic code? > > And seems even on csky __fp16 is distinct type from _Float16 (which is a > good thing for consistency, these 3 targets are the only ones that have > __fp16 type), so instead the patch handles it the same as on arm/aarch64, > Dh mangling for __fp16 and DF16_ for _Float16. > > Tested with cross-compilers, ok for trunk? OK. > 2022-09-30 Jakub Jelinek > > PR c++/107080 > * config/arm/arm.cc (arm_mangle_type): Mangle just __fp16 as Dh > and _Float16 as DF16_. > * config/aarch64/aarch64.cc (aarch64_mangle_type): Likewise. > * config/csky/csky.cc (csky_init_builtins): Fix a comment typo. > (csky_mangle_type): Mangle __fp16 as Dh and _Float16 as DF16_ > rather than mangling __fp16 as __fp16. > > * g++.target/arm/pr107080.C: New test. > * g++.target/aarch64/pr107080.C: New test. > > --- gcc/config/arm/arm.cc.jj 2022-09-29 18:11:28.746750048 +0200 > +++ gcc/config/arm/arm.cc 2022-09-30 19:01:48.774286551 +0200 > @@ -30359,6 +30359,8 @@ arm_mangle_type (const_tree type) > /* Half-precision floating point types. */ > if (TREE_CODE (type) == REAL_TYPE && TYPE_PRECISION (type) == 16) > { > + if (TYPE_MAIN_VARIANT (type) == float16_type_node) > + return NULL; > if (TYPE_MODE (type) == BFmode) > return "u6__bf16"; > else > --- gcc/config/aarch64/aarch64.cc.jj 2022-09-29 18:11:34.806667210 +0200 > +++ gcc/config/aarch64/aarch64.cc 2022-09-30 19:02:02.079108171 +0200 > @@ -20664,6 +20664,8 @@ aarch64_mangle_type (const_tree type) > /* Half-precision floating point types. */ > if (TREE_CODE (type) == REAL_TYPE && TYPE_PRECISION (type) == 16) > { > + if (TYPE_MAIN_VARIANT (type) == float16_type_node) > + return NULL; > if (TYPE_MODE (type) == BFmode) > return "u6__bf16"; > else > --- gcc/config/csky/csky.cc.jj 2022-09-08 13:01:19.239779562 +0200 > +++ gcc/config/csky/csky.cc 2022-09-30 19:06:09.126794587 +0200 > @@ -7300,7 +7300,7 @@ csky_init_cumulative_args (CUMULATIVE_AR > void > csky_init_builtins (void) > { > - /* Inint fp16. */ > + /* Init fp16. */ > static tree csky_floatHF_type_node = make_node (REAL_TYPE); > TYPE_PRECISION (csky_floatHF_type_node) = GET_MODE_PRECISION (HFmode); > layout_type (csky_floatHF_type_node); > @@ -7313,10 +7313,10 @@ csky_init_builtins (void) > static const char * > csky_mangle_type (const_tree type) > { > - if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL > - && DECL_NAME (TYPE_NAME (type)) > - && !strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))), "__fp16")) > - return "__fp16"; > + if (TREE_CODE (type) == REAL_TYPE > + && TYPE_PRECISION (type) == 16 > + && TYPE_MAIN_VARIANT (type) != float16_type_node) > + return "Dh"; > > /* Use the default mangling. */ > return NULL; > --- gcc/testsuite/g++.target/arm/pr107080.C.jj 2022-09-30 18:56:08.885797047 +0200 > +++ gcc/testsuite/g++.target/arm/pr107080.C 2022-09-30 18:58:07.812221153 +0200 > @@ -0,0 +1,16 @@ > +// PR c++/107080 > +// { dg-do compile } > +// { dg-options "-mfp16-format=ieee" } > + > +template > +int > +foo (T x, T1 y) > +{ > + return 3; > +} > + > +int > +main () > +{ > + return (foo (0.0f16, 0.0f16) + foo (0.0f16, (__fp16) 0.0)) != 6; > +} > --- gcc/testsuite/g++.target/aarch64/pr107080.C.jj 2022-09-30 18:56:08.885797047 +0200 > +++ gcc/testsuite/g++.target/aarch64/pr107080.C 2022-09-30 18:56:04.805851530 +0200 > @@ -0,0 +1,16 @@ > +// PR c++/107080 > +// { dg-do compile } > +// { dg-options "" } > + > +template > +int > +foo (T x, T1 y) > +{ > + return 3; > +} > + > +int > +main () > +{ > + return (foo (0.0f16, 0.0f16) + foo (0.0f16, (__fp16) 0.0)) != 6; > +} > > > Jakub >