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 A1D673858D28 for ; Tue, 20 Sep 2022 08:51:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1D673858D28 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=1663663891; h=from:from:reply-to: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=+X/3XoMB3D46+iNQvh1f9aQh6zM8qe8RkjNBiAWboAk=; b=AsNZ/Scz7wL2RCQ8MZOUB6Ve4k4RkXbtKoBHTyca3OPylqGpnrc45MYDHioXS0BGtbHMgX 6PcnxwAFVs/yNn6jscwIPMbXgWmpOyB+EwvusMJTQmvlqbWIdrafiFPyS1yIIhpAszGINd Dq9RcEXe1U+CcSdmUbpovy8Kn+v49e4= 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-362-N5knuI6NNZKGpuZ0r3l-Mg-1; Tue, 20 Sep 2022 04:51:24 -0400 X-MC-Unique: N5knuI6NNZKGpuZ0r3l-Mg-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 1B7A4185A79C; Tue, 20 Sep 2022 08:51:24 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE51040C6EC2; Tue, 20 Sep 2022 08:51:23 +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 28K8pKQH668322 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:51:21 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28K8pJo3668321; Tue, 20 Sep 2022 10:51:19 +0200 Date: Tue, 20 Sep 2022 10:51:18 +0200 From: Jakub Jelinek To: Hongtao Liu Cc: Jason Merrill , Jonathan Wakely , "Joseph S. Myers" , Bruce Korb , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: Implement P1467R9 - Extended floating-point types and standard names compiler part except for bfloat16 [PR106652] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: 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.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 Tue, Sep 20, 2022 at 11:35:07AM +0800, Hongtao Liu wrote: > > The question is (mainly for aarch64, arm and x86 backend maintainers) if we > > shouldn't support it, in the PR there is a partial patch to do so, but > > the big question is if it should be supported as the __bf16 type those > > 3 targets use with u6__bf16 mangling and remove those *_invalid_* cases > > and add conversions to/from at least SFmode but probably also DFmode, TFmode > > and XFmode on x86 and implement arithmetics on those through conversion to > > SFmode, performing arithmetics there and conversion back. > > Conversion from BFmode to SFmode is easy, left shift by 16 and ought to be > > implemented inline, SFmode -> BFmode conversion is harder, > > I think it is roughly: > I'm not sure if there should be any floating point exceptions for > BFmode operation. > For x86, there's no floating point exceptions for AVX512_BF16 related > instructions As long as __bf16 is just an extension, supporting or not supporting exceptions on sNaNs is just fine I think, but I'm afraid it is different for std::bfloat16_t. If we claim we support it (define that type in , predefine __STD_BFLOAT16_TYPE__), then it needs to follow ISO/IEC/IEEE 60559, and I'm afraid that means also exceptions and the like. While the IEEE spec doesn't cover the exact bfloat16 format, C++ talks about a format with these and these number of bits here and there that behaves like in IEEE otherwise. Whether we support std::bfloat16_t at all is our choice, if we do support it, whether we support it with __bf16 underlying type or come up with something different, it is up to us, and with -ffast-math/-Ofast etc. we can certainly use hw instructions for it which don't raise exceptions. At least that is my limited understanding of it... Jakub