[llvm] 02a52b7 - [llvm] Use llvm::bit_width (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 28 15:04:30 PST 2023
Author: Kazu Hirata
Date: 2023-01-28T15:04:20-08:00
New Revision: 02a52b7306026f9d5eb42267d7261974dea1a9ba
URL: https://github.com/llvm/llvm-project/commit/02a52b7306026f9d5eb42267d7261974dea1a9ba
DIFF: https://github.com/llvm/llvm-project/commit/02a52b7306026f9d5eb42267d7261974dea1a9ba.diff
LOG: [llvm] Use llvm::bit_width (NFC)
Added:
Modified:
llvm/include/llvm/Support/ScaledNumber.h
llvm/lib/Analysis/VectorUtils.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/ScaledNumber.h b/llvm/include/llvm/Support/ScaledNumber.h
index 4cef02c6f0b2..faf3ce351c3e 100644
--- a/llvm/include/llvm/Support/ScaledNumber.h
+++ b/llvm/include/llvm/Support/ScaledNumber.h
@@ -85,7 +85,7 @@ inline std::pair<DigitsT, int16_t> getAdjusted(uint64_t Digits,
return std::make_pair(Digits, Scale);
// Shift right and round.
- int Shift = 64 - Width - llvm::countl_zero(Digits);
+ int Shift = llvm::bit_width(Digits) - Width;
return getRounded<DigitsT>(Digits >> Shift, Scale + Shift,
Digits & (UINT64_C(1) << (Shift - 1)));
}
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 3c9fbcf1d673..c96e320fa78a 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -770,8 +770,7 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
for (Value *M : llvm::make_range(ECs.member_begin(I), ECs.member_end()))
LeaderDemandedBits |= DBits[M];
- uint64_t MinBW = (sizeof(LeaderDemandedBits) * 8) -
- llvm::countl_zero(LeaderDemandedBits);
+ uint64_t MinBW = llvm::bit_width(LeaderDemandedBits);
// Round up to a power of 2
if (!isPowerOf2_64((uint64_t)MinBW))
MinBW = NextPowerOf2(MinBW);
More information about the llvm-commits
mailing list