[Mlir-commits] [mlir] ad44495 - [mlir][NFC] Replace some llvm::find with llvm::is_contained.
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Jun 5 20:01:45 PDT 2022
Author: jacquesguan
Date: 2022-06-06T03:01:14Z
New Revision: ad44495ad3058f207d621fb9c3546ae0d51f26ee
URL: https://github.com/llvm/llvm-project/commit/ad44495ad3058f207d621fb9c3546ae0d51f26ee
DIFF: https://github.com/llvm/llvm-project/commit/ad44495ad3058f207d621fb9c3546ae0d51f26ee.diff
LOG: [mlir][NFC] Replace some llvm::find with llvm::is_contained.
This patch replaces some llvm::find with llvm::is_contained, it should be more clear.
Differential Revision: https://reviews.llvm.org/D127077
Added:
Modified:
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
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
index 6e8cec021845a..f69d612bbcdb9 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
@@ -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;
diff --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
index 152183c172d9d..1d37af5420afd 100644
--- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
+++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
@@ -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;
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
index 3e86637c2cf9d..e1d128ffd7c00 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
@@ -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;
};
diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp
index ecb66faee1999..2460e535d3ad5 100644
--- a/mlir/lib/Dialect/SCF/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/SCF.cpp
@@ -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.
diff --git a/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp b/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
index 5abc780e22d8e..b28d4d84b7967 100644
--- a/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
+++ b/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
@@ -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
More information about the Mlir-commits
mailing list