Skip to content

Commit 15e6b5d

Browse files
[Transforms] Avoid repeated hash lookups (NFC) (#109565)
1 parent c219ebd commit 15e6b5d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/Transforms/IPO/IROutliner.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,8 @@ static void findConstants(IRSimilarityCandidate &C, DenseSet<unsigned> &NotSame,
787787
// global value numbering.
788788
unsigned GVN = *C.getGVN(V);
789789
if (isa<Constant>(V))
790-
if (NotSame.contains(GVN) && !Seen.contains(GVN)) {
790+
if (NotSame.contains(GVN) && Seen.insert(GVN).second)
791791
Inputs.push_back(GVN);
792-
Seen.insert(GVN);
793-
}
794792
}
795793
}
796794
}
@@ -814,8 +812,9 @@ static void mapInputsToGVNs(IRSimilarityCandidate &C,
814812
// replacement.
815813
for (Value *Input : CurrentInputs) {
816814
assert(Input && "Have a nullptr as an input");
817-
if (OutputMappings.contains(Input))
818-
Input = OutputMappings.find(Input)->second;
815+
auto It = OutputMappings.find(Input);
816+
if (It != OutputMappings.end())
817+
Input = It->second;
819818
assert(C.getGVN(Input) && "Could not find a numbering for the given input");
820819
EndInputNumbers.push_back(*C.getGVN(Input));
821820
}
@@ -836,8 +835,9 @@ remapExtractedInputs(const ArrayRef<Value *> ArgInputs,
836835
// Get the global value number for each input that will be extracted as an
837836
// argument by the code extractor, remapping if needed for reloaded values.
838837
for (Value *Input : ArgInputs) {
839-
if (OutputMappings.contains(Input))
840-
Input = OutputMappings.find(Input)->second;
838+
auto It = OutputMappings.find(Input);
839+
if (It != OutputMappings.end())
840+
Input = It->second;
841841
RemappedArgInputs.insert(Input);
842842
}
843843
}

0 commit comments

Comments
 (0)