[mlir][NFC] Replace some llvm::find with llvm::is_contained.
authorjacquesguan <Jianjian.Guan@streamcomputing.com>
Mon, 6 Jun 2022 02:31:12 +0000 (02:31 +0000)
committerjacquesguan <Jianjian.Guan@streamcomputing.com>
Mon, 6 Jun 2022 03:01:14 +0000 (03:01 +0000)
This patch replaces some llvm::find with llvm::is_contained, it should be more clear.

Differential Revision: https://reviews.llvm.org/D127077

mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
mlir/lib/Dialect/SCF/SCF.cpp
mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp

index 6e8cec0..f69d612 100644 (file)
@@ -164,8 +164,7 @@ def BufferizableOpInterface : OpInterface<"BufferizableOpInterface"> {
               continue;
             SmallVector<OpResult> aliasingOpResults =
                 bufferizableOp.getAliasingOpResult(opOperand, state);
-            if (llvm::find(aliasingOpResults, opResult)
-                != aliasingOpResults.end())
+            if (llvm::is_contained(aliasingOpResults, opResult))
               result.push_back(&opOperand);
           }
           return result;
index 152183c..1d37af5 100644 (file)
@@ -94,11 +94,10 @@ matchSelectReduction(Block &block, ArrayRef<Predicate> lessThanPredicates,
 
   // Detect whether the comparison is less-than or greater-than, otherwise bail.
   bool isLess;
-  if (llvm::find(lessThanPredicates, compare.getPredicate()) !=
-      lessThanPredicates.end()) {
+  if (llvm::is_contained(lessThanPredicates, compare.getPredicate())) {
     isLess = true;
-  } else if (llvm::find(greaterThanPredicates, compare.getPredicate()) !=
-             greaterThanPredicates.end()) {
+  } else if (llvm::is_contained(greaterThanPredicates,
+                                compare.getPredicate())) {
     isLess = false;
   } else {
     return false;
index 3e86637..e1d128f 100644 (file)
@@ -198,9 +198,8 @@ struct OneShotBufferizePass
           [&](Operation *op) {
             // Filter may be specified via options.
             if (this->dialectFilter.hasValue())
-              return llvm::find(this->dialectFilter,
-                                op->getDialect()->getNamespace()) !=
-                     this->dialectFilter.end();
+              return llvm::is_contained(this->dialectFilter,
+                                        op->getDialect()->getNamespace());
             // No filter specified: All other ops are allowed.
             return true;
           };
index ecb66fa..2460e53 100644 (file)
@@ -2467,14 +2467,10 @@ struct MergeNestedParallelLoops : public OpRewritePattern<ParallelOp> {
     if (!innerOp)
       return failure();
 
-    auto hasVal = [](const auto &range, Value val) {
-      return llvm::find(range, val) != range.end();
-    };
-
     for (auto val : outerBody.getArguments())
-      if (hasVal(innerOp.getLowerBound(), val) ||
-          hasVal(innerOp.getUpperBound(), val) ||
-          hasVal(innerOp.getStep(), val))
+      if (llvm::is_contained(innerOp.getLowerBound(), val) ||
+          llvm::is_contained(innerOp.getUpperBound(), val) ||
+          llvm::is_contained(innerOp.getStep(), val))
         return failure();
 
     // Reductions are not supported yet.
index 5abc780..b28d4d8 100644 (file)
@@ -270,7 +270,7 @@ LogicalResult scf::canonicalizeMinMaxOpInLoop(RewriterBase &rewriter,
   // Find all iteration variables among `minOp`'s operands add constrain them.
   for (Value operand : operands) {
     // Skip duplicate ivs.
-    if (llvm::find(allIvs, operand) != allIvs.end())
+    if (llvm::is_contained(allIvs, operand))
       continue;
 
     // If `operand` is an iteration variable: Find corresponding loop