[Mlir-commits] [mlir] 7d9f993 - [Transform] Avoid repeated hash lookups (NFC) (#111620)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 9 06:43:41 PDT 2024
Author: Kazu Hirata
Date: 2024-10-09T06:43:35-07:00
New Revision: 7d9f9938ff788aa7565c61ce6f391264750515af
URL: https://github.com/llvm/llvm-project/commit/7d9f9938ff788aa7565c61ce6f391264750515af
DIFF: https://github.com/llvm/llvm-project/commit/7d9f9938ff788aa7565c61ce6f391264750515af.diff
LOG: [Transform] Avoid repeated hash lookups (NFC) (#111620)
Added:
Modified:
mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp b/mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp
index 561d3d5b05af64..e6db819b51c22c 100644
--- a/mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp
+++ b/mlir/lib/Dialect/Transform/Transforms/CheckUses.cpp
@@ -39,11 +39,11 @@ template <typename FnTy>
const llvm::SmallPtrSet<Block *, 4> &
getReachableImpl(Block *block, FnTy getNextNodes,
DenseMap<Block *, llvm::SmallPtrSet<Block *, 4>> &cache) {
- auto it = cache.find(block);
- if (it != cache.end())
+ auto [it, inserted] = cache.try_emplace(block);
+ if (!inserted)
return it->getSecond();
- llvm::SmallPtrSet<Block *, 4> &reachable = cache[block];
+ llvm::SmallPtrSet<Block *, 4> &reachable = it->second;
SmallVector<Block *> worklist;
worklist.push_back(block);
while (!worklist.empty()) {
More information about the Mlir-commits
mailing list