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.129.124]) by sourceware.org (Postfix) with ESMTPS id A2F983858D1E for ; Fri, 30 Sep 2022 17:49:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A2F983858D1E 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=1664560151; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=hyAZgdk4SVwmO+pC9R/5bypo309+Jfi2bpqUNy6/UhQ=; b=QHepLqy5FUgoLAjhUx377y1ADA6FyP7YyoCCqfRW7YaUDw6fzo8128q+NyPFpQrCV9Lr39 kagpxwJ54xpvGknvBbPaemrOnvTJCmbpLv67EoHHOkxbtYBZw8zgIoRnh7cmQkAY4onPuR q88Zl8PaU0jDmsb4Tiiqfe8DptAJtg0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-533-UDtIm1YVPne4oYbqQAFldg-1; Fri, 30 Sep 2022 13:49:08 -0400 X-MC-Unique: UDtIm1YVPne4oYbqQAFldg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADCD4800186; Fri, 30 Sep 2022 17:49:07 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63E56492CA4; Fri, 30 Sep 2022 17:49:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28UHn47R091403 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 30 Sep 2022 19:49:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28UHn3kx091402; Fri, 30 Sep 2022 19:49:03 +0200 Date: Fri, 30 Sep 2022 19:49:03 +0200 From: Jakub Jelinek To: Jason Merrill , gcc-patches@gcc.gnu.org, Richard Earnshaw , Kyrylo Tkachov , richard.sandiford@arm.com Subject: Re: [PATCH] arm, aarch64, csky: Fix C++ ICEs with _Float16 and __fp16 [PR107080] Message-ID: Reply-To: Jakub Jelinek References: <60f5d708-a233-2c36-6f74-ae064fdf6ffd@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Fri, Sep 30, 2022 at 06:38:39PM +0100, Richard Sandiford wrote: > OK for the aarch64 part, thanks. But could you add some scan-assemblers > to the test to check for the mangled names? I assume they should be: Ok, about to commit the aarch64 part, will await review of the rest afterwards. > > _Z3fooIDF16_DF16_EiT_T0_ > _Z3fooIDF16_DhEiT_T0_ > > (which is what clang produces). Indeed, that is what we now get. Added. 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,19 @@ +// 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; +} + +// { dg-final { scan-assembler "_Z3fooIDF16_DF16_EiT_T0_" } } +// { dg-final { scan-assembler "_Z3fooIDF16_DhEiT_T0_" } } --- 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 19:45:08.657342253 +0200 @@ -0,0 +1,19 @@ +// 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; +} + +// { dg-final { scan-assembler "_Z3fooIDF16_DF16_EiT_T0_" } } +// { dg-final { scan-assembler "_Z3fooIDF16_DhEiT_T0_" } } Jakub