public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
	gcc-patches@gcc.gnu.org, Bruce Korb <bkorb@gnu.org>
Subject: Re: [PATCH] c++: Implement P1467R9 - Extended floating-point types and standard names compiler part except for bfloat16 [PR106652]
Date: Mon, 12 Sep 2022 22:52:35 +0200	[thread overview]
Message-ID: <Yx+cEyCrrhs+tqf9@tucnak> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2209121927040.3025938@digraph.polyomino.org.uk>

On Mon, Sep 12, 2022 at 07:36:05PM +0000, Joseph Myers wrote:
> On Mon, 12 Sep 2022, Jakub Jelinek via Gcc-patches wrote:
> 
> > Now, I guess for the fixincludes it could also use
> > #  if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0))
> > where earlier GCC 13 snapshots would not be doing the fixincludes,
> > but the question is what to use for upstream glibc, because
> > there will be 13.0 snapshots where C++ doesn't support _Float{16,32,64,128}
> > and where it is essential to use what glibc has been doing previously
> > and using the #else would fail miserably, and then 13.0 snapshots where it
> > does support it and where using the if would fail miserably.
> 
> We don't claim in glibc to support old snapshots from master, so checking 
> for __GNUC_PREREQ (13, 0) and failing for such older GCC 13 versions is 
> fine.

Ok, makes sense, especially if it is applied on the glibc side a few months
after it is changed on the GCC side.  If it is applied immediately, there
could be people who have 2 weeks old GCC trunk snapshot and try it with latest
glibc, but if it will be say in December, it will be far less likely.

> > Conversion from BFmode to SFmode is easy, left shift by 16 and ought to be
> > implemented inline, SFmode -> BFmode conversion is harder,
> 
> Properly the right way for converting from BFmode to SFmode in the 
> presence of -fsignaling-nans should depend on how the result is used.  If 
> it's used for arithmetic, it's OK to have converted a BFmode signaling NaN 
> to an SFmode signaling NaN, but if e.g. the result is examined with 
> issignaling or otherwise stored so it may be significant later whether the 
> result is a quiet or signaling NaN, IEEE semantics would mean a signaling 
> NaN should be a converted to a quiet NaN with "invalid" raised.  Though I 
> don't know how far hardware instructions for BFmode attempt to follow IEEE 
> semantics.
> 
> (Cf. powerpc single-precision load instructions whose effect is defined as 
> a purely bitwise conversion from single to double precision, so that 
> single-precision load and store of a signaling NaN never end up converting 
> it to a quiet NaN even though the in-register format is double precision.)

Looking at HW instructions, I believe x86 F16C VCVTPH2PS and VCVTPS2PH
raise invalid on SNaN and turn it into QNaN and from what I can understand,
the AVX512F16 conversion insns like VCVTSH2SS and VCVTSS2SH do too,
but AVX512_BF16 VCVTNE2PS2BF16 doesn't raise any exceptions (and there is
no insn for the other direction).

> > (untested) and the question is if it should be implemented in libgcc
> > (and using soft-fp or not), or inline, or both depending on -Os.
> 
> Also if you try to do a direct conversion between BFmode and HFmode, 
> soft-fp's current support for conversions may not handle that case (where 
> one type has wider exponent range and other type has higher precision).

Can't that be implemented as 2 conversions, convert BFmode to SFmode and
then back to HFmode (or the other way around)?
SFmode is a superset of both formats, so except for the raise exception on
SNaN and conversion to QNaN extension to SFmode from both formats should be
lossless?

In any case, the bfloat16 support is intended maybe for follow-up patches,
not in this patch.

	Jakub


  reply	other threads:[~2022-09-12 20:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-12  8:05 Jakub Jelinek
2022-09-12 19:36 ` Joseph Myers
2022-09-12 20:52   ` Jakub Jelinek [this message]
2022-09-12 21:00     ` Jakub Jelinek
2022-09-13 17:50     ` Joseph Myers
2022-09-16 11:48 ` Jason Merrill
2022-09-16 17:34   ` Jakub Jelinek
2022-09-17  8:58     ` Jason Merrill
2022-09-19 16:39       ` Jakub Jelinek
2022-09-26 21:15         ` Jason Merrill
2022-09-26 22:11           ` Jakub Jelinek
2022-09-20  3:35 ` Hongtao Liu
2022-09-20  7:14   ` Hongtao Liu
2022-09-20  8:51   ` Jakub Jelinek
2022-09-22 15:56     ` [RFC PATCH] __trunc{tf,xf,df,sf,hf}bf2, __truncbfhf2 and __extendbfsf2 Jakub Jelinek
2022-09-23  0:44       ` Hongtao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yx+cEyCrrhs+tqf9@tucnak \
    --to=jakub@redhat.com \
    --cc=bkorb@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=jwakely@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).