Skip to content

Commit d5aa6df

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#123286)
1 parent d5ef2c0 commit d5aa6df

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,11 +1409,10 @@ template <class BT> void BlockFrequencyInfoImpl<BT>::applyIterativeInference() {
14091409
auto Node = getNode(&BB);
14101410
if (!Node.isValid())
14111411
continue;
1412-
if (BlockIndex.count(&BB)) {
1413-
Freqs[Node.Index].Scaled = Freq[BlockIndex[&BB]];
1414-
} else {
1412+
if (auto It = BlockIndex.find(&BB); It != BlockIndex.end())
1413+
Freqs[Node.Index].Scaled = Freq[It->second];
1414+
else
14151415
Freqs[Node.Index].Scaled = Scaled64::getZero();
1416-
}
14171416
}
14181417
}
14191418

@@ -1764,8 +1763,8 @@ void BlockFrequencyInfoImpl<BT>::verifyMatch(
17641763
for (auto &Entry : ValidNodes) {
17651764
const BlockT *BB = Entry.first;
17661765
BlockNode Node = Entry.second;
1767-
if (OtherValidNodes.count(BB)) {
1768-
BlockNode OtherNode = OtherValidNodes[BB];
1766+
if (auto It = OtherValidNodes.find(BB); It != OtherValidNodes.end()) {
1767+
BlockNode OtherNode = It->second;
17691768
const auto &Freq = Freqs[Node.Index];
17701769
const auto &OtherFreq = Other.Freqs[OtherNode.Index];
17711770
if (Freq.Integer != OtherFreq.Integer) {

0 commit comments

Comments
 (0)