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 362F53858C83 for ; Wed, 2 Nov 2022 11:16:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 362F53858C83 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=1667387812; 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: in-reply-to:in-reply-to:references:references; bh=BWfh3zEn+xFXufu4cq2Xmv09beVhta26b0xmYY7IRfk=; b=NeTcnfNXywVU6iJCN+bbOtZUR3cbYQWoBbaTOfm9vuhh58QpKxXUHirsqj1z5044AYNtO0 9CsJeCGf6IHWJE28DGyk2YBPeaIRdhCE53j/4SfZTwx43wi2evysUq+YzX05sn2Ue/cwY6 pvB1O63pHopHFodL7AbSV5ehwE83DQg= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-562-87BsVLrWPXaQwFlc83mmog-1; Wed, 02 Nov 2022 07:16:51 -0400 X-MC-Unique: 87BsVLrWPXaQwFlc83mmog-1 Received: by mail-ej1-f72.google.com with SMTP id qw17-20020a1709066a1100b0078e25b6a52fso9641319ejc.3 for ; Wed, 02 Nov 2022 04:16:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BWfh3zEn+xFXufu4cq2Xmv09beVhta26b0xmYY7IRfk=; b=HuLngL+Bb+lJv/yW4ofhFkRKPCmkhRaYczuBHPoSh+YrU/RK9TibP/HvNkOVmT6MN9 L7MT5nh2SPpdvSVsQR90RvAi85v/a3AWzwesW7cUTLvZR8ux1grcD01B2XTcpqb32wwP x9tfwH4wBDWdJFS+1L2UUq6QqJOB99zP5Xa4FDEHn1uShMkcThHew0o80rzbmgW+HKyZ Q6l8leWRJF9Yxhal5YC1Wu0ZxgPJJWUd9NH9dr4Ur8dW37dsoCEIb1+e5znB7H2Pv5yK TQj38SkZFIvszoeMYER9+qLfza81svw+u7gxNx+RgZ2cmQdBhBqPTvdhtPCNOsfcnUim eX3A== X-Gm-Message-State: ACrzQf2YEtgS1y9O1hLs1pVf1gtpDk3zuGpY1i/J0Psajnjr0cUuYI+x S0hTarn6qwdpwX3Sh0L3A5CN9AM+1HbhtwYwVR1jXOYfC47V9SIXRh1DxNpbJUL3C7DTqK1vpGg 4vS8Y7SsOHArBdjcFSpLTJUAmBy4tCGQVUA== X-Received: by 2002:a17:906:cc58:b0:7a9:6b4e:79e4 with SMTP id mm24-20020a170906cc5800b007a96b4e79e4mr22472118ejb.57.1667387810507; Wed, 02 Nov 2022 04:16:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76u4SvAm3iCMPFt5b0bUYXDq0y3QwBWJw5vSHyAN7OXTXUwFBqQxQyJIidz7xWaFYQB3ML3Juar10ldRI/0LM= X-Received: by 2002:a17:906:cc58:b0:7a9:6b4e:79e4 with SMTP id mm24-20020a170906cc5800b007a96b4e79e4mr22472102ejb.57.1667387810250; Wed, 02 Nov 2022 04:16:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 2 Nov 2022 11:16:39 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: _Bfloat16 for To: Jakub Jelinek Cc: Patrick Palka , gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 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 List-Id: On Wed, 2 Nov 2022 at 09:39, Jakub Jelinek wrote: > > Hi! > > Jon pointed out that we have TODO: _Bfloat16 in . > 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 > > * 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 >