On Wed, Nov 05, 2025 at 09:56:21AM -0500, Michael Meissner wrote:
> On Wed, Nov 05, 2025 at 10:34:37AM +0100, Jakub Jelinek wrote:
> > On Wed, Nov 05, 2025 at 03:48:46AM -0500, Michael Meissner wrote:
> > > This set of patches is a request for comments (RFC) on the support to
> > > add 16-bit floating point support to the GCC 16 PowerPC.  In GCC 16, I
> > > anticipate this will be listed as an experimental feature, to allow
> > > the code to be refined by the time GCC 17 ships.
> > > 
> > > There are 2 popular 16-bit floating point formats.
> > 
> > One thing I'm missing in the patchset is libstdc++-v3 part of this.
> > I assume that with -mfloat16 -std=c++23 g++ will predefine the
> > __STDCPP_FLOAT16_T__ and __STDCPP_BFLOAT16_T__ macros (some 
> > g++.target/powerpc
> > test should test that), so that enables all of libstdc++ std::float16_t
> > and std::bfloat16_t support.
> 
> I have a patch that isn't part of the current set (but hopefully will
> be) that adds a configuration option to enable the 16-bit types by
> default and another to disable the call/return warning.
> 
> If I enable __bfloat16_t, I can't build libstdc++ because
> include/limits uses __builtin_nansfb16, which I haven't added yet, and

Should be __builtin_nansf16b.
And I think that should work as long as you have bfloat16_type_node.

> I have debugged why it isn't added automatically.
> 
> My patch uses __builtin_nansf and converts it, much like a few lines
> earlier, the include file limit used __builtn_nanf and converts it to
> __bfloat16.

That is something that works for __builtin_nanf, but doesn't work for
__builtin_nansf, because the conversion between the floating point formats
on sNaN should already throw.
Another case where one can't just cast to/from IEEE single float is
nextafter, so __builtin_nextafterf16 and __builtin_nextafterf16b are needed
so that constant evaluation can handle those.  WHen not constant evaluated
there is runtime code to handle those.

> 
> > Now, for <charconv> std::from_chars and std::to_chars overloads the
> > __{from,to}_chars_{,b}float16_t helper functions are exported from libstdc++
> > for some years already whenever _Float32 is defined (i.e. when float is IEEE
> > single) at some older symbol version (because those functions just use float
> > rather than _Float16 or decltype (1.0bf16) types in their ABI).
> > But _ZTI{,P,PK}DF16{_,b} symbols needed for std::float16_t and
> > std::bfloat16_t RTTI are presumably not exported from libstdc++ and would be
> > when libstdc++ is built with -mfloat16 and are actually needed in this
> > patchset even when libstdc++ isn't built with that option, because code
> > built with -mfloat16 -std=c++23 can use typeid (std::float16_t) or
> > typeid (std::bfloat16_t) etc.
> 
> Ok.  Is there a test for these issues that I can run before submission?

git grep -l float16 gcc/testsuite/g++.dg libstdc++-v3/testsuite | sort
gcc/testsuite/g++.dg/abi/mangle-neon-aarch64.C
gcc/testsuite/g++.dg/abi/mangle-neon.C
gcc/testsuite/g++.dg/abi/pr121801.C
gcc/testsuite/g++.dg/cpp0x/constexpr-104472.C
gcc/testsuite/g++.dg/cpp23/ext-floating12.C
gcc/testsuite/g++.dg/cpp23/ext-floating14.C
gcc/testsuite/g++.dg/cpp23/ext-floating16.C
gcc/testsuite/g++.dg/cpp23/ext-floating17.C
gcc/testsuite/g++.dg/cpp23/ext-floating1.C
gcc/testsuite/g++.dg/cpp23/ext-floating2.C
gcc/testsuite/g++.dg/cpp23/ext-floating3.C
gcc/testsuite/g++.dg/cpp23/ext-floating4.C
gcc/testsuite/g++.dg/cpp23/ext-floating6.C
gcc/testsuite/g++.dg/cpp23/ext-floating7.C
gcc/testsuite/g++.dg/cpp23/ext-floating.h
gcc/testsuite/g++.dg/ext/is_implicit_lifetime.C
gcc/testsuite/g++.dg/modules/target-aarch64-1_a.C
gcc/testsuite/g++.dg/modules/target-aarch64-1_b.C
gcc/testsuite/g++.dg/reflect/type_trait12.C
libstdc++-v3/testsuite/18_support/headers/limits/synopsis_cxx23.cc
libstdc++-v3/testsuite/18_support/headers/stdfloat/types_std.cc
libstdc++-v3/testsuite/20_util/to_chars/float16_c++23.cc
libstdc++-v3/testsuite/26_numerics/complex/ext_c++23.cc
libstdc++-v3/testsuite/26_numerics/complex/tuple_like.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/117406.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std_c++23.cc
libstdc++-v3/testsuite/26_numerics/headers/cmath/nextafter_c++23.cc
libstdc++-v3/testsuite/26_numerics/numbers/4.cc
libstdc++-v3/testsuite/29_atomics/atomic_float/requirements_cxx23.cc
libstdc++-v3/testsuite/std/format/arguments/args.cc
libstdc++-v3/testsuite/std/format/formatter/ext_float.cc
libstdc++-v3/testsuite/std/format/parse_ctx.cc

?

        Jakub

Reply via email to