[llvm] Call *set::insert without checking membership first (NFC)

This commit is contained in:
Kazu Hirata 2022-06-18 10:17:22 -07:00
parent eca86cb2ed
commit 4271a1ff33
8 changed files with 12 additions and 31 deletions

View File

@ -831,8 +831,6 @@ public:
void getBasicBlocks(DenseSet<BasicBlock *> &BBSet) const {
for (IRInstructionData &ID : *this) {
BasicBlock *BB = ID.Inst->getParent();
if (BBSet.contains(BB))
continue;
BBSet.insert(BB);
}
}
@ -843,9 +841,7 @@ public:
SmallVector<BasicBlock *> &BBList) const {
for (IRInstructionData &ID : *this) {
BasicBlock *BB = ID.Inst->getParent();
if (BBSet.contains(BB))
continue;
BBSet.insert(BB);
if (BBSet.insert(BB).second)
BBList.push_back(BB);
}
}

View File

@ -6020,31 +6020,25 @@ bool CodeGenPrepare::optimizePhiType(
for (Value *V : Phi->incoming_values()) {
if (auto *OpPhi = dyn_cast<PHINode>(V)) {
if (!PhiNodes.count(OpPhi)) {
if (Visited.count(OpPhi))
if (!Visited.insert(OpPhi).second)
return false;
PhiNodes.insert(OpPhi);
Visited.insert(OpPhi);
Worklist.push_back(OpPhi);
}
} else if (auto *OpLoad = dyn_cast<LoadInst>(V)) {
if (!OpLoad->isSimple())
return false;
if (!Defs.count(OpLoad)) {
Defs.insert(OpLoad);
if (Defs.insert(OpLoad).second)
Worklist.push_back(OpLoad);
}
} else if (auto *OpEx = dyn_cast<ExtractElementInst>(V)) {
if (!Defs.count(OpEx)) {
Defs.insert(OpEx);
if (Defs.insert(OpEx).second)
Worklist.push_back(OpEx);
}
} else if (auto *OpBC = dyn_cast<BitCastInst>(V)) {
if (!ConvertTy)
ConvertTy = OpBC->getOperand(0)->getType();
if (OpBC->getOperand(0)->getType() != ConvertTy)
return false;
if (!Defs.count(OpBC)) {
Defs.insert(OpBC);
if (Defs.insert(OpBC).second) {
Worklist.push_back(OpBC);
AnyAnchored |= !isa<LoadInst>(OpBC->getOperand(0)) &&
!isa<ExtractElementInst>(OpBC->getOperand(0));

View File

@ -1298,7 +1298,6 @@ bool SwingSchedulerDAG::Circuits::circuit(int V, int S, NodeSetType &NodeSets,
for (auto W : AdjK[V]) {
if (W < S)
continue;
if (B[W].count(SV) == 0)
B[W].insert(SV);
}
}

View File

@ -528,10 +528,8 @@ static void handleNormalInst(const MachineInstr &MI, LOHInfo *LOHInfos) {
// count as MultiUser or block optimization. This is especially important on
// arm64_32, where any memory operation is likely to be an explicit use of
// xN and an implicit use of wN (the base address register).
if (!UsesSeen.count(Idx)) {
if (UsesSeen.insert(Idx).second)
handleUse(MI, MO, LOHInfos[Idx]);
UsesSeen.insert(Idx);
}
}
}

View File

@ -3464,8 +3464,7 @@ AMDGPUAsmParser::validateConstantBusLimitations(const MCInst &Inst,
// flat_scratch_lo, flat_scratch_hi
// are theoretically valid but they are disabled anyway.
// Note that this code mimics SIInstrInfo::verifyInstruction
if (!SGPRsUsed.count(LastSGPR)) {
SGPRsUsed.insert(LastSGPR);
if (SGPRsUsed.insert(LastSGPR).second) {
++ConstantBusUseCount;
}
} else { // Expression or a literal

View File

@ -349,8 +349,7 @@ void SIWholeQuadMode::markDefs(const MachineInstr &UseMI, LiveRange &LR,
const VNInfo *NextValue = nullptr;
const VisitKey Key(Value, DefinedLanes);
if (!Visited.count(Key)) {
Visited.insert(Key);
if (Visited.insert(Key).second) {
// On first visit to a phi then start processing first predecessor
NextPredIdx = 0;
}

View File

@ -192,10 +192,8 @@ private:
void push_back(Value *V) {
// Do not push back duplicates.
if (!S.count(V)) {
if (S.insert(V).second)
Q.push_back(V);
S.insert(V);
}
}
Value *pop_front_val() {

View File

@ -222,10 +222,8 @@ private:
assert(!Enterers.count(MBB));
if (Blocks.insert(MBB).second) {
for (auto *Pred : MBB->predecessors()) {
if (!AddedToWorkList.count(Pred)) {
if (AddedToWorkList.insert(Pred).second)
WorkList.push_back(Pred);
AddedToWorkList.insert(Pred);
}
}
}
}