[llvm] ab06a18 - [IRSim] Avoid repeated hash lookups (NFC) (#108483)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 07:53:26 PDT 2024


Author: Kazu Hirata
Date: 2024-09-13T07:53:23-07:00
New Revision: ab06a18b59eddfa0719faa1fe40e83829939c6db

URL: https://github.com/llvm/llvm-project/commit/ab06a18b59eddfa0719faa1fe40e83829939c6db
DIFF: https://github.com/llvm/llvm-project/commit/ab06a18b59eddfa0719faa1fe40e83829939c6db.diff

LOG: [IRSim] Avoid repeated hash lookups (NFC) (#108483)

Added: 
    

Modified: 
    llvm/lib/Analysis/IRSimilarityIdentifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index 41815c633fdf2a..42e986e6179dd3 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -1420,16 +1420,8 @@ void IRSimilarityIdentifier::findCandidates(
         // IRSimilarityCandidates that include that instruction.
         for (IRSimilarityCandidate &IRCand : SimilarityCandidates->back()) {
           for (unsigned Idx = IRCand.getStartIdx(), Edx = IRCand.getEndIdx();
-               Idx <= Edx; ++Idx) {
-            DenseMap<unsigned, DenseSet<IRSimilarityCandidate *>>::iterator
-                IdIt;
-            IdIt = IndexToIncludedCand.find(Idx);
-            bool Inserted = false;
-            if (IdIt == IndexToIncludedCand.end())
-              std::tie(IdIt, Inserted) = IndexToIncludedCand.insert(
-                  std::make_pair(Idx, DenseSet<IRSimilarityCandidate *>()));
-            IdIt->second.insert(&IRCand);
-          }
+               Idx <= Edx; ++Idx)
+            IndexToIncludedCand[Idx].insert(&IRCand);
           // Add mapping of candidate to the overall similarity group number.
           CandToGroup.insert(
               std::make_pair(&IRCand, SimilarityCandidates->size() - 1));


        


More information about the llvm-commits mailing list