Skip to content

Commit c714da2

Browse files
[Transforms] Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC)
1 parent 1c2d333 commit c714da2

14 files changed

+26
-30
lines changed

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ static bool hasCallsInBlocksBetween(BasicBlock *SaveBB, BasicBlock *ResDesBB) {
13551355
auto *BB = Worklist.pop_back_val();
13561356
Set.insert(BB);
13571357
for (auto *Pred : predecessors(BB))
1358-
if (Set.count(Pred) == 0)
1358+
if (!Set.contains(Pred))
13591359
Worklist.push_back(Pred);
13601360
}
13611361

llvm/lib/Transforms/IPO/FunctionAttrs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ static bool InstrBreaksNonConvergent(Instruction &I,
14391439
// Breaks non-convergent assumption if CS is a convergent call to a function
14401440
// not in the SCC.
14411441
return CB && CB->isConvergent() &&
1442-
SCCNodes.count(CB->getCalledFunction()) == 0;
1442+
!SCCNodes.contains(CB->getCalledFunction());
14431443
}
14441444

14451445
/// Helper for NoUnwind inference predicate InstrBreaksAttribute.

llvm/lib/Transforms/IPO/StripSymbols.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ static bool StripSymbolNames(Module &M, bool PreserveDbgInfo) {
214214
findUsedValues(M.getGlobalVariable("llvm.compiler.used"), llvmUsedValues);
215215

216216
for (GlobalVariable &GV : M.globals()) {
217-
if (GV.hasLocalLinkage() && llvmUsedValues.count(&GV) == 0)
217+
if (GV.hasLocalLinkage() && !llvmUsedValues.contains(&GV))
218218
if (!PreserveDbgInfo || !GV.getName().startswith("llvm.dbg"))
219219
GV.setName(""); // Internal symbols can't participate in linkage
220220
}
221221

222222
for (Function &I : M) {
223-
if (I.hasLocalLinkage() && llvmUsedValues.count(&I) == 0)
223+
if (I.hasLocalLinkage() && !llvmUsedValues.contains(&I))
224224
if (!PreserveDbgInfo || !I.getName().startswith("llvm.dbg"))
225225
I.setName(""); // Internal symbols can't participate in linkage
226226
if (auto *Symtab = I.getValueSymbolTable())

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,7 @@ Instruction *InstCombinerImpl::optimizeBitCastFromPhi(CastInst &CI,
25552555
// As long as the user is another old PHI node, then even if we don't
25562556
// rewrite it, the PHI web we're considering won't have any users
25572557
// outside itself, so it'll be dead.
2558-
if (OldPhiNodes.count(PHI) == 0)
2558+
if (!OldPhiNodes.contains(PHI))
25592559
return nullptr;
25602560
} else {
25612561
return nullptr;

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
541541
if (!CI->isNoopCast(DL))
542542
return false;
543543

544-
if (Explored.count(CI->getOperand(0)) == 0)
544+
if (!Explored.contains(CI->getOperand(0)))
545545
WorkList.push_back(CI->getOperand(0));
546546
}
547547

@@ -553,7 +553,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
553553
GEP->getType() != Start->getType())
554554
return false;
555555

556-
if (Explored.count(GEP->getOperand(0)) == 0)
556+
if (!Explored.contains(GEP->getOperand(0)))
557557
WorkList.push_back(GEP->getOperand(0));
558558
}
559559

@@ -575,7 +575,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
575575
// Explore the PHI nodes further.
576576
for (auto *PN : PHIs)
577577
for (Value *Op : PN->incoming_values())
578-
if (Explored.count(Op) == 0)
578+
if (!Explored.contains(Op))
579579
WorkList.push_back(Op);
580580
}
581581

@@ -589,7 +589,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
589589
auto *Inst = dyn_cast<Instruction>(Val);
590590

591591
if (Inst == Base || Inst == PHI || !Inst || !PHI ||
592-
Explored.count(PHI) == 0)
592+
!Explored.contains(PHI))
593593
continue;
594594

595595
if (PHI->getParent() == Inst->getParent())

llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,11 +1553,11 @@ static bool negateICmpIfUsedByBranchOrSelectOnly(ICmpInst *ICmp,
15531553
SI->swapValues();
15541554
SI->swapProfMetadata();
15551555
if (Scope->TrueBiasedSelects.count(SI)) {
1556-
assert(Scope->FalseBiasedSelects.count(SI) == 0 &&
1556+
assert(!Scope->FalseBiasedSelects.contains(SI) &&
15571557
"Must not be already in");
15581558
Scope->FalseBiasedSelects.insert(SI);
15591559
} else if (Scope->FalseBiasedSelects.count(SI)) {
1560-
assert(Scope->TrueBiasedSelects.count(SI) == 0 &&
1560+
assert(!Scope->TrueBiasedSelects.contains(SI) &&
15611561
"Must not be already in");
15621562
Scope->TrueBiasedSelects.insert(SI);
15631563
}
@@ -1592,7 +1592,7 @@ static void insertTrivialPHIs(CHRScope *Scope,
15921592
SmallVector<Instruction *, 8> Users;
15931593
for (User *U : I.users()) {
15941594
if (auto *UI = dyn_cast<Instruction>(U)) {
1595-
if (BlocksInScope.count(UI->getParent()) == 0 &&
1595+
if (!BlocksInScope.contains(UI->getParent()) &&
15961596
// Unless there's already a phi for I at the exit block.
15971597
!(isa<PHINode>(UI) && UI->getParent() == ExitBlock)) {
15981598
CHR_DEBUG(dbgs() << "V " << I << "\n");

llvm/lib/Transforms/Scalar/Float2Int.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ bool Float2IntPass::validateAndTransform() {
372372
// If it does, transformation would be illegal.
373373
//
374374
// Don't count the roots, as they terminate the graphs.
375-
if (Roots.count(I) == 0) {
375+
if (!Roots.contains(I)) {
376376
// Set the type of the conversion while we're here.
377377
if (!ConvertedToTy)
378378
ConvertedToTy = I->getType();

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ mayLoopAccessLocation(Value *Ptr, ModRefInfo Access, Loop *L,
10191019

10201020
for (BasicBlock *B : L->blocks())
10211021
for (Instruction &I : *B)
1022-
if (IgnoredInsts.count(&I) == 0 &&
1022+
if (!IgnoredInsts.contains(&I) &&
10231023
isModOrRefSet(
10241024
intersectModRef(AA.getModRefInfo(&I, StoreLoc), Access)))
10251025
return true;

llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,16 +1710,12 @@ bool LoopInterchangeTransform::adjustLoopBranches() {
17101710
auto &OuterInnerReductions = LIL.getOuterInnerReductions();
17111711
// Now update the reduction PHIs in the inner and outer loop headers.
17121712
SmallVector<PHINode *, 4> InnerLoopPHIs, OuterLoopPHIs;
1713-
for (PHINode &PHI : InnerLoopHeader->phis()) {
1714-
if (OuterInnerReductions.find(&PHI) == OuterInnerReductions.end())
1715-
continue;
1716-
InnerLoopPHIs.push_back(cast<PHINode>(&PHI));
1717-
}
1718-
for (PHINode &PHI : OuterLoopHeader->phis()) {
1719-
if (OuterInnerReductions.find(&PHI) == OuterInnerReductions.end())
1720-
continue;
1721-
OuterLoopPHIs.push_back(cast<PHINode>(&PHI));
1722-
}
1713+
for (PHINode &PHI : InnerLoopHeader->phis())
1714+
if (OuterInnerReductions.contains(&PHI))
1715+
InnerLoopPHIs.push_back(cast<PHINode>(&PHI));
1716+
for (PHINode &PHI : OuterLoopHeader->phis())
1717+
if (OuterInnerReductions.contains(&PHI))
1718+
OuterLoopPHIs.push_back(cast<PHINode>(&PHI));
17231719

17241720
// Now move the remaining reduction PHIs from outer to inner loop header and
17251721
// vice versa. The PHI nodes must be part of a reduction across the inner and

llvm/lib/Transforms/Scalar/NewGVN.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,7 @@ void NewGVN::convertClassToDFSOrdered(
36073607

36083608
// Skip uses in unreachable blocks, as we're going
36093609
// to delete them.
3610-
if (ReachableBlocks.count(IBlock) == 0)
3610+
if (!ReachableBlocks.contains(IBlock))
36113611
continue;
36123612

36133613
DomTreeNode *DomNode = DT->getNode(IBlock);

0 commit comments

Comments
 (0)