From patchwork Wed Oct 19 08:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 4582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp205863wrs; Wed, 19 Oct 2022 01:50:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Gt0GNA4oHjFXdeoNE7vHldArq6zsEobdIXFTSX6VNNPj3PBQUjHlyfqqg8HTlVNaIyER7 X-Received: by 2002:a17:906:fc6:b0:72f:d080:416 with SMTP id c6-20020a1709060fc600b0072fd0800416mr5891627ejk.1.1666169452901; Wed, 19 Oct 2022 01:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169452; cv=none; d=google.com; s=arc-20160816; b=rfylFb8GklBxfoBRbNUVCxGvMhcB44L5si22M4zxdIRm4s7GrPf/KXedwhLUYr2bDd HhKtUk+YArXUqb/LpVX46wq4Pk5QHod1VboPJ0eEaz4GQVRAu9iKKjUdXXIKSss8Rae3 OIcLFpjpnvgsguAX+5NtdBoXFlRDdG/RBp6GPyPUA9953S0eTszFG33yyYwZv+KRtprX M/zXT83yCXYXJwTJNcjyjydhJ0KJqd5X0j5qx0z1Rjwd1Jcpfx/uTSdMNHdm6rqDe7gv GJt41F5dB3eUeLe1Y1uDZU+rQwws1dy2iwAshL+BaVOJubvBOMo13jzCpuDE4ILIH2qy UE3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=dHMSc3RHMSnbt4MUpLhUzXGhNtWH/UkSNSWidi5CN3w=; b=PUqbh4sS64tMN2TwJZctnA0J2Yq+7OpH9/Tc47x87CyveOz78p2uxlkTHyeYZRRtCi HzrTHlDodlPuWOtpEtFAfpQV+CCP2d+XzLxlEXpVAksH9yzdGOHrYJUb6SYthVCLPKxK +wfKo6PIthvqLP/FZg3DvUvhUfkjem1Uv0XSSIWQ7BQ1gBpQm+p2+5jesJAbFkS04hf/ NVTQqDwte5RVLbKnZabtPMWD+7bNZNzEDxa1/E/pc1+Co9/B/eDksR4MdijvqMwh71lR IxaA4UCSgcbWpCddLVNh++ffEQtMX1ZSEWCmQA0C0lFJo9kLkH7Wjz8Fk9Ra5NL1OhYb eryQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=D7FyUbM2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o19-20020a170906975300b00787b0b0a96esi5381547ejy.131.2022.10.19.01.50.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 01:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=D7FyUbM2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A3A83858034 for ; Wed, 19 Oct 2022 08:50:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A3A83858034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666169451; bh=dHMSc3RHMSnbt4MUpLhUzXGhNtWH/UkSNSWidi5CN3w=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=D7FyUbM2bHabDKDDwDwDLzvrj5bEJg6hEu1o989/tSeex0Pl9SiEaH2ME5sr1PQ9F BzCjnj2QdUOe8IU3SvU1PRqyJrTiwfvfPsiwvJs6FE/fGlj6a8wE7DgDFMrMZZkXaU 4IP9CVO6S3A/Vzw1DRqMhNmgi8J/uRNQPNvmHT3I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 8F7383858D39 for ; Wed, 19 Oct 2022 08:50:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F7383858D39 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-670-A3iiObDjMzyjvqKKBow_XQ-1; Wed, 19 Oct 2022 04:50:05 -0400 X-MC-Unique: A3iiObDjMzyjvqKKBow_XQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CACA886C051; Wed, 19 Oct 2022 08:50:04 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85958492B1E; Wed, 19 Oct 2022 08:50:04 +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 29J8o0g93797327 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 10:50:01 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29J8o0wM3797326; Wed, 19 Oct 2022 10:50:00 +0200 Date: Wed, 19 Oct 2022 10:50:00 +0200 To: Uros Bizjak Subject: [PATCH] i386: Fix up __bf16 handling on ia32 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747105300178788701?= X-GMAIL-MSGID: =?utf-8?q?1747105300178788701?= Hi! Last night's testing of the libstdc++ changes revealed a problem in the __bf16 backend registration (while _Float16 seems ok). The problem is that for both BFmode and HFmode we require TARGET_SSE2, the generic code creates {,b}float16_type_node only if that is true at the start of the TU and the builtins for the type are only created in that case (many __builtin_*f16 for HFmode and __builtin_nansf16b for BFmode). Now, for _Float16 I've kept what the code did previously, if float16_type_node from generic code is NULL, create ix86_float16_type_node and register _Float16 for it, but for __bf16 I've changed it so that if bfloat16_type_node from generic code is NULL, ix86_register_bf16_builtin_type makes bfloat16_type_node non-NULL. This has an unfortunate consequence though, __STDCPP_BFLOAT16_T__ is predefined for C++23, __BFLT16_*__ macros are predefined as well, but the type doesn't really work (errors whenever it is used) and the builtin isn't defined. The following patch fixes that by going with what we do for HFmode, bfloat16_type_node stays as initialized by generic code and we have a local type for backend use. On the other side, nothing used ix86_bf16_ptr_type_node so that is now dropped. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-10-19 Jakub Jelinek * config/i386/i386-builtins.cc (ix86_bf16_ptr_type_node): Remove. (ix86_bf16_type_node): New variable. (ix86_register_bf16_builtin_type): If bfloat16_type_node is NULL from generic code, set only ix86_bf16_type_node to a new REAL_TYPE rather than bfloat16_type_node, otherwise set ix86_bf16_type_node to bfloat16_type_node. Register __bf16 on ix86_bf16_type_node rather than bfloat16_type_node. Don't initialize unused ix86_bf16_ptr_type_node. * config/i386/i386-builtin-types.def (BFLOAT16): Use ix86_bf16_type_node rather than bfloat16_type_node. Jakub --- gcc/config/i386/i386-builtins.cc.jj 2022-10-14 22:32:30.088698145 +0200 +++ gcc/config/i386/i386-builtins.cc 2022-10-19 01:11:33.685164338 +0200 @@ -126,7 +126,7 @@ BDESC_VERIFYS (IX86_BUILTIN_MAX, static GTY(()) tree ix86_builtin_type_tab[(int) IX86_BT_LAST_CPTR + 1]; tree ix86_float16_type_node = NULL_TREE; -tree ix86_bf16_ptr_type_node = NULL_TREE; +tree ix86_bf16_type_node = NULL_TREE; /* Retrieve an element from the above table, building some of the types lazily. */ @@ -1373,17 +1373,16 @@ ix86_register_bf16_builtin_type (void) { if (bfloat16_type_node == NULL_TREE) { - bfloat16_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (bfloat16_type_node) = 16; - SET_TYPE_MODE (bfloat16_type_node, BFmode); - layout_type (bfloat16_type_node); + ix86_bf16_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (ix86_bf16_type_node) = 16; + SET_TYPE_MODE (ix86_bf16_type_node, BFmode); + layout_type (ix86_bf16_type_node); } + else + ix86_bf16_type_node = bfloat16_type_node; if (!maybe_get_identifier ("__bf16") && TARGET_SSE2) - { - lang_hooks.types.register_builtin_type (bfloat16_type_node, "__bf16"); - ix86_bf16_ptr_type_node = build_pointer_type (bfloat16_type_node); - } + lang_hooks.types.register_builtin_type (ix86_bf16_type_node, "__bf16"); } static void --- gcc/config/i386/i386-builtin-types.def.jj 2022-10-14 22:32:30.088698145 +0200 +++ gcc/config/i386/i386-builtin-types.def 2022-10-19 01:11:58.030845416 +0200 @@ -69,7 +69,7 @@ DEF_PRIMITIVE_TYPE (UINT16, short_unsign DEF_PRIMITIVE_TYPE (INT64, long_long_integer_type_node) DEF_PRIMITIVE_TYPE (UINT64, long_long_unsigned_type_node) DEF_PRIMITIVE_TYPE (FLOAT16, ix86_float16_type_node) -DEF_PRIMITIVE_TYPE (BFLOAT16, bfloat16_type_node) +DEF_PRIMITIVE_TYPE (BFLOAT16, ix86_bf16_type_node) DEF_PRIMITIVE_TYPE (FLOAT, float_type_node) DEF_PRIMITIVE_TYPE (DOUBLE, double_type_node) DEF_PRIMITIVE_TYPE (FLOAT80, float80_type_node)