Skip to content

[mlir] Use Region::hasOneBlock (NFC) #133879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ LogicalResult LoopOp::verifyRegions() {
return emitOpError(
"should not have 'spirv.mlir.merge' op outside the merge block");

if (std::next(region.begin()) == region.end())
if (region.hasOneBlock())
return emitOpError(
"must have an entry block branching to the loop header block");
// The first block is the entry block.
Expand Down Expand Up @@ -502,7 +502,7 @@ LogicalResult SelectionOp::verifyRegions() {
return emitOpError(
"should not have 'spirv.mlir.merge' op outside the merge block");

if (std::next(region.begin()) == region.end())
if (region.hasOneBlock())
return emitOpError("must have a selection header block");

return success();
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Transforms/Utils/RegionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ LogicalResult mlir::eraseUnreachableBlocks(RewriterBase &rewriter,
continue;

// If this is a single block region, just collect the nested regions.
if (std::next(region->begin()) == region->end()) {
if (region->hasOneBlock()) {
for (Operation &op : region->front())
for (Region &region : op.getRegions())
worklist.push_back(&region);
Expand Down
Loading