diff --git a/libc/.clang-tidy b/libc/.clang-tidy --- a/libc/.clang-tidy +++ b/libc/.clang-tidy @@ -9,17 +9,21 @@ - key: readability-identifier-naming.MemberCase value: lower_case - key: readability-identifier-naming.MemberIgnoredRegexp - value: "^_[A-Za-z0-9_]+$" + value: "_?(_[A-Za-z0-9]+)*" - key: readability-identifier-naming.VariableCase value: lower_case - key: readability-identifier-naming.VariableIgnoredRegexp - value: "^_[A-Za-z0-9_]+$" + value: "_?(_[A-Za-z0-9]+)*" - key: readability-identifier-naming.FunctionCase value: lower_case - key: readability-identifier-naming.FunctionIgnoredRegexp - value: "^_[A-Za-z0-9_]+$" + value: "_?(_[A-Za-z0-9]+)*" - key: readability-identifier-naming.GlobalConstantCase value: UPPER_CASE + - key: readability-identifier-naming.LocalConstantIgnoredRegexp + value: "[A-Z]+[A-Z0-9]*(_[A-Z0-9]+)*" + - key: readability-identifier-naming.ClassConstantCase + value: UPPER_CASE - key: readability-identifier-naming.ConstexprVariableCase value: UPPER_CASE - key: readability-identifier-naming.GetConfigPerFile diff --git a/libc/src/__support/FPUtil/XFloat.h b/libc/src/__support/FPUtil/XFloat.h --- a/libc/src/__support/FPUtil/XFloat.h +++ b/libc/src/__support/FPUtil/XFloat.h @@ -19,7 +19,7 @@ template class XFloat { static constexpr uint64_t OneMask = (uint64_t(1) << 63); UInt man; - static constexpr uint64_t WordCount = Precision / 64; + static constexpr uint64_t WORDCOUNT = Precision / 64; int exp; size_t bit_width(uint64_t x) { @@ -35,25 +35,25 @@ public: XFloat() : exp(0) { - for (int i = 0; i < WordCount; ++i) + for (int i = 0; i < WORDCOUNT; ++i) man[i] = 0; } XFloat(const XFloat &other) : exp(other.exp) { - for (int i = 0; i < WordCount; ++i) + for (int i = 0; i < WORDCOUNT; ++i) man[i] = other.man[i]; } explicit XFloat(double x) { auto xn = NormalFloat(x); exp = xn.exponent; - man[WordCount - 1] = xn.mantissa << 11; - for (int i = 0; i < WordCount - 1; ++i) + man[WORDCOUNT - 1] = xn.mantissa << 11; + for (int i = 0; i < WORDCOUNT - 1; ++i) man[i] = 0; } XFloat(int e, const UInt &bits) : exp(e) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) man[i] = bits[i]; } @@ -65,7 +65,7 @@ size_t carry_width = bit_width(carry); carry_width = (carry_width == 64 ? 64 : 63); man.shift_right(carry_width); - man[WordCount - 1] = man[WordCount - 1] + (carry << (64 - carry_width)); + man[WORDCOUNT - 1] = man[WORDCOUNT - 1] + (carry << (64 - carry_width)); exp += carry_width == 64 ? 1 : 0; normalize(); } @@ -74,7 +74,7 @@ if (exp < 0) return; if (exp > int(Precision - 1)) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) man[i] = 0; return; } @@ -86,14 +86,14 @@ } double mul(const XFloat &other) { - constexpr size_t row_words = 2 * WordCount + 1; + constexpr size_t row_words = 2 * WORDCOUNT + 1; constexpr size_t row_precision = row_words * 64; constexpr size_t result_bits = 2 * Precision; - UInt rows[WordCount]; + UInt rows[WORDCOUNT]; - for (size_t r = 0; r < WordCount; ++r) { + for (size_t r = 0; r < WORDCOUNT; ++r) { for (size_t i = 0; i < row_words; ++i) { - if (i < WordCount) + if (i < WORDCOUNT) rows[r][i] = man[i]; else rows[r][i] = 0; @@ -102,7 +102,7 @@ rows[r].shift_left(r * 64); } - for (size_t r = 1; r < WordCount; ++r) { + for (size_t r = 1; r < WORDCOUNT; ++r) { rows[0].add(rows[r]); } int result_exp = exp + other.exp; @@ -134,14 +134,14 @@ constexpr uint64_t one = uint64_t(1) << 10; constexpr uint64_t excess_mask = (one << 1) - 1; - uint64_t excess = man[WordCount - 1] & excess_mask; - uint64_t new_man = man[WordCount - 1] >> 11; + uint64_t excess = man[WORDCOUNT - 1] & excess_mask; + uint64_t new_man = man[WORDCOUNT - 1] >> 11; if (excess > one) { // We have to round up. ++new_man; } else if (excess == one) { bool greater_than_one = false; - for (size_t i = 0; i < WordCount - 1; ++i) { + for (size_t i = 0; i < WORDCOUNT - 1; ++i) { greater_than_one = (man[i] != 0); if (greater_than_one) break; @@ -163,13 +163,13 @@ // Normalizes this number. void normalize() { uint64_t man_bits = 0; - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) man_bits |= man[i]; if (man_bits == 0) return; - while ((man[WordCount - 1] & OneMask) == 0) { + while ((man[WORDCOUNT - 1] & OneMask) == 0) { man.shift_left(1); --exp; } diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h --- a/libc/src/__support/FPUtil/dyadic_float.h +++ b/libc/src/__support/FPUtil/dyadic_float.h @@ -104,11 +104,11 @@ sign, exponent + (Bits - 1) + FloatProperties::EXPONENT_BIAS, output_bits_t(m_hi) & FloatProperties::MANTISSA_MASK); - const MantissaType ROUND_MASK = MantissaType(1) << (Bits - PRECISION - 1); - const MantissaType STICKY_MASK = ROUND_MASK - MantissaType(1); + const MantissaType round_mask = MantissaType(1) << (Bits - PRECISION - 1); + const MantissaType sticky_mask = round_mask - MantissaType(1); - bool round_bit = !(mantissa & ROUND_MASK).is_zero(); - bool sticky_bit = !(mantissa & STICKY_MASK).is_zero(); + bool round_bit = !(mantissa & round_mask).is_zero(); + bool sticky_bit = !(mantissa & sticky_mask).is_zero(); int round_and_sticky = int(round_bit) * 2 + int(sticky_bit); auto d_lo = FPBits::create_value(sign, exponent + (Bits - PRECISION - 2) + @@ -156,7 +156,7 @@ if (result.mantissa.add(b.mantissa)) { // Mantissa addition overflow. result.shift_right(1); - result.mantissa.val[DyadicFloat::MantissaType::WordCount - 1] |= + result.mantissa.val[DyadicFloat::MantissaType::WORDCOUNT - 1] |= (uint64_t(1) << 63); } // Result is already normalized. @@ -183,7 +183,7 @@ // result.mantissa = quick_mul_hi(a.mantissa + b.mantissa) // ~ (full product a.mantissa * b.mantissa) >> Bits. // The errors compared to the mathematical product is bounded by: -// 2 * errors of quick_mul_hi = 2 * (UInt::WordCount - 1) in ULPs. +// 2 * errors of quick_mul_hi = 2 * (UInt::WORDCOUNT - 1) in ULPs. // Assume inputs are normalized (by constructors or other functions) so that we // don't need to normalize the inputs again in this function. If the inputs are // not normalized, the results might lose precision significantly. @@ -198,7 +198,7 @@ result.mantissa = a.mantissa.quick_mul_hi(b.mantissa); // Check the leading bit directly, should be faster than using clz in // normalize(). - if (result.mantissa.val[DyadicFloat::MantissaType::WordCount - 1] >> + if (result.mantissa.val[DyadicFloat::MantissaType::WORDCOUNT - 1] >> 63 == 0) result.shift_left(1); diff --git a/libc/src/__support/FPUtil/generic/FMod.h b/libc/src/__support/FPUtil/generic/FMod.h --- a/libc/src/__support/FPUtil/generic/FMod.h +++ b/libc/src/__support/FPUtil/generic/FMod.h @@ -122,9 +122,9 @@ static_assert(cpp::is_floating_point_v, "FModCStandardWrapper instantiated with invalid type."); - LIBC_INLINE static bool PreCheck(T x, T y, T &out) { + LIBC_INLINE static bool pre_check(T x, T y, T &out) { using FPB = fputil::FPBits; - const T quiet_NaN = FPB::build_quiet_nan(0); + const T quiet_nan = FPB::build_quiet_nan(0); FPB sx(x), sy(y); if (LIBC_LIKELY(!sy.is_zero() && !sy.is_inf_or_nan() && !sx.is_inf_or_nan())) { @@ -134,14 +134,15 @@ if (sx.is_nan() || sy.is_nan()) { if ((sx.is_nan() && !sx.is_quiet_nan()) || (sy.is_nan() && !sy.is_quiet_nan())) - fputil::set_except(FE_INVALID); - out = quiet_NaN; + fputil::raise_except_if_required(FE_INVALID); + out = quiet_nan; return true; } if (sx.is_inf() || sy.is_zero()) { - fputil::set_except(FE_INVALID); - out = with_errno(quiet_NaN, EDOM); + fputil::raise_except_if_required(FE_INVALID); + fputil::set_errno_if_required(EDOM); + out = quiet_nan; return true; } @@ -161,7 +162,7 @@ static_assert(cpp::is_floating_point_v, "FModFastMathWrapper instantiated with invalid type."); - static bool PreCheck(T, T, T &) { return false; } + static bool pre_check(T, T, T &) { return false; } }; template class FModDivisionSimpleHelper { @@ -302,7 +303,7 @@ public: LIBC_INLINE static T eval(T x, T y) { - if (T out; Wrapper::PreCheck(x, y, out)) + if (T out; Wrapper::pre_check(x, y, out)) return out; FPB sx(x), sy(y); bool sign = sx.get_sign(); diff --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h --- a/libc/src/__support/UInt.h +++ b/libc/src/__support/UInt.h @@ -27,8 +27,8 @@ static_assert(Bits > 0 && Bits % 64 == 0, "Number of bits in UInt should be a multiple of 64."); - static constexpr size_t WordCount = Bits / 64; - uint64_t val[WordCount]; + static constexpr size_t WORDCOUNT = Bits / 64; + uint64_t val[WORDCOUNT]; static constexpr uint64_t MASK32 = 0xFFFFFFFFu; @@ -38,45 +38,45 @@ constexpr UInt() {} constexpr UInt(const UInt &other) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] = other.val[i]; } template constexpr UInt(const UInt &other) { if (OtherBits >= Bits) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] = other[i]; } else { size_t i = 0; for (; i < OtherBits / 64; ++i) val[i] = other[i]; - for (; i < WordCount; ++i) + for (; i < WORDCOUNT; ++i) val[i] = 0; } } // Construct a UInt from a C array. - template = 0> + template = 0> constexpr UInt(const uint64_t (&nums)[N]) { - size_t min_wordcount = N < WordCount ? N : WordCount; + size_t min_wordcount = N < WORDCOUNT ? N : WORDCOUNT; size_t i = 0; for (; i < min_wordcount; ++i) val[i] = nums[i]; // If nums doesn't completely fill val, then fill the rest with zeroes. - for (; i < WordCount; ++i) + for (; i < WORDCOUNT; ++i) val[i] = 0; } // Initialize the first word to |v| and the rest to 0. constexpr UInt(uint64_t v) { val[0] = v; - for (size_t i = 1; i < WordCount; ++i) { + for (size_t i = 1; i < WORDCOUNT; ++i) { val[i] = 0; } } - constexpr explicit UInt(const cpp::array &words) { - for (size_t i = 0; i < WordCount; ++i) + constexpr explicit UInt(const cpp::array &words) { + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] = words[i]; } @@ -91,13 +91,13 @@ } UInt &operator=(const UInt &other) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] = other.val[i]; return *this; } constexpr bool is_zero() const { - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { if (val[i] != 0) return false; } @@ -108,7 +108,7 @@ // Returns the carry value produced by the addition operation. constexpr uint64_t add(const UInt &x) { SumCarry s{0, 0}; - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { s = add_with_carry(val[i], x.val[i], s.carry); val[i] = s.sum; } @@ -118,7 +118,7 @@ constexpr UInt operator+(const UInt &other) const { UInt result; SumCarry s{0, 0}; - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { s = add_with_carry(val[i], other.val[i], s.carry); result.val[i] = s.sum; } @@ -134,7 +134,7 @@ // Returns the carry value produced by the subtraction operation. constexpr uint64_t sub(const UInt &x) { DiffBorrow d{0, 0}; - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { d = sub_with_borrow(val[i], x.val[i], d.borrow); val[i] = d.diff; } @@ -144,7 +144,7 @@ constexpr UInt operator-(const UInt &other) const { UInt result; DiffBorrow d{0, 0}; - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { d = sub_with_borrow(val[i], other.val[i], d.borrow); result.val[i] = d.diff; } @@ -166,7 +166,7 @@ constexpr uint64_t mul(uint64_t x) { UInt<128> partial_sum(0); uint64_t carry = 0; - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { NumberPair prod = full_mul(val[i], x); UInt<128> tmp({prod.lo, prod.hi}); carry += partial_sum.add(tmp); @@ -179,13 +179,13 @@ } constexpr UInt operator*(const UInt &other) const { - if constexpr (WordCount == 1) { + if constexpr (WORDCOUNT == 1) { return {val[0] * other.val[0]}; } else { UInt result(0); UInt<128> partial_sum(0); uint64_t carry = 0; - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { for (size_t j = 0; j <= i; j++) { NumberPair prod = full_mul(val[j], other.val[i - j]); UInt<128> tmp({prod.lo, prod.hi}); @@ -206,10 +206,11 @@ UInt result(0); UInt<128> partial_sum(0); uint64_t carry = 0; - constexpr size_t OtherWordCount = UInt::WordCount; - for (size_t i = 0; i <= WordCount + OtherWordCount - 2; ++i) { - const size_t lower_idx = i < OtherWordCount ? 0 : i - OtherWordCount + 1; - const size_t upper_idx = i < WordCount ? i : WordCount - 1; + constexpr size_t OTHER_WORDCOUNT = UInt::WORDCOUNT; + for (size_t i = 0; i <= WORDCOUNT + OTHER_WORDCOUNT - 2; ++i) { + const size_t lower_idx = + i < OTHER_WORDCOUNT ? 0 : i - OTHER_WORDCOUNT + 1; + const size_t upper_idx = i < WORDCOUNT ? i : WORDCOUNT - 1; for (size_t j = lower_idx; j <= upper_idx; ++j) { NumberPair prod = full_mul(val[j], other.val[i - j]); UInt<128> tmp({prod.lo, prod.hi}); @@ -220,7 +221,7 @@ partial_sum.val[1] = carry; carry = 0; } - result.val[WordCount + OtherWordCount - 1] = partial_sum.val[0]; + result.val[WORDCOUNT + OTHER_WORDCOUNT - 1] = partial_sum.val[0]; return result; } @@ -228,7 +229,7 @@ // `Bits` least significant bits of the full product, while this function will // approximate `Bits` most significant bits of the full product with errors // bounded by: - // 0 <= (a.full_mul(b) >> Bits) - a.quick_mul_hi(b)) <= WordCount - 1. + // 0 <= (a.full_mul(b) >> Bits) - a.quick_mul_hi(b)) <= WORDCOUNT - 1. // // An example usage of this is to quickly (but less accurately) compute the // product of (normalized) mantissas of floating point numbers: @@ -240,7 +241,7 @@ // // Performance summary: // Number of 64-bit x 64-bit -> 128-bit multiplications performed. - // Bits WordCount ful_mul quick_mul_hi Error bound + // Bits WORDCOUNT ful_mul quick_mul_hi Error bound // 128 2 4 3 1 // 196 3 9 6 2 // 256 4 16 10 3 @@ -249,26 +250,26 @@ UInt result(0); UInt<128> partial_sum(0); uint64_t carry = 0; - // First round of accumulation for those at WordCount - 1 in the full + // First round of accumulation for those at WORDCOUNT - 1 in the full // product. - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { NumberPair prod = - full_mul(val[i], other.val[WordCount - 1 - i]); + full_mul(val[i], other.val[WORDCOUNT - 1 - i]); UInt<128> tmp({prod.lo, prod.hi}); carry += partial_sum.add(tmp); } - for (size_t i = WordCount; i < 2 * WordCount - 1; ++i) { + for (size_t i = WORDCOUNT; i < 2 * WORDCOUNT - 1; ++i) { partial_sum.val[0] = partial_sum.val[1]; partial_sum.val[1] = carry; carry = 0; - for (size_t j = i - WordCount + 1; j < WordCount; ++j) { + for (size_t j = i - WORDCOUNT + 1; j < WORDCOUNT; ++j) { NumberPair prod = full_mul(val[j], other.val[i - j]); UInt<128> tmp({prod.lo, prod.hi}); carry += partial_sum.add(tmp); } - result.val[i - WordCount] = partial_sum.val[0]; + result.val[i - WORDCOUNT] = partial_sum.val[0]; } - result.val[WordCount - 1] = partial_sum.val[1]; + result.val[WORDCOUNT - 1] = partial_sum.val[1]; return result; } @@ -338,7 +339,7 @@ constexpr uint64_t clz() { uint64_t leading_zeroes = 0; - for (size_t i = WordCount; i > 0; --i) { + for (size_t i = WORDCOUNT; i > 0; --i) { if (val[i - 1] == 0) { leading_zeroes += sizeof(uint64_t) * 8; } else { @@ -370,17 +371,17 @@ const size_t drop = s / 64; // Number of words to drop const size_t shift = s % 64; // Bits to shift in the remaining words. - size_t i = WordCount; + size_t i = WORDCOUNT; - if (drop < WordCount) { - i = WordCount - 1; + if (drop < WORDCOUNT) { + i = WORDCOUNT - 1; if (shift > 0) { - for (size_t j = WordCount - 1 - drop; j > 0; --i, --j) { + for (size_t j = WORDCOUNT - 1 - drop; j > 0; --i, --j) { val[i] = (val[j] << shift) | (val[j - 1] >> (64 - shift)); } val[i] = val[0] << shift; } else { - for (size_t j = WordCount - 1 - drop; j > 0; --i, --j) { + for (size_t j = WORDCOUNT - 1 - drop; j > 0; --i, --j) { val[i] = val[j]; } val[i] = val[0]; @@ -427,21 +428,21 @@ size_t i = 0; - if (drop < WordCount) { + if (drop < WORDCOUNT) { if (shift > 0) { - for (size_t j = drop; j < WordCount - 1; ++i, ++j) { + for (size_t j = drop; j < WORDCOUNT - 1; ++i, ++j) { val[i] = (val[j] >> shift) | (val[j + 1] << (64 - shift)); } - val[i] = val[WordCount - 1] >> shift; + val[i] = val[WORDCOUNT - 1] >> shift; ++i; } else { - for (size_t j = drop; j < WordCount; ++i, ++j) { + for (size_t j = drop; j < WORDCOUNT; ++i, ++j) { val[i] = val[j]; } } } - for (; i < WordCount; ++i) { + for (; i < WORDCOUNT; ++i) { val[i] = 0; } } @@ -459,52 +460,52 @@ constexpr UInt operator&(const UInt &other) const { UInt result; - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) result.val[i] = val[i] & other.val[i]; return result; } constexpr UInt &operator&=(const UInt &other) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] &= other.val[i]; return *this; } constexpr UInt operator|(const UInt &other) const { UInt result; - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) result.val[i] = val[i] | other.val[i]; return result; } constexpr UInt &operator|=(const UInt &other) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] |= other.val[i]; return *this; } constexpr UInt operator^(const UInt &other) const { UInt result; - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) result.val[i] = val[i] ^ other.val[i]; return result; } constexpr UInt &operator^=(const UInt &other) { - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) val[i] ^= other.val[i]; return *this; } constexpr UInt operator~() const { UInt result; - for (size_t i = 0; i < WordCount; ++i) + for (size_t i = 0; i < WORDCOUNT; ++i) result.val[i] = ~val[i]; return result; } constexpr bool operator==(const UInt &other) const { - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { if (val[i] != other.val[i]) return false; } @@ -512,7 +513,7 @@ } constexpr bool operator!=(const UInt &other) const { - for (size_t i = 0; i < WordCount; ++i) { + for (size_t i = 0; i < WORDCOUNT; ++i) { if (val[i] != other.val[i]) return true; } @@ -520,7 +521,7 @@ } constexpr bool operator>(const UInt &other) const { - for (size_t i = WordCount; i > 0; --i) { + for (size_t i = WORDCOUNT; i > 0; --i) { uint64_t word = val[i - 1]; uint64_t other_word = other.val[i - 1]; if (word > other_word) @@ -533,7 +534,7 @@ } constexpr bool operator>=(const UInt &other) const { - for (size_t i = WordCount; i > 0; --i) { + for (size_t i = WORDCOUNT; i > 0; --i) { uint64_t word = val[i - 1]; uint64_t other_word = other.val[i - 1]; if (word > other_word) @@ -546,7 +547,7 @@ } constexpr bool operator<(const UInt &other) const { - for (size_t i = WordCount; i > 0; --i) { + for (size_t i = WORDCOUNT; i > 0; --i) { uint64_t word = val[i - 1]; uint64_t other_word = other.val[i - 1]; if (word > other_word) @@ -559,7 +560,7 @@ } constexpr bool operator<=(const UInt &other) const { - for (size_t i = WordCount; i > 0; --i) { + for (size_t i = WORDCOUNT; i > 0; --i) { uint64_t word = val[i - 1]; uint64_t other_word = other.val[i - 1]; if (word > other_word) diff --git a/libc/src/math/generic/exp2f.cpp b/libc/src/math/generic/exp2f.cpp --- a/libc/src/math/generic/exp2f.cpp +++ b/libc/src/math/generic/exp2f.cpp @@ -21,9 +21,9 @@ namespace __llvm_libc { -constexpr uint32_t exval1 = 0x3b42'9d37U; -constexpr uint32_t exval2 = 0xbcf3'a937U; -constexpr uint32_t exval_mask = exval1 & exval2; +constexpr uint32_t EXVAL1 = 0x3b42'9d37U; +constexpr uint32_t EXVAL2 = 0xbcf3'a937U; +constexpr uint32_t EXVAL_MASK = EXVAL1 & EXVAL2; LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { using FPBits = typename fputil::FPBits; @@ -73,11 +73,11 @@ } // Check exceptional values. - if (LIBC_UNLIKELY((x_u & exval_mask) == exval_mask)) { - if (LIBC_UNLIKELY(x_u == exval1)) { // x = 0x1.853a6ep-9f + if (LIBC_UNLIKELY((x_u & EXVAL_MASK) == EXVAL_MASK)) { + if (LIBC_UNLIKELY(x_u == EXVAL1)) { // x = 0x1.853a6ep-9f if (fputil::get_round() == FE_TONEAREST) return 0x1.00870ap+0f; - } else if (LIBC_UNLIKELY(x_u == exval2)) { // x = -0x1.e7526ep-6f + } else if (LIBC_UNLIKELY(x_u == EXVAL2)) { // x = -0x1.e7526ep-6f if (fputil::get_round() == FE_TONEAREST) return 0x1.f58d62p-1f; } diff --git a/libc/src/math/generic/log10.cpp b/libc/src/math/generic/log10.cpp --- a/libc/src/math/generic/log10.cpp +++ b/libc/src/math/generic/log10.cpp @@ -917,7 +917,6 @@ // Further range reductions. double scale = 0x1.0p+7; - const fputil::DyadicFloat<128> NEG_ONE(-1.0); for (size_t i = 0; i < R_STEPS; ++i) { scale *= 0x1.0p+4; int id = static_cast(fputil::multiply_add(mx.hi, scale, 0x1.0p+4)); diff --git a/libc/utils/HdrGen/PrototypeTestGen/.clang-tidy b/libc/utils/HdrGen/PrototypeTestGen/.clang-tidy deleted file mode 100644 --- a/libc/utils/HdrGen/PrototypeTestGen/.clang-tidy +++ /dev/null @@ -1,3 +0,0 @@ -CheckOptions: - - key: readability-identifier-naming.VariableCase - value: camelBack