[libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356)
Krishna Pandey via libc-commits
libc-commits at lists.llvm.org
Tue Feb 4 22:42:26 PST 2025
================
@@ -163,6 +176,26 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
return bit_and((x + round_bit), rounding_mask);
}
+// count leading zeros
+template <typename T>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_fixed_point_v<T>, int>
+countls(T f) {
+ using FXRep = FXRep<T>;
+ using BitType = typename FXRep::StorageType;
+ using FXBits = FXBits<T>;
+
+ constexpr int CONTAIN_LEN = cpp::numeric_limits<BitType>::digits;
+ constexpr int PADDING_LEN = CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN);
----------------
krishna2803 wrote:
fixed in [9b499bcb](https://github.com/llvm/llvm-project/pull/125356/commits/9b499bcb5a1894b4991c14885cd514746c6c634a)
https://github.com/llvm/llvm-project/pull/125356
More information about the libc-commits
mailing list