[libc-commits] [libc] [llvm] [libc][math] Move hypot to shared/math and make it constexpr (PR #177588)

via libc-commits libc-commits at lists.llvm.org
Thu Jan 29 18:48:39 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- libc/shared/math/hypot.h libc/src/__support/math/hypot.h libc/shared/math.h libc/src/__support/FPUtil/Hypot.h libc/src/math/generic/hypot.cpp libc/test/shared/shared_math_test.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h
index 9ddae5826..a64aaa928 100644
--- a/libc/src/__support/FPUtil/Hypot.h
+++ b/libc/src/__support/FPUtil/Hypot.h
@@ -155,7 +155,7 @@ LIBC_INLINE constexpr T hypot(T x, T y) {
   StorageType a_mant = a_bits.get_mantissa();
   StorageType b_mant = b_bits.get_mantissa();
 
-  //Initialize variables for constexpr compatibility
+  // Initialize variables for constexpr compatibility
   DStorageType a_mant_sq = 0;
   DStorageType b_mant_sq = 0;
   bool sticky_bits = false;
@@ -166,8 +166,8 @@ LIBC_INLINE constexpr T hypot(T x, T y) {
   a_mant <<= 1;
   b_mant <<= 1;
 
-  StorageType leading_one=0;
-  int y_mant_width=0;
+  StorageType leading_one = 0;
+  int y_mant_width = 0;
   if (a_exp != 0) {
     leading_one = ONE;
     a_mant |= ONE;
@@ -211,7 +211,7 @@ LIBC_INLINE constexpr T hypot(T x, T y) {
           if (round_mode == FE_TONEAREST || round_mode == FE_UPWARD)
             return FPBits_t::inf().get_val();
         } else {
-              return FPBits_t::inf().get_val();
+          return FPBits_t::inf().get_val();
         }
         return FPBits_t::max_normal().get_val();
       }

``````````

</details>


https://github.com/llvm/llvm-project/pull/177588


More information about the libc-commits mailing list