[llvm] 042e860 - [Vectorize] Avoid repeated hash lookups (NFC) (#126681)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 09:09:47 PST 2025


Author: Kazu Hirata
Date: 2025-02-11T09:09:43-08:00
New Revision: 042e860a8a3a2e1be384a5de04b90607ce32e294

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

LOG: [Vectorize] Avoid repeated hash lookups (NFC) (#126681)

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 3816e1b61576a3d..fbbc466f2f7f600 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3709,18 +3709,16 @@ class VPlan {
   ///  yet) for \p V.
   VPValue *getOrAddLiveIn(Value *V) {
     assert(V && "Trying to get or add the VPValue of a null Value");
-    if (!Value2VPValue.count(V)) {
+    auto [It, Inserted] = Value2VPValue.try_emplace(V);
+    if (Inserted) {
       VPValue *VPV = new VPValue(V);
       VPLiveInsToFree.push_back(VPV);
       assert(VPV->isLiveIn() && "VPV must be a live-in.");
-      assert(!Value2VPValue.count(V) && "Value already exists in VPlan");
-      Value2VPValue[V] = VPV;
+      It->second = VPV;
     }
 
-    assert(Value2VPValue.count(V) && "Value does not exist in VPlan");
-    assert(Value2VPValue[V]->isLiveIn() &&
-           "Only live-ins should be in mapping");
-    return Value2VPValue[V];
+    assert(It->second->isLiveIn() && "Only live-ins should be in mapping");
+    return It->second;
   }
 
   /// Return the live-in VPValue for \p V, if there is one or nullptr otherwise.


        


More information about the llvm-commits mailing list