[llvm] bd15595 - [IndVars] Avoid repeated hash lookups (NFC) (#107513)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 07:40:30 PDT 2024


Author: Kazu Hirata
Date: 2024-09-06T07:40:27-07:00
New Revision: bd1559533d88f0d32b7ca17aa316b07b7924be2d

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

LOG: [IndVars] Avoid repeated hash lookups (NFC) (#107513)

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index a950a4f57ef486..ff13c0653e9b96 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1103,10 +1103,8 @@ class WidenIV {
 
   void updatePostIncRangeInfo(Value *Def, Instruction *UseI, ConstantRange R) {
     DefUserPair Key(Def, UseI);
-    auto It = PostIncRangeInfos.find(Key);
-    if (It == PostIncRangeInfos.end())
-      PostIncRangeInfos.insert({Key, R});
-    else
+    auto [It, Inserted] = PostIncRangeInfos.try_emplace(Key, R);
+    if (!Inserted)
       It->second = R.intersectWith(It->second);
   }
 


        


More information about the llvm-commits mailing list