Set std::numeric_limits<>::tinyness_before to true for floating point types on ARM...
authorOwen Anderson <resistor@mac.com>
Tue, 28 Dec 2021 19:44:49 +0000 (11:44 -0800)
committerOwen Anderson <resistor@mac.com>
Tue, 22 Feb 2022 23:49:21 +0000 (15:49 -0800)
Set std::numeric_limits<>::tinyness_before to true for floating point types on ARM platforms.

Section E1.3.5 in the ARMv8 Architecture Reference Manual specifies:
  Underflow. The bit is set to 1 if the absolute value of the result
  of an operation, produced before rounding, is less than the minimum
  positive normalized number for the destination precision, and the
  rounded result is inexact.

Reviewed By: #libc, majnemer, EricWF

Differential Revision: https://reviews.llvm.org/D116338

libcxx/include/limits
libcxx/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp

index bf5d6d1..5afef4b 100644 (file)
@@ -339,7 +339,11 @@ protected:
     static _LIBCPP_CONSTEXPR const bool is_modulo = false;
 
     static _LIBCPP_CONSTEXPR const bool traps = false;
+#if (defined(__arm__) || defined(__aarch64__))
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
+#else
     static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+#endif
     static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
 };
 
@@ -385,7 +389,11 @@ protected:
     static _LIBCPP_CONSTEXPR const bool is_modulo = false;
 
     static _LIBCPP_CONSTEXPR const bool traps = false;
+#if (defined(__arm__) || defined(__aarch64__))
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
+#else
     static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+#endif
     static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
 };
 
@@ -435,7 +443,11 @@ protected:
     static _LIBCPP_CONSTEXPR const bool is_modulo = false;
 
     static _LIBCPP_CONSTEXPR const bool traps = false;
+#if (defined(__arm__) || defined(__aarch64__))
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
+#else
     static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+#endif
     static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
 };
 
index e132d4f..3231a63 100644 (file)
@@ -50,9 +50,15 @@ int main(int, char**)
     test<__int128_t, false>();
     test<__uint128_t, false>();
 #endif
+#if (defined(__arm__) || defined(__aarch64__))
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+#else
     test<float, false>();
     test<double, false>();
     test<long double, false>();
+#endif
 
   return 0;
 }