[llvm] 9528bcd - [IRSim] Avoid repeated hash lookups (NFC) (#107510)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 07:39:57 PDT 2024
Author: Kazu Hirata
Date: 2024-09-06T07:39:54-07:00
New Revision: 9528bcd5327c0120c82c84031b52b167037aa650
URL: https://github.com/llvm/llvm-project/commit/9528bcd5327c0120c82c84031b52b167037aa650
DIFF: https://github.com/llvm/llvm-project/commit/9528bcd5327c0120c82c84031b52b167037aa650.diff
LOG: [IRSim] Avoid repeated hash lookups (NFC) (#107510)
Added:
Modified:
llvm/lib/Analysis/IRSimilarityIdentifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index ebe22f5c35d182..41815c633fdf2a 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -459,16 +459,14 @@ IRSimilarityCandidate::IRSimilarityCandidate(unsigned StartIdx, unsigned Len,
// Map the operand values to an unsigned integer if it does not already
// have an unsigned integer assigned to it.
for (Value *Arg : ID->OperVals)
- if (!ValueToNumber.contains(Arg)) {
- ValueToNumber.try_emplace(Arg, LocalValNumber);
+ if (ValueToNumber.try_emplace(Arg, LocalValNumber).second) {
NumberToValue.try_emplace(LocalValNumber, Arg);
LocalValNumber++;
}
// Mapping the instructions to an unsigned integer if it is not already
// exist in the mapping.
- if (!ValueToNumber.contains(ID->Inst)) {
- ValueToNumber.try_emplace(ID->Inst, LocalValNumber);
+ if (ValueToNumber.try_emplace(ID->Inst, LocalValNumber).second) {
NumberToValue.try_emplace(LocalValNumber, ID->Inst);
LocalValNumber++;
}
@@ -484,12 +482,10 @@ IRSimilarityCandidate::IRSimilarityCandidate(unsigned StartIdx, unsigned Len,
DenseSet<BasicBlock *> BBSet;
getBasicBlocks(BBSet);
for (BasicBlock *BB : BBSet) {
- if (ValueToNumber.contains(BB))
- continue;
-
- ValueToNumber.try_emplace(BB, LocalValNumber);
- NumberToValue.try_emplace(LocalValNumber, BB);
- LocalValNumber++;
+ if (ValueToNumber.try_emplace(BB, LocalValNumber).second) {
+ NumberToValue.try_emplace(LocalValNumber, BB);
+ LocalValNumber++;
+ }
}
}
More information about the llvm-commits
mailing list