// the highest bit set can be used to construct a resource mask identifier.
inline unsigned getResourceStateIndex(uint64_t Mask) {
assert(Mask && "Processor Resource Mask cannot be zero!");
- return (std::numeric_limits<uint64_t>::digits - countLeadingZeros(Mask)) - 1;
+ return llvm::Log2_64(Mask);
}
/// Compute the reciprocal block throughput from a set of processor resource
return std::make_pair(INT32_MIN, 0);
// Get the floor of the lg of Digits.
- int32_t LocalFloor = sizeof(Digits) * 8 - countLeadingZeros(Digits) - 1;
+ static_assert(sizeof(Digits) <= sizeof(uint64_t));
+ int32_t LocalFloor = llvm::Log2_64(Digits);
// Get the actual floor.
int32_t Floor = Scale + LocalFloor;
const MCOperand &MO = MI.getOperand(Op);
uint32_t v = ~MO.getImm();
uint32_t lsb = llvm::countr_zero(v);
- uint32_t msb = (32 - llvm::countl_zero(v)) - 1;
+ uint32_t msb = llvm::Log2_32(v);
assert(v != 0 && lsb < 32 && msb < 32 && "Illegal bitfield mask!");
return lsb | (msb << 5);
}