[libc-commits] [libc] [libc][math][c++23] Add bfloat16 support in LLVM libc (PR #144463)
via libc-commits
libc-commits at lists.llvm.org
Sun Jul 6 20:16:45 PDT 2025
================
@@ -415,7 +415,11 @@ template <size_t Bits> struct DyadicFloat {
if constexpr (cpp::is_same_v<T, float16>)
return generic_as<T, ShouldSignalExceptions>();
#endif
- return fast_as<T, ShouldSignalExceptions>();
+ if constexpr (cpp::is_same_v<T, bfloat16>) {
+ return generic_as<T, ShouldSignalExceptions>();
+ } else {
+ return fast_as<T, ShouldSignalExceptions>();
+ }
}
----------------
overmighty wrote:
GitHub doesn't let me select lines 414 and above to suggest a change.
```cpp
LIBC_INLINE constexpr T as() const {
if constexpr (cpp::is_same_v<T, bfloat16>
#if defined(LIBC_TYPES_HAS_FLOAT16) && !defined(__LIBC_USE_FLOAT16_CONVERSION)
|| cpp::is_same_v<T, float16>
#endif
)
return generic_as<T, ShouldSignalExceptions>();
return fast_as<T, ShouldSignalExceptions>();
}
```
https://github.com/llvm/llvm-project/pull/144463
More information about the libc-commits
mailing list