// Count the number of values since the checkpoint.
Word BelowKeyMask = KeyMask - 1;
unsigned CountSinceCheckpoint =
- llvm::countPopulation(HasValue[KeyWord] & BelowKeyMask);
+ llvm::popcount(HasValue[KeyWord] & BelowKeyMask);
// Find the value relative to the last checkpoint.
return Values[Checkpoints[KeyWord] + CountSinceCheckpoint];
}
unsigned SanitizerMask::countPopulation() const {
unsigned total = 0;
for (const auto &Val : maskLoToHigh)
- total += llvm::countPopulation(Val);
+ total += llvm::popcount(Val);
return total;
}
for (auto *enumerator : enum_decl->enumerators()) {
uint64_t val = enumerator->getInitVal().getSExtValue();
val = llvm::SignExtend64(val, 8*byte_size);
- if (llvm::countPopulation(val) != 1 && (val & ~covered_bits) != 0)
+ if (llvm::popcount(val) != 1 && (val & ~covered_bits) != 0)
can_be_bitfield = false;
covered_bits |= val;
++num_enumerators;
// Sort in reverse order of the number of the population count, so that in
// `enum {A, B, ALL = A|B }` we visit ALL first. Use a stable sort so that
// A | C where A is declared before C is displayed in this order.
- std::stable_sort(values.begin(), values.end(), [](const auto &a, const auto &b) {
- return llvm::countPopulation(a.first) > llvm::countPopulation(b.first);
- });
+ std::stable_sort(values.begin(), values.end(),
+ [](const auto &a, const auto &b) {
+ return llvm::popcount(a.first) > llvm::popcount(b.first);
+ });
for (const auto &val : values) {
if ((remaining_value & val.first) != val.first)
#define EXTRACT_BITS(value, mask) \
((value >> llvm::countTrailingZeros(static_cast<uint32_t>(mask))) & \
- (((1 << llvm::countPopulation(static_cast<uint32_t>(mask)))) - 1))
+ (((1 << llvm::popcount(static_cast<uint32_t>(mask)))) - 1))
// constructor
/// \returns 0 if the value is zero, otherwise returns the number of set bits.
unsigned countPopulation() const {
if (isSingleWord())
- return llvm::countPopulation(U.VAL);
+ return llvm::popcount(U.VAL);
return countPopulationSlowCase();
}
size_type count() const {
unsigned NumBits = 0;
for (auto Bit : Bits)
- NumBits += countPopulation(Bit);
+ NumBits += llvm::popcount(Bit);
return NumBits;
}
size_type count() const {
if (isSmall()) {
uintptr_t Bits = getSmallBits();
- return countPopulation(Bits);
+ return llvm::popcount(Bits);
}
return getPointer()->count();
}
size_type count() const {
unsigned NumBits = 0;
for (unsigned i = 0; i < BITWORDS_PER_ELEMENT; ++i)
- NumBits += countPopulation(Bits[i]);
+ NumBits += llvm::popcount(Bits[i]);
return NumBits;
}
if (Exponent < 0)
Exponent = -Exponent;
return !OptForSize ||
- (countPopulation((unsigned int)Exponent) + Log2_32(Exponent) < 7);
+ (llvm::popcount((unsigned int)Exponent) + Log2_32(Exponent) < 7);
}
//===--------------------------------------------------------------------===//
constexpr Type getAsInteger() const { return Mask; }
- unsigned getNumLanes() const {
- return countPopulation(Mask);
- }
+ unsigned getNumLanes() const { return llvm::popcount(Mask); }
unsigned getHighestLane() const {
return Log2_64(Mask);
}
size_t count() const {
size_t Count = 0;
for (auto B : Bits)
- Count += countPopulation(B);
+ Count += llvm::popcount(B);
return Count;
}
}
unsigned getNumUnits() const {
- return isAResourceGroup() ? 1U : countPopulation(ResourceSizeMask);
+ return isAResourceGroup() ? 1U : llvm::popcount(ResourceSizeMask);
}
/// Checks if there is an available slot in the resource buffer.
}
static bool hasSingleAllocType(uint8_t AllocTypes) {
- const unsigned NumAllocTypes = countPopulation(AllocTypes);
+ const unsigned NumAllocTypes = llvm::popcount(AllocTypes);
assert(NumAllocTypes != 0);
return NumAllocTypes == 1;
}
if (Scale && other.Scale && Scale != other.Scale)
Result |= ScaleField;
- if (countPopulation(Result) > 1)
+ if (llvm::popcount(Result) > 1)
return MultipleFields;
else
return static_cast<FieldName>(Result);
LLT SwitchTy = getLLTForMVT(BB.RegVT);
Register Cmp;
- unsigned PopCount = countPopulation(B.Mask);
+ unsigned PopCount = llvm::popcount(B.Mask);
if (PopCount == 1) {
// Testing for a single bit; just compare the shift count with what it
// would need to be to shift a 1 bit in that position.
make_range(InstrItins->beginStage(SchedClass),
InstrItins->endStage(SchedClass))) {
InstrStage::FuncUnits funcUnits = IS.getUnits();
- unsigned numAlternatives = countPopulation(funcUnits);
+ unsigned numAlternatives = llvm::popcount(funcUnits);
if (numAlternatives < min) {
min = numAlternatives;
F = funcUnits;
make_range(InstrItins->beginStage(SchedClass),
InstrItins->endStage(SchedClass))) {
InstrStage::FuncUnits FuncUnits = IS.getUnits();
- if (countPopulation(FuncUnits) == 1)
+ if (llvm::popcount(FuncUnits) == 1)
Resources[FuncUnits]++;
}
return;
MVT VT = BB.RegVT;
SDValue ShiftOp = DAG.getCopyFromReg(getControlRoot(), dl, Reg, VT);
SDValue Cmp;
- unsigned PopCount = countPopulation(B.Mask);
+ unsigned PopCount = llvm::popcount(B.Mask);
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
if (PopCount == 1) {
// Testing for a single bit; just compare the shift count with what it
uint32_t NumBuckets = 0;
for (uint32_t B : HashBitmap)
- NumBuckets += countPopulation(B);
+ NumBuckets += llvm::popcount(B);
// Hash buckets follow.
if (auto EC = Reader.readArray(HashBuckets, NumBuckets))
for (; I != E; ++I) {
if (!I->getCycles())
continue;
- double Temp = countPopulation(I->getUnits()) * 1.0 / I->getCycles();
+ double Temp = llvm::popcount(I->getUnits()) * 1.0 / I->getCycles();
Throughput = Throughput ? std::min(*Throughput, Temp) : Temp;
}
if (Throughput)
ResourceState::ResourceState(const MCProcResourceDesc &Desc, unsigned Index,
uint64_t Mask)
: ProcResourceDescIndex(Index), ResourceMask(Mask),
- BufferSize(Desc.BufferSize), IsAGroup(countPopulation(ResourceMask) > 1) {
+ BufferSize(Desc.BufferSize), IsAGroup(llvm::popcount(ResourceMask) > 1) {
if (IsAGroup) {
ResourceSizeMask =
ResourceMask ^ 1ULL << getResourceStateIndex(ResourceMask);
bool ResourceState::isReady(unsigned NumUnits) const {
return (!isReserved() || isADispatchHazard()) &&
- countPopulation(ReadyMask) >= NumUnits;
+ (unsigned)llvm::popcount(ReadyMask) >= NumUnits;
}
ResourceStateEvent ResourceState::isBufferAvailable() const {
}
if (Desc.HasPartiallyOverlappingGroups && !RS.isAResourceGroup()) {
- unsigned NumAvailableUnits = countPopulation(RS.getReadyMask());
+ unsigned NumAvailableUnits = llvm::popcount(RS.getReadyMask());
NumAvailableUnits -= NumUnits;
AvailableUnits[E.first] = NumAvailableUnits;
if (!NumAvailableUnits)
auto it = AvailableUnits.find(ResourceMask);
if (it == AvailableUnits.end()) {
unsigned Index = getResourceStateIndex(ResourceMask);
- unsigned NumUnits = countPopulation(Resources[Index]->getReadyMask());
+ unsigned NumUnits = llvm::popcount(Resources[Index]->getReadyMask());
it =
AvailableUnits.insert(std::make_pair(ResourceMask, NumUnits)).first;
}
Pipes.emplace_back(std::pair<ResourceRef, ResourceCycles>(
Pipe, ResourceCycles(CS.size())));
} else {
- assert((countPopulation(R.first) > 1) && "Expected a group!");
+ assert((llvm::popcount(R.first) > 1) && "Expected a group!");
// Mark this group as reserved.
assert(R.second.isReserved());
reserveResource(R.first);
// Release this resource.
const ResourceRef &RR = BR.first;
- if (countPopulation(RR.first) == 1)
+ if (llvm::popcount(RR.first) == 1)
release(RR);
releaseResource(RR.first);
ResourcesFreed.push_back(RR);
// Sort elements by mask popcount, so that we prioritize resource units over
// resource groups, and smaller groups over larger groups.
sort(Worklist, [](const ResourcePlusCycles &A, const ResourcePlusCycles &B) {
- unsigned popcntA = countPopulation(A.first);
- unsigned popcntB = countPopulation(B.first);
+ unsigned popcntA = llvm::popcount(A.first);
+ unsigned popcntB = llvm::popcount(B.first);
if (popcntA < popcntB)
return true;
if (popcntA > popcntB)
for (unsigned I = 0, E = Worklist.size(); I < E; ++I) {
ResourcePlusCycles &A = Worklist[I];
if (!A.second.size()) {
- assert(countPopulation(A.first) > 1 && "Expected a group!");
+ assert(llvm::popcount(A.first) > 1 && "Expected a group!");
UsedResourceGroups |= PowerOf2Floor(A.first);
continue;
}
ID.Resources.emplace_back(A);
uint64_t NormalizedMask = A.first;
- if (countPopulation(A.first) == 1) {
+ if (llvm::popcount(A.first) == 1) {
UsedResourceUnits |= A.first;
} else {
// Remove the leading 1 from the resource group mask.
ResourcePlusCycles &B = Worklist[J];
if ((NormalizedMask & B.first) == NormalizedMask) {
B.second.CS.subtract(A.second.size() - SuperResources[A.first]);
- if (countPopulation(B.first) > 1)
+ if (llvm::popcount(B.first) > 1)
B.second.NumUnits++;
}
}
// extra delay on top of the 2 cycles latency.
// During those extra cycles, HWPort01 is not usable by other instructions.
for (ResourcePlusCycles &RPC : ID.Resources) {
- if (countPopulation(RPC.first) > 1 && !RPC.second.isReserved()) {
+ if (llvm::popcount(RPC.first) > 1 && !RPC.second.isReserved()) {
// Remove the leading 1 from the resource group mask.
uint64_t Mask = RPC.first ^ PowerOf2Floor(RPC.first);
- uint64_t MaxResourceUnits = countPopulation(Mask);
- if (RPC.second.NumUnits > countPopulation(Mask)) {
+ uint64_t MaxResourceUnits = llvm::popcount(Mask);
+ if (RPC.second.NumUnits > (unsigned)llvm::popcount(Mask)) {
RPC.second.setReserved();
RPC.second.NumUnits = MaxResourceUnits;
}
if (!UsedBuffers)
return;
- SmallVector<unsigned, 4> BufferIDs(countPopulation(UsedBuffers), 0);
+ SmallVector<unsigned, 4> BufferIDs(llvm::popcount(UsedBuffers), 0);
for (unsigned I = 0, E = BufferIDs.size(); I < E; ++I) {
uint64_t CurrentBufferMask = UsedBuffers & (-UsedBuffers);
BufferIDs[I] = HWS.getResourceID(CurrentBufferMask);
unsigned APInt::countPopulationSlowCase() const {
unsigned Count = 0;
for (unsigned i = 0; i < getNumWords(); ++i)
- Count += llvm::countPopulation(U.pVal[i]);
+ Count += llvm::popcount(U.pVal[i]);
return Count;
}
uint32_t MaskVal = Mask->getZExtValue();
if (isMask_32(MaskVal)) {
- uint32_t WidthVal = countPopulation(MaskVal);
+ uint32_t WidthVal = llvm::popcount(MaskVal);
ReplaceNode(N, getBFE32(false, SDLoc(N), Srl.getOperand(0), ShiftVal,
WidthVal));
return;
uint32_t MaskVal = Mask->getZExtValue() >> ShiftVal;
if (isMask_32(MaskVal)) {
- uint32_t WidthVal = countPopulation(MaskVal);
+ uint32_t WidthVal = llvm::popcount(MaskVal);
ReplaceNode(N, getBFE32(false, SDLoc(N), And.getOperand(0), ShiftVal,
WidthVal));
return;
unsigned DMaskVal = DMask->getZExtValue() & 0xf;
// Mask off values that are undefined because the dmask doesn't cover them
- DemandedElts &= (1 << countPopulation(DMaskVal)) - 1;
+ DemandedElts &= (1 << llvm::popcount(DMaskVal)) - 1;
unsigned NewDMaskVal = 0;
unsigned OrigLoadIdx = 0;
}
} else {
DMask = MI.getOperand(ArgOffset + Intr->DMaskIndex).getImm();
- DMaskLanes = BaseOpcode->Gather4 ? 4 : countPopulation(DMask);
+ DMaskLanes = BaseOpcode->Gather4 ? 4 : llvm::popcount(DMask);
if (BaseOpcode->Store) {
VDataIn = MI.getOperand(1).getReg();
if (BaseOpcode->Gather4) {
DMaskLanes = 4;
} else if (DMask != 0) {
- DMaskLanes = countPopulation(DMask);
+ DMaskLanes = llvm::popcount(DMask);
} else if (!IsTFE && !BaseOpcode->Store) {
// If dmask is 0, this is a no-op load. This can be eliminated.
B.buildUndef(MI.getOperand(0));
bool IsPackedD16 = false;
unsigned DataSize =
- (Desc.TSFlags & SIInstrFlags::Gather4) ? 4 : countPopulation(DMask);
+ (Desc.TSFlags & SIInstrFlags::Gather4) ? 4 : llvm::popcount(DMask);
if (hasPackedD16()) {
int D16Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::d16);
IsPackedD16 = D16Idx >= 0;
}
unsigned DMask = MI.getOperand(DMaskIdx).getImm() & 0xf;
- unsigned DstSize = IsGather4 ? 4 : std::max(countPopulation(DMask), 1u);
+ unsigned DstSize = IsGather4 ? 4 : std::max(llvm::popcount(DMask), 1);
bool D16 = D16Idx >= 0 && MI.getOperand(D16Idx).getImm();
if (D16 && AMDGPU::hasPackedD16(STI)) {
}]>;
def IMMPopCount : SDNodeXForm<imm, [{
- return CurDAG->getTargetConstant(countPopulation(N->getZExtValue()), SDLoc(N),
+ return CurDAG->getTargetConstant(llvm::popcount(N->getZExtValue()), SDLoc(N),
MVT::i32);
}]>;
uint16_t OrMask = (Imm >> BITMASK_OR_SHIFT) & BITMASK_MASK;
uint16_t XorMask = (Imm >> BITMASK_XOR_SHIFT) & BITMASK_MASK;
- if (AndMask == BITMASK_MAX &&
- OrMask == 0 &&
- countPopulation(XorMask) == 1) {
+ if (AndMask == BITMASK_MAX && OrMask == 0 && llvm::popcount(XorMask) == 1) {
O << "swizzle(" << IdSymbolic[ID_SWAP];
O << ",";
O << formatDec(XorMask);
O << ")";
- } else if (AndMask == BITMASK_MAX &&
- OrMask == 0 && XorMask > 0 &&
+ } else if (AndMask == BITMASK_MAX && OrMask == 0 && XorMask > 0 &&
isPowerOf2_64(XorMask + 1)) {
O << "swizzle(" << IdSymbolic[ID_REVERSE];
// IR type. Check the dmask for the real number of elements loaded.
unsigned DMask
= cast<ConstantInt>(CI.getArgOperand(0))->getZExtValue();
- MaxNumLanes = DMask == 0 ? 1 : countPopulation(DMask);
+ MaxNumLanes = DMask == 0 ? 1 : llvm::popcount(DMask);
}
}
Type *DataTy = CI.getArgOperand(0)->getType();
if (RsrcIntr->IsImage) {
unsigned DMask = cast<ConstantInt>(CI.getArgOperand(1))->getZExtValue();
- unsigned DMaskLanes = DMask == 0 ? 1 : countPopulation(DMask);
+ unsigned DMaskLanes = DMask == 0 ? 1 : llvm::popcount(DMask);
Info.memVT = memVTFromLoadIntrData(DataTy, DMaskLanes);
} else
Info.memVT = EVT::getEVT(DataTy);
auto *DMaskConst =
cast<ConstantSDNode>(Op.getOperand(ArgOffset + Intr->DMaskIndex));
DMask = DMaskConst->getZExtValue();
- DMaskLanes = BaseOpcode->Gather4 ? 4 : countPopulation(DMask);
+ DMaskLanes = BaseOpcode->Gather4 ? 4 : llvm::popcount(DMask);
if (BaseOpcode->Store) {
VData = Op.getOperand(2);
// It can be optimized out using SDWA for GFX8+ in the SDWA peephole pass,
// given that we are selecting 8 or 16 bit fields starting at byte boundary.
uint64_t Mask = CRHS->getZExtValue();
- unsigned Bits = countPopulation(Mask);
+ unsigned Bits = llvm::popcount(Mask);
if (getSubtarget()->hasSDWA() && LHS->getOpcode() == ISD::SRL &&
(Bits == 8 || Bits == 16) && isShiftedMask_64(Mask) && !(Mask & 1)) {
if (auto *CShift = dyn_cast<ConstantSDNode>(LHS->getOperand(1))) {
return Node;
}
- unsigned OldBitsSet = countPopulation(OldDmask);
+ unsigned OldBitsSet = llvm::popcount(OldDmask);
// Work out which is the TFE/LWE lane if that is enabled.
if (UsesTFC) {
TFCLane = OldBitsSet;
if (NewDmask == OldDmask)
return Node;
- unsigned BitsSet = countPopulation(NewDmask);
+ unsigned BitsSet = llvm::popcount(NewDmask);
// Check for TFE or LWE - increase the number of channels by one to account
// for the extra return value
unsigned dmask = MO_Dmask->getImm();
// Determine the number of active lanes taking into account the
// Gather4 special case
- unsigned ActiveLanes = TII->isGather4(MI) ? 4 : countPopulation(dmask);
+ unsigned ActiveLanes = TII->isGather4(MI) ? 4 : llvm::popcount(dmask);
bool Packed = !Subtarget->hasUnpackedD16VMem();
if (DMask) {
uint64_t DMaskImm = DMask->getImm();
uint32_t RegCount =
- isGather4(MI.getOpcode()) ? 4 : countPopulation(DMaskImm);
+ isGather4(MI.getOpcode()) ? 4 : llvm::popcount(DMaskImm);
const MachineOperand *TFE = getNamedOperand(MI, AMDGPU::OpName::tfe);
const MachineOperand *LWE = getNamedOperand(MI, AMDGPU::OpName::lwe);
const MachineOperand *D16 = getNamedOperand(MI, AMDGPU::OpName::d16);
}]>;
def IMMPopCount : SDNodeXForm<imm, [{
- return CurDAG->getTargetConstant(countPopulation(N->getZExtValue()), SDLoc(N),
+ return CurDAG->getTargetConstant(llvm::popcount(N->getZExtValue()), SDLoc(N),
MVT::i32);
}]>;
if (TII.isMIMG(MI)) {
uint64_t DMaskImm =
TII.getNamedOperand(MI, AMDGPU::OpName::dmask)->getImm();
- return countPopulation(DMaskImm);
+ return llvm::popcount(DMaskImm);
}
if (TII.isMTBUF(Opc)) {
return AMDGPU::getMTBUFElements(Opc);
return AMDGPU::FLAT_STORE_DWORDX4;
}
case MIMG:
- assert((countPopulation(CI.DMask | Paired.DMask) == Width) &&
+ assert(((unsigned)llvm::popcount(CI.DMask | Paired.DMask) == Width) &&
"No overlaps");
return AMDGPU::getMaskedMIMGOp(CI.I->getOpcode(), Width);
}
std::pair<unsigned, unsigned>
SILoadStoreOptimizer::getSubRegIdxs(const CombineInfo &CI,
const CombineInfo &Paired) {
- assert((CI.InstClass != MIMG || (countPopulation(CI.DMask | Paired.DMask) ==
- CI.Width + Paired.Width)) &&
+ assert((CI.InstClass != MIMG ||
+ ((unsigned)llvm::popcount(CI.DMask | Paired.DMask) ==
+ CI.Width + Paired.Width)) &&
"No overlaps");
unsigned Idx0;
uint64_t Even = Mask & 0xAAAAAAAAAAAAAAAAULL;
Mask = (Even >> 1) | Mask;
uint64_t Odd = Mask & 0x5555555555555555ULL;
- return countPopulation(Odd);
+ return llvm::popcount(Odd);
}
// \returns a DWORD offset of a \p SubReg
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
if (!CE) return false;
int64_t Value = CE->getValue();
- return Value > 0 && countPopulation((uint64_t)Value) == 1 &&
- Value >= Min && Value <= Max;
+ return Value > 0 && llvm::popcount((uint64_t)Value) == 1 && Value >= Min &&
+ Value <= Max;
}
bool isModImm() const { return Kind == k_ModifiedImmediate; }
// Conditions only allowing a 't' are those with no set bit except
// the lowest-order one that indicates the end of the sequence. In
// other words, powers of 2.
- if (Cond == ARMCC::AL && countPopulation(Mask) != 1)
+ if (Cond == ARMCC::AL && llvm::popcount(Mask) != 1)
return Error(Loc, "unpredictable IT predicate sequence");
break;
}
unsigned P = Sorted[I], Count = 1;
while (++I != E && P == Sorted[I])
++Count;
- if (countPopulation(P) < Count) {
+ if ((unsigned)llvm::popcount(P) < Count) {
// Reset all occurences of P, if there are more occurrences of P
// than there are bits in P.
for_each(Worklist, [P](unsigned &Q) {
public:
HexagonBid() = default;
- HexagonBid(unsigned B) { Bid = B ? MAX / countPopulation(B) : 0; }
+ HexagonBid(unsigned B) { Bid = B ? MAX / llvm::popcount(B) : 0; }
// Check if the insn priority is overflowed.
bool isSold() const { return (Bid >= MAX); }
if (Key == 0 || Units == 0 || (SlotWeight * s >= 32))
return Weight = 0;
- unsigned Ctpop = countPopulation(Units);
+ unsigned Ctpop = llvm::popcount(Units);
unsigned Cttz = countTrailingZeros(Units);
Weight = (1u << (SlotWeight * s)) * ((MaskWeight - Ctpop) << Cttz);
return Weight;
// Check if the resources are in ascending slot order.
static bool lessUnits(const HexagonResource &A, const HexagonResource &B) {
- return (countPopulation(A.getUnits()) < countPopulation(B.getUnits()));
+ return (llvm::popcount(A.getUnits()) < llvm::popcount(B.getUnits()));
}
// Check if the resources are in ascending weight order.
RISCVMatInt::InstSeq TmpSeq;
generateInstSeqImpl(Lo, ActiveFeatures, TmpSeq);
// Check if it is profitable to use BCLRI/BSETI.
- if (Lo > 0 && TmpSeq.size() + countPopulation(Hi) < Res.size()) {
+ if (Lo > 0 && TmpSeq.size() + llvm::popcount(Hi) < Res.size()) {
Opc = RISCV::BSETI;
- } else if (Lo < 0 && TmpSeq.size() + countPopulation(~Hi) < Res.size()) {
+ } else if (Lo < 0 && TmpSeq.size() + llvm::popcount(~Hi) < Res.size()) {
Opc = RISCV::BCLRI;
Hi = ~Hi;
}
if (isInt<12>(N->getSExtValue()))
return false;
// The immediate must have exactly two bits set.
- return countPopulation(N->getZExtValue()) == 2;
+ return llvm::popcount(N->getZExtValue()) == 2;
}]>;
def BSETINVTwoBitsMaskHigh : SDNodeXForm<imm, [{
if (isInt<12>(N->getSExtValue()))
return false;
// The immediate must have exactly two bits clear.
- return countPopulation(N->getZExtValue()) == Subtarget->getXLen() - 2;
+ return (unsigned)llvm::popcount(N->getZExtValue()) == Subtarget->getXLen() - 2;
}]>;
def BCLRITwoBitsMaskLow : SDNodeXForm<imm, [{
// used if ByteVal is all zeros or all ones; in other cases,
// we can move at most 2 halfwords.
uint64_t ByteVal = CByte->getZExtValue();
- if (ByteVal == 0 || ByteVal == 255 ?
- Bytes <= 16 && countPopulation(Bytes) <= 2 :
- Bytes <= 4) {
+ if (ByteVal == 0 || ByteVal == 255
+ ? Bytes <= 16 && llvm::popcount(Bytes) <= 2
+ : Bytes <= 4) {
unsigned Size1 = Bytes == 16 ? 8 : 1 << findLastSet(Bytes);
unsigned Size2 = Bytes - Size1;
SDValue Chain1 = memsetStore(DAG, DL, Chain, Dst, ByteVal, Size1,
// Now we should have the correct registers live.
LLVM_DEBUG(dumpStack());
- assert(StackTop == countPopulation(Mask) && "Live count mismatch");
+ assert(StackTop == (unsigned)llvm::popcount(Mask) && "Live count mismatch");
}
/// shuffleStackTop - emit fxch instructions before I to shuffle the top
return nullptr;
uint64_t Shift = ShiftCst->getZExtValue();
- uint64_t MaskSize = countPopulation(Mask);
+ uint64_t MaskSize = llvm::popcount(Mask);
// Don't interfere with something that can be handled by extracting AH.
// TODO: If we are able to fold a load, BEXTR might still be better than AH.
return DAG.getNode(ISD::CONCAT_VECTORS, dl, ResVT, Lo, Hi);
}
- assert(countPopulation(NonZeros) == 2 && "Simple cases not handled?");
+ assert(llvm::popcount(NonZeros) == 2 && "Simple cases not handled?");
if (ResVT.getVectorNumElements() >= 16)
return Op; // The operation is legal with KUNPCK
// We can commute insertps if we zero 2 of the elements, the insertion is
// "inline" and we don't override the insertion with a zero.
if (DstIdx == SrcIdx && (ZMask & (1 << DstIdx)) == 0 &&
- countPopulation(ZMask) == 2) {
+ llvm::popcount(ZMask) == 2) {
unsigned AltIdx = findFirstSet((ZMask | (1 << DstIdx)) ^ 15);
assert(AltIdx < 4 && "Illegal insertion index");
unsigned AltImm = (AltIdx << 6) | (AltIdx << 4) | ZMask;
}
sort(ResourceMaskAndEntries,
[](const ResourceMaskAndEntry &A, const ResourceMaskAndEntry &B) {
- unsigned popcntA = countPopulation(A.first);
- unsigned popcntB = countPopulation(B.first);
+ unsigned popcntA = llvm::popcount(A.first);
+ unsigned popcntB = llvm::popcount(B.first);
if (popcntA < popcntB)
return true;
if (popcntA > popcntB)
}
if (RF.C()) {
// Count the number of registers pushed below R11
- int FpOffset = 4 * countPopulation(GPRMask & ((1U << 11) - 1));
+ int FpOffset = 4 * llvm::popcount(GPRMask & ((1U << 11) - 1));
if (FpOffset)
SW.startLine() << "add.w r11, sp, #" << FpOffset << "\n";
else
unsigned size() const {
unsigned Count = 0;
for (WordType W : Words)
- Count += countPopulation(W);
+ Count += llvm::popcount(W);
return Count;
}
LLVM_ATTRIBUTE_ALWAYS_INLINE
spirv::MemorySemantics::AcquireRelease |
spirv::MemorySemantics::SequentiallyConsistent;
- auto bitCount = llvm::countPopulation(
- static_cast<uint32_t>(memorySemantics & atMostOneInSet));
+ auto bitCount =
+ llvm::popcount(static_cast<uint32_t>(memorySemantics & atMostOneInSet));
if (bitCount > 1) {
return op->emitError(
"expected at most one of these four memory constraints "
enumName);
os << formatv(
- " assert(::llvm::countPopulation(static_cast<{0}>(value)) <= 1"
+ " assert(::llvm::popcount(static_cast<{0}>(value)) <= 1"
" && \"cannot have more than one bit set\");\n",
underlyingType);