[llvm] [Scalar] Avoid repeated hash lookups (NFC) (PR #129989)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 21:56:10 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/129989.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/GuardWidening.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
index 2978b7990a6eb..3ba5b79293bcd 100644
--- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp
+++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
@@ -665,8 +665,8 @@ Value *GuardWideningImpl::freezeAndPush(Value *Orig,
       CacheOfFreezes[Def] = FI;
     }
 
-    if (CacheOfFreezes.count(Def))
-      U.set(CacheOfFreezes[Def]);
+    if (auto It = CacheOfFreezes.find(Def); It != CacheOfFreezes.end())
+      U.set(It->second);
     return true;
   };
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/129989


More information about the llvm-commits mailing list