Message ID | Y2I62a8i1u1I7EaE@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3515034wru; Wed, 2 Nov 2022 02:40:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Rc+wH4+Kgu+CFivhn0x08lX6tlK7Z5PmpMk38g2SHpqsP9Pr/S9dWWGyRoxgqevFlLNFI X-Received: by 2002:a05:6402:22f1:b0:462:f6eb:6c6b with SMTP id dn17-20020a05640222f100b00462f6eb6c6bmr22983996edb.365.1667382029983; Wed, 02 Nov 2022 02:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667382029; cv=none; d=google.com; s=arc-20160816; b=gLKqCSMTuT8qTzARI1YgnF8kHZ3vZHGbVrIHUlgBOcZm1EcM9NHgbGNSRC3HSDt7vl D3YjTtof0HcQvMvEQN2NR8W+pT9csDbmIpKjYrI0jhqzTtDeVIgLJJkZVQKyWrLO2iiB qwJcwInTK23uPOSF4TO5dGtuVfjJPybRIePr3L5GxqlQMPgvVY1ac3Yo9+jQc7rLcZs7 QBYl5OlvIMh5uV3LalfhUuBg2Rx8ZiLLUXsy8yJzTurdt0KvDFdWuajTDUr4G6kflRiE bdeFhFv8qWTo5q7Kuvdm7w9LEQUMk2ChrNA1jHru+zm5QiYCD70lwD+2m6zxpwWfpAeD cd3A== 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=duvFFBYZzw7RIqKJI4WnQ6JAi9JwTDCIGbjG9CqgSZI=; b=yHi4iUMSo/1buhezAL/KWuc5aeDjSOTlPYs81K3wkRZAW+MeO1JRUV5iKHSmRdV8m8 MUcqodEJFuqldiJaWLWzvGndEKe1YIOb9pswVk2xMwFXNnq4Pj13WpQqBDAuQl95VDpl VzBbKYLxHa7sEiVB95GxbZSW4nvvEIGDjTlIUnNvY4XRKrCKlP8tW87Un4Fs0iF//7bA Z2Y188+QfZ2zFx0AGV2HYFUhIRllLx+AQfh/H1NTlITux3JyEufDLNh0mnvRHz1tDKa9 vlMOrZ8uCSZVhGvQdRNekLfg3PR3Y+0wt5GIUrV4EsWz7UYc8YNQYJ4CJIF9m0h9riaZ uiaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=bd3AGjvU; 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 my15-20020a1709065a4f00b0078db6f488c2si12022456ejc.56.2022.11.02.02.40.29 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 02:40:29 -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=bd3AGjvU; 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 BF6E23858014 for <ouuuleilei@gmail.com>; Wed, 2 Nov 2022 09:40:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF6E23858014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667382028; bh=duvFFBYZzw7RIqKJI4WnQ6JAi9JwTDCIGbjG9CqgSZI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=bd3AGjvUfJ+EsFLMEfxiYaPbhQ8W8KNGs1rY25PhHdZBouKaj5FDCejNyufdPCkXa 7qERuw/IjeRccI6ftcLBxoXBFADpRCaD6nHs/xrz8eofRy/Zbyhpa+oqoWdGeI8i7D iRFK5Fvf1w/u2o46V9eEDQe4igPn4cx/qNYa/4Xg= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id C607B3858D28 for <gcc-patches@gcc.gnu.org>; Wed, 2 Nov 2022 09:39:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C607B3858D28 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-pFCrIyOaPrmlL-TGlumDTg-1; Wed, 02 Nov 2022 05:39:41 -0400 X-MC-Unique: pFCrIyOaPrmlL-TGlumDTg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 89C851C09B72 for <gcc-patches@gcc.gnu.org>; Wed, 2 Nov 2022 09:39:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4953140C94CE; Wed, 2 Nov 2022 09:39:40 +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 2A29dbSQ2091873 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 2 Nov 2022 10:39:38 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2A29db382091872; Wed, 2 Nov 2022 10:39:37 +0100 Date: Wed, 2 Nov 2022 10:39:37 +0100 To: Jonathan Wakely <jwakely@redhat.com>, Patrick Palka <ppalka@redhat.com> Subject: [PATCH] libstdc++: _Bfloat16 for <compare> Message-ID: <Y2I62a8i1u1I7EaE@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748376779343636410?= X-GMAIL-MSGID: =?utf-8?q?1748376779343636410?= |
Series |
libstdc++: _Bfloat16 for <compare>
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
Nov. 2, 2022, 9:39 a.m. UTC
Hi! Jon pointed out that we have TODO: _Bfloat16 in <compare>. Right now _S_fp_fmt() returns _Binary16 for _Float16, __fp16 as well as __bf16 and it actually works because we don't have a special handling of _Binary16. So, either we could just document that, but I'm a little bit afraid if HPPA or MIPS don't start supporting _Float16 and/or __bf16. If they do, we have the #if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008) // IEEE 754-1985 allowed the meaning of the quiet/signaling // bit to be reversed. Flip that to give desired ordering. if (__builtin_isnan(__x) && __builtin_isnan(__y)) { using _Int = decltype(__ix); constexpr int __nantype = __fmt == _Binary32 ? 22 : __fmt == _Binary64 ? 51 : __fmt == _Binary128 ? 111 : -1; constexpr _Int __bit = _Int(1) << __nantype; __ix ^= __bit; __iy ^= __bit; } #endif code, the only one where we actually care whether something is _Binary{32,64,128} (elsewhere we just care about the x86 and m68k 80bits or double double or just floating point type's sizeof) and we'd need to handle there _Binary16 and/or _Bfloat16. So this patch uses different enum for it even when it isn't needed right now, after all _Binary16 isn't needed either and we could just use _Binary32... Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-11-02 Jakub Jelinek <jakub@redhat.com> * libsupc++/compare (_Strong_order::_Fp_fmt): Add _Bfloat16. (_Strong_order::_Bfloat16): New static data member. (_Strong_order::_S_fp_fmt): Return _Bfloat16 for std::bfloat16_t. Jakub
Comments
On Wed, 2 Nov 2022 at 09:39, Jakub Jelinek <jakub@redhat.com> wrote: > > Hi! > > Jon pointed out that we have TODO: _Bfloat16 in <compare>. > Right now _S_fp_fmt() returns _Binary16 for _Float16, __fp16 as well > as __bf16 and it actually works because we don't have a special handling > of _Binary16. So, either we could just document that, but I'm a little bit > afraid if HPPA or MIPS don't start supporting _Float16 and/or __bf16. > If they do, we have the > #if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008) > // IEEE 754-1985 allowed the meaning of the quiet/signaling > // bit to be reversed. Flip that to give desired ordering. > if (__builtin_isnan(__x) && __builtin_isnan(__y)) > { > using _Int = decltype(__ix); > > constexpr int __nantype = __fmt == _Binary32 ? 22 > : __fmt == _Binary64 ? 51 > : __fmt == _Binary128 ? 111 > : -1; > constexpr _Int __bit = _Int(1) << __nantype; > __ix ^= __bit; > __iy ^= __bit; > } > #endif > code, the only one where we actually care whether something is > _Binary{32,64,128} (elsewhere we just care about the x86 and m68k 80bits > or double double or just floating point type's sizeof) and we'd need > to handle there _Binary16 and/or _Bfloat16. > > So this patch uses different enum for it even when it isn't needed right > now, after all _Binary16 isn't needed either and we could just use > _Binary32... > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK, thanks for taking care of it. > > 2022-11-02 Jakub Jelinek <jakub@redhat.com> > > * libsupc++/compare (_Strong_order::_Fp_fmt): Add _Bfloat16. > (_Strong_order::_Bfloat16): New static data member. > (_Strong_order::_S_fp_fmt): Return _Bfloat16 for std::bfloat16_t. > > --- libstdc++-v3/libsupc++/compare.jj 2022-05-09 09:09:21.196461093 +0200 > +++ libstdc++-v3/libsupc++/compare 2022-11-01 22:13:16.771219615 +0100 > @@ -672,7 +672,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul > _X86_80bit, // x86 80-bit extended precision > _M68k_80bit, // m68k 80-bit extended precision > _Dbldbl, // IBM 128-bit double-double > - // TODO: _Bfloat16, > + _Bfloat16, // std::bfloat16_t > }; > > #ifndef __cpp_using_enum > @@ -684,6 +684,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul > static constexpr _Fp_fmt _X86_80bit = _Fp_fmt::_X86_80bit; > static constexpr _Fp_fmt _M68k_80bit = _Fp_fmt::_M68k_80bit; > static constexpr _Fp_fmt _Dbldbl = _Fp_fmt::_Dbldbl; > + static constexpr _Fp_fmt _Bfloat16 = _Fp_fmt::_Bfloat16; > #endif > > // Identify the format used by a floating-point type. > @@ -714,6 +715,10 @@ namespace std _GLIBCXX_VISIBILITY(defaul > if constexpr (__is_same(_Tp, __float80)) > return _X86_80bit; > #endif > +#ifdef __STDCPP_BFLOAT16_T__ > + if constexpr (__is_same(_Tp, decltype(0.0bf16))) > + return _Bfloat16; > +#endif > > constexpr int __width = sizeof(_Tp) * __CHAR_BIT__; > > > Jakub >
--- libstdc++-v3/libsupc++/compare.jj 2022-05-09 09:09:21.196461093 +0200 +++ libstdc++-v3/libsupc++/compare 2022-11-01 22:13:16.771219615 +0100 @@ -672,7 +672,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul _X86_80bit, // x86 80-bit extended precision _M68k_80bit, // m68k 80-bit extended precision _Dbldbl, // IBM 128-bit double-double - // TODO: _Bfloat16, + _Bfloat16, // std::bfloat16_t }; #ifndef __cpp_using_enum @@ -684,6 +684,7 @@ namespace std _GLIBCXX_VISIBILITY(defaul static constexpr _Fp_fmt _X86_80bit = _Fp_fmt::_X86_80bit; static constexpr _Fp_fmt _M68k_80bit = _Fp_fmt::_M68k_80bit; static constexpr _Fp_fmt _Dbldbl = _Fp_fmt::_Dbldbl; + static constexpr _Fp_fmt _Bfloat16 = _Fp_fmt::_Bfloat16; #endif // Identify the format used by a floating-point type. @@ -714,6 +715,10 @@ namespace std _GLIBCXX_VISIBILITY(defaul if constexpr (__is_same(_Tp, __float80)) return _X86_80bit; #endif +#ifdef __STDCPP_BFLOAT16_T__ + if constexpr (__is_same(_Tp, decltype(0.0bf16))) + return _Bfloat16; +#endif constexpr int __width = sizeof(_Tp) * __CHAR_BIT__;