summaryrefslogtreecommitdiffstats
path: root/mlir/lib
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib')
-rw-r--r--mlir/lib/Dialect/AffineOps/AffineOps.cpp3
-rw-r--r--mlir/lib/Dialect/SPIRV/SPIRVOps.cpp2
-rw-r--r--mlir/lib/IR/Module.cpp2
3 files changed, 3 insertions, 4 deletions
diff --git a/mlir/lib/Dialect/AffineOps/AffineOps.cpp b/mlir/lib/Dialect/AffineOps/AffineOps.cpp
index 6d90464e632..76417bb3289 100644
--- a/mlir/lib/Dialect/AffineOps/AffineOps.cpp
+++ b/mlir/lib/Dialect/AffineOps/AffineOps.cpp
@@ -1337,8 +1337,7 @@ struct AffineForEmptyLoopFolder : public OpRewritePattern<AffineForOp> {
PatternMatchResult matchAndRewrite(AffineForOp forOp,
PatternRewriter &rewriter) const override {
// Check that the body only contains a terminator.
- auto *body = forOp.getBody();
- if (std::next(body->begin()) != body->end())
+ if (!has_single_element(*forOp.getBody()))
return matchFailure();
rewriter.eraseOp(forOp);
return matchSuccess();
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
index 85e22a5c391..c47d4b87027 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
@@ -1418,7 +1418,7 @@ static void print(spirv::LoopOp loopOp, OpAsmPrinter &printer) {
/// given `dstBlock`.
static inline bool hasOneBranchOpTo(Block &srcBlock, Block &dstBlock) {
// Check that there is only one op in the `srcBlock`.
- if (srcBlock.empty() || std::next(srcBlock.begin()) != srcBlock.end())
+ if (!has_single_element(srcBlock))
return false;
auto branchOp = dyn_cast<spirv::BranchOp>(srcBlock.back());
diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp
index 9f3bdaa854c..f55f960ffa2 100644
--- a/mlir/lib/IR/Module.cpp
+++ b/mlir/lib/IR/Module.cpp
@@ -87,7 +87,7 @@ LogicalResult ModuleOp::verify() {
auto &bodyRegion = getOperation()->getRegion(0);
// The body must contain a single basic block.
- if (bodyRegion.empty() || std::next(bodyRegion.begin()) != bodyRegion.end())
+ if (!has_single_element(bodyRegion))
return emitOpError("expected body region to have a single block");
// Check that the body has no block arguments.
OpenPOWER on IntegriCloud