[Mlir-commits] [mlir] [mlir] Use llvm::is_contained (NFC) (PR #140986)

Kazu Hirata llvmlistbot at llvm.org
Wed May 21 19:23:28 PDT 2025


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

None

>From 670f5c834454100a33239fc388dac478213a2534 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 21 May 2025 14:10:49 -0700
Subject: [PATCH] [mlir] Use llvm::is_contained (NFC)

---
 .../mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h    | 3 +--
 mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp  | 3 +--
 mlir/test/lib/Analysis/TestTopologicalSort.cpp                 | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h b/mlir/include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h
index 78109770efab7..cf86b9a23f59e 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h
@@ -54,8 +54,7 @@ struct OpWithUnstructuredControlFlowBufferizableOpInterfaceExternalModel
       // If the forwarded operand is already on the invocation stack, we ran
       // into a loop and this operand cannot be used to compute the bufferized
       // type.
-      if (llvm::find(invocationStack, opOperand->get()) !=
-          invocationStack.end())
+      if (llvm::is_contained(invocationStack, opOperand->get()))
         continue;
 
       // Compute the bufferized type of the forwarded operand.
diff --git a/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp b/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp
index 10aaf35be2ab7..81d376ef991b6 100644
--- a/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp
+++ b/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp
@@ -807,8 +807,7 @@ void transform::TransformState::compactOpHandles() {
   for (Value handle : opHandlesToCompact) {
     Mappings &mappings = getMapping(handle, /*allowOutOfScope=*/true);
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
-    if (llvm::find(mappings.direct[handle], nullptr) !=
-        mappings.direct[handle].end())
+    if (llvm::is_contained(mappings.direct[handle], nullptr))
       // Payload IR is removed from the mapping. This invalidates the respective
       // iterators.
       mappings.incrementTimestamp(handle);
diff --git a/mlir/test/lib/Analysis/TestTopologicalSort.cpp b/mlir/test/lib/Analysis/TestTopologicalSort.cpp
index c7e0206b2a4d7..bd7e60f1ecc33 100644
--- a/mlir/test/lib/Analysis/TestTopologicalSort.cpp
+++ b/mlir/test/lib/Analysis/TestTopologicalSort.cpp
@@ -53,7 +53,7 @@ struct TestTopologicalSortAnalysisPass
         return WalkResult::advance();
       });
 
-      if (llvm::find(selectedOps, nullptr) != selectedOps.end()) {
+      if (llvm::is_contained(selectedOps, nullptr)) {
         root->emitError("invalid test case: some indices are missing among the "
                         "selected ops");
         return WalkResult::skip();



More information about the Mlir-commits mailing list