Skip to content

Commit 0c7dccd

Browse files
[Utils] Avoid repeated hash lookups (NFC)
It's safe to use try_emplace instead of operator[] here because: - PhiPredIVs is empty at the beginning of the loop, and - The elements we are inserting into PhiPredIVs are unique.
1 parent a6463f4 commit 0c7dccd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7542,10 +7542,10 @@ bool SimplifyCFGOpt::simplifyDuplicateSwitchArms(SwitchInst *SI,
75427542
// SwitchSuccWrapper.
75437543
PhiPredIVs.reserve(Phis.size());
75447544
for (PHINode *Phi : Phis) {
7545-
PhiPredIVs[Phi] =
7546-
SmallDenseMap<BasicBlock *, Value *, 8>(Phi->getNumIncomingValues());
7545+
auto &IVs =
7546+
PhiPredIVs.try_emplace(Phi, Phi->getNumIncomingValues()).first->second;
75477547
for (auto &IV : Phi->incoming_values())
7548-
PhiPredIVs[Phi].insert({Phi->getIncomingBlock(IV), IV.get()});
7548+
IVs.insert({Phi->getIncomingBlock(IV), IV.get()});
75497549
}
75507550

75517551
// Build a set such that if the SwitchSuccWrapper exists in the set and

0 commit comments

Comments
 (0)