[Mlir-commits] [mlir] [Conversion] Avoid repeated hash lookups (NFC) (PR #111637)

Kazu Hirata llvmlistbot at llvm.org
Tue Oct 8 23:14:29 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111637

None

>From 904a0b14974aa4ebe87ee67facef932b0a1f000d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 8 Oct 2024 23:08:40 -0700
Subject: [PATCH] [Conversion] Avoid repeated hash lookups (NFC)

---
 mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
index 2bcd082fb3e82f..dece254c325fcd 100644
--- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
+++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp
@@ -509,12 +509,11 @@ static LogicalResult processParallelLoop(
                   ensureLaunchIndependent(cloningMap.lookupOrDefault(step))});
           // todo(herhut,ravishankarm): Update the behavior of setMappingAttr
           // when this condition is relaxed.
-          if (bounds.contains(processor)) {
+          if (!bounds.try_emplace(processor, launchBound).second) {
             return rewriter.notifyMatchFailure(
                 parallelOp, "cannot redefine the bound for processor " +
                                 Twine(static_cast<int64_t>(processor)));
           }
-          bounds[processor] = launchBound;
         }
         if (!boundIsPrecise) {
           // We are using an approximation, create a surrounding conditional.



More information about the Mlir-commits mailing list