[Mlir-commits] [mlir] [Affine] Avoid repeated hash lookups (NFC) (PR #111330)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Oct 6 19:35:21 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-affine

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) mlir/lib/Dialect/Affine/Analysis/Utils.cpp (+3-3) 


``````````diff
diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index 194ee9115e3d7a..29608647d85746 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -1927,9 +1927,9 @@ static std::optional<int64_t> getMemoryFootprintBytes(Block &block,
       return opInst->emitError("error obtaining memory region\n");
     }
 
-    auto it = regions.find(region->memref);
-    if (it == regions.end()) {
-      regions[region->memref] = std::move(region);
+    auto [it, inserted] = regions.try_emplace(region->memref);
+    if (inserted) {
+      it->second = std::move(region);
     } else if (failed(it->second->unionBoundingBox(*region))) {
       return opInst->emitWarning(
           "getMemoryFootprintBytes: unable to perform a union on a memory "

``````````

</details>


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


More information about the Mlir-commits mailing list