Skip to content

[libc][math][c++23] Implement comparison operations operator overloads for BFloat16 #150087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2025

Conversation

krishna2803
Copy link
Contributor

@krishna2803 krishna2803 commented Jul 22, 2025

No description provided.

@llvmbot llvmbot added the libc label Jul 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 22, 2025

@llvm/pr-subscribers-libc

Author: Krishna Pandey (krishna2803)

Changes

cc @overmighty @lntue


Full diff: https://github.com/llvm/llvm-project/pull/150087.diff

2 Files Affected:

  • (modified) libc/src/__support/FPUtil/CMakeLists.txt (+1)
  • (modified) libc/src/__support/FPUtil/bfloat16.h (+25)
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index f157d90abb8aa..372eba374d8eb 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -274,6 +274,7 @@ add_header_library(
     bfloat16.h
   DEPENDS
     .cast
+    .comparison_operations
     .dyadic_float
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.type_traits
diff --git a/libc/src/__support/FPUtil/bfloat16.h b/libc/src/__support/FPUtil/bfloat16.h
index bc0b8b23896fc..05edbba048cb7 100644
--- a/libc/src/__support/FPUtil/bfloat16.h
+++ b/libc/src/__support/FPUtil/bfloat16.h
@@ -12,6 +12,7 @@
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/comparison_operations.h"
 #include "src/__support/FPUtil/dyadic_float.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/types.h"
@@ -57,6 +58,30 @@ struct BFloat16 {
     uint32_t x_bits = static_cast<uint32_t>(bits) << 16U;
     return cpp::bit_cast<float>(x_bits);
   }
+
+  LIBC_INLINE constexpr bool operator==(BFloat16 other) const {
+    return fputil::equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator!=(BFloat16 other) const {
+    return !fputil::equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator<(BFloat16 other) const {
+    return fputil::less_than(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator<=(BFloat16 other) const {
+    return fputil::less_than_or_equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator>(BFloat16 other) const {
+    return fputil::greater_than(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator>=(BFloat16 other) const {
+    return fputil::greater_than_or_equals(*this, other);
+  }
 }; // struct BFloat16
 
 } // namespace fputil

@lntue lntue requested review from overmighty and lntue July 22, 2025 19:11
@@ -57,6 +58,30 @@ struct BFloat16 {
uint32_t x_bits = static_cast<uint32_t>(bits) << 16U;
return cpp::bit_cast<float>(x_bits);
}

LIBC_INLINE constexpr bool operator==(BFloat16 other) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to suggest const BFloat16 &other but it doesn't impact codegen since BFloat16 is just a wrapper around uint16_t.

@overmighty overmighty changed the title [libc][c++23][math] Implement comparison operations operator overloads for BFloat16 [libc][math][c++23] Implement comparison operations operator overloads for BFloat16 Jul 23, 2025
@overmighty
Copy link
Member

Renamed the PR from "[libc][c++23][math]" to "[libc][math][c++23]" for consistency unless I missed something.

@overmighty overmighty merged commit 594b6f7 into llvm:main Jul 23, 2025
16 of 21 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 23, 2025

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/104/builds/27494

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcAtolTest.NotNumbers (1 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[686/1273] Running unit test libc.test.src.stdlib.atof_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcAToFTest.SimpleTest
[       OK ] LlvmLibcAToFTest.SimpleTest (6 us)
[ RUN      ] LlvmLibcAToFTest.FailedParsingTest
[       OK ] LlvmLibcAToFTest.FailedParsingTest (1 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[687/1273] Building CXX object libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o
FAILED: libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc -isystem libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -std=gnu++17 -MD -MT libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o -MF libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o.d -o libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:62:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator==(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:63:12: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::equals(*this, other);
           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:66:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator!=(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:67:13: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return !fputil::equals(*this, other);
            ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:70:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:71:12: note: non-constexpr function 'less_than<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than(*this, other);
           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:55:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> less_than(T x,
                                                                ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:74:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<=(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:75:12: note: non-constexpr function 'less_than_or_equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than_or_equals(*this, other);
           ^
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[       OK ] LlvmLibcAtolTest.NotNumbers (1 us)
Ran 3 tests.  PASS: 3  FAIL: 0
[686/1273] Running unit test libc.test.src.stdlib.atof_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcAToFTest.SimpleTest
[       OK ] LlvmLibcAToFTest.SimpleTest (6 us)
[ RUN      ] LlvmLibcAToFTest.FailedParsingTest
[       OK ] LlvmLibcAToFTest.FailedParsingTest (1 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[687/1273] Building CXX object libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o
FAILED: libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc -isystem libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -std=gnu++17 -MD -MT libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o -MF libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o.d -o libc/test/src/__support/FPUtil/CMakeFiles/libc.test.src.__support.FPUtil.bfloat16_test.__unit__.__build__.dir/bfloat16_test.cpp.o -c /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:62:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator==(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:63:12: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::equals(*this, other);
           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:66:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator!=(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:67:13: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return !fputil::equals(*this, other);
            ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:70:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:71:12: note: non-constexpr function 'less_than<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than(*this, other);
           ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:55:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> less_than(T x,
                                                                ^
In file included from /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/__support/FPUtil/bfloat16_test.cpp:9:
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:74:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<=(BFloat16 other) const {
                             ^
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/src/__support/FPUtil/bfloat16.h:75:12: note: non-constexpr function 'less_than_or_equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than_or_equals(*this, other);
           ^

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 23, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building libc at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/39077

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: lld :: COFF/dtlto/options.test (98819 of 101829)
PASS: lit :: shtest-external-shell-kill.py (98820 of 101829)
PASS: lld :: COFF/debug-reloc.s (98821 of 101829)
PASS: lld :: COFF/dllexport-mingw.s (98822 of 101829)
PASS: lld :: COFF/duplicate.test (98823 of 101829)
PASS: lld :: COFF/dtlto/files.test (98824 of 101829)
PASS: lld :: COFF/deploadflag-cfg-short.s (98825 of 101829)
PASS: lld :: COFF/delayimports32.test (98826 of 101829)
PASS: lit :: discovery.py (98827 of 101829)
TIMEOUT: MLIR :: Examples/standalone/test.toy (98828 of 101829)
******************** TEST 'MLIR :: Examples/standalone/test.toy' FAILED ********************
Exit Code: 1
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" "/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone" -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang  -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  -DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake /build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout------------
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
# | -- Using MLIRConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 23, 2025

LLVM Buildbot has detected a new failure on builder libc-arm32-debian-dbg running on libc-arm32-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/182/builds/12655

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcTypeTraitsTest.is_signed
[       OK ] LlvmLibcTypeTraitsTest.is_signed (24 us)
[ RUN      ] LlvmLibcTypeTraitsTest.is_unsigned
[       OK ] LlvmLibcTypeTraitsTest.is_unsigned (18 us)
[ RUN      ] LlvmLibcTypeTraitsTest.true_type
[       OK ] LlvmLibcTypeTraitsTest.true_type (9 us)
[ RUN      ] LlvmLibcTypeTraitsTest.has_unique_object_representations
[       OK ] LlvmLibcTypeTraitsTest.has_unique_object_representations (12 us)
Ran 66 tests.  PASS: 66  FAIL: 0
[34/749] Building CXX object libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o
FAILED: libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o 
/llvm/llvm-install/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -fdiagnostics-color -g -O3 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -std=gnu++17 -MD -MT libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o -MF libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o.d -o libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o -c /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:62:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator==(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:63:12: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::equals(*this, other);
           ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:66:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator!=(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:67:13: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return !fputil::equals(*this, other);
            ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:70:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:71:12: note: non-constexpr function 'less_than<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than(*this, other);
           ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:55:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> less_than(T x,
                                                                ^
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:74:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<=(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:75:12: note: non-constexpr function 'less_than_or_equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than_or_equals(*this, other);
           ^
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcTypeTraitsTest.is_signed
[       OK ] LlvmLibcTypeTraitsTest.is_signed (24 us)
[ RUN      ] LlvmLibcTypeTraitsTest.is_unsigned
[       OK ] LlvmLibcTypeTraitsTest.is_unsigned (18 us)
[ RUN      ] LlvmLibcTypeTraitsTest.true_type
[       OK ] LlvmLibcTypeTraitsTest.true_type (9 us)
[ RUN      ] LlvmLibcTypeTraitsTest.has_unique_object_representations
[       OK ] LlvmLibcTypeTraitsTest.has_unique_object_representations (12 us)
Ran 66 tests.  PASS: 66  FAIL: 0
[34/749] Building CXX object libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o
FAILED: libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o 
/llvm/llvm-install/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -fdiagnostics-color -g -O3 -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -fpie -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -std=gnu++17 -MD -MT libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o -MF libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o.d -o libc/utils/MPFRWrapper/CMakeFiles/libcMPCommon.dir/MPCommon.cpp.o -c /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:62:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator==(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:63:12: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::equals(*this, other);
           ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:66:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator!=(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:67:13: note: non-constexpr function 'equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return !fputil::equals(*this, other);
            ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:29:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> equals(T x,
                                                                ^
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:70:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:71:12: note: non-constexpr function 'less_than<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than(*this, other);
           ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/comparison_operations.h:55:65: note: declared here
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, bool> less_than(T x,
                                                                ^
In file included from /llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/utils/MPFRWrapper/MPCommon.cpp:12:
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:74:30: error: constexpr function never produces a constant expression [-Winvalid-constexpr]
  LIBC_INLINE constexpr bool operator<=(BFloat16 other) const {
                             ^
/llvm/libc_worker/worker/libc-arm32-debian/libc-arm32-debian-dbg/llvm-project/libc/src/__support/FPUtil/bfloat16.h:75:12: note: non-constexpr function 'less_than_or_equals<__llvm_libc_20_0_0_git::fputil::BFloat16>' cannot be used in a constant expression
    return fputil::less_than_or_equals(*this, other);
           ^

rupprecht added a commit to rupprecht/llvm-project that referenced this pull request Jul 23, 2025
rupprecht added a commit that referenced this pull request Jul 23, 2025
rupprecht added a commit that referenced this pull request Jul 23, 2025
I believe this is from #150087 and #144983, but I didn't confirm
specific commits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants