[libc-commits] [libc] 616cef0 - [libc][math] Make BFloat16 comparison tests constexpr (#151211)

via libc-commits libc-commits at lists.llvm.org
Tue Jul 29 13:52:00 PDT 2025


Author: Krishna Pandey
Date: 2025-07-29T16:51:57-04:00
New Revision: 616cef08831631b3b049b92af43bc71326c910e4

URL: https://github.com/llvm/llvm-project/commit/616cef08831631b3b049b92af43bc71326c910e4
DIFF: https://github.com/llvm/llvm-project/commit/616cef08831631b3b049b92af43bc71326c910e4.diff

LOG: [libc][math] Make BFloat16 comparison tests constexpr (#151211)

Signed-off-by: Krishna Pandey <kpandey81930 at gmail.com>

Added: 
    

Modified: 
    libc/test/src/__support/FPUtil/comparison_operations_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/__support/FPUtil/comparison_operations_test.cpp b/libc/test/src/__support/FPUtil/comparison_operations_test.cpp
index 04a3321fd5dbf..05b8f68441532 100644
--- a/libc/test/src/__support/FPUtil/comparison_operations_test.cpp
+++ b/libc/test/src/__support/FPUtil/comparison_operations_test.cpp
@@ -25,28 +25,15 @@ template <typename T>
 class ComparisonOperationsTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
   DECLARE_SPECIAL_CONSTANTS(T)
 
-  // TODO: Make these constexpr once quick_get_round is made constexpr.
-  T normal1;
-  T neg_normal1;
-  T normal2;
-  T small;
-  T neg_small;
-  T large;
-  T neg_large;
+  static constexpr T normal1 = T(3.14);
+  static constexpr T neg_normal1 = T(-3.14);
+  static constexpr T normal2 = T(2.71);
+  static constexpr T small = T(0.1);
+  static constexpr T neg_small = T(-0.1);
+  static constexpr T large = T(10000.0);
+  static constexpr T neg_large = T(-10000.0);
 
 public:
-  void SetUp() override {
-    with_fenv_preserved([this]() {
-      normal1 = T(3.14);
-      neg_normal1 = T(-3.14);
-      normal2 = T(2.71);
-      small = T(0.1);
-      neg_small = T(-0.1);
-      large = T(10000.0);
-      neg_large = T(-10000.0);
-    });
-  }
-
   void test_equals() {
     EXPECT_TRUE(equals(neg_zero, neg_zero));
     EXPECT_TRUE(equals(zero, neg_zero));


        


More information about the libc-commits mailing list