Skip to content

Commit 782ca72

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c66bc5afd03a' from apple/master into swift/master-next
2 parents 2cd73a5 + c66bc5a commit 782ca72

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,9 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoSideEffect]> {
18531853
// Fortran loops
18541854
//===----------------------------------------------------------------------===//
18551855

1856-
def fir_ResultOp : fir_Op<"result", [NoSideEffect, ReturnLike, Terminator]> {
1856+
def fir_ResultOp : fir_Op<"result",
1857+
[NoSideEffect, ReturnLike, Terminator,
1858+
ParentOneOf<["WhereOp", "LoopOp", "IterWhileOp"]>]> {
18571859
let summary = "special terminator for use in fir region operations";
18581860

18591861
let description = [{
@@ -1970,7 +1972,7 @@ def fir_LoopOp : region_Op<"do_loop",
19701972
}];
19711973
}
19721974

1973-
def fir_WhereOp : region_Op<"if"> {
1975+
def fir_WhereOp : region_Op<"if", [NoRegionArguments]> {
19741976
let summary = "if-then-else conditional operation";
19751977
let description = [{
19761978
Used to conditionally execute operations. This operation is the FIR

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -968,19 +968,12 @@ static mlir::LogicalResult verify(fir::ResultOp op) {
968968
auto results = parentOp->getResults();
969969
auto operands = op.getOperands();
970970

971-
if (isa<fir::WhereOp>(parentOp) || isa<fir::LoopOp>(parentOp) ||
972-
isa<fir::IterWhileOp>(parentOp)) {
973-
if (parentOp->getNumResults() != op.getNumOperands())
974-
return op.emitOpError() << "parent of result must have same arity";
975-
for (auto e : llvm::zip(results, operands)) {
976-
if (std::get<0>(e).getType() != std::get<1>(e).getType())
977-
return op.emitOpError()
978-
<< "types mismatch between result op and its parent";
979-
}
980-
} else {
981-
return op.emitOpError()
982-
<< "result only terminates if, do_loop, or iterate_while regions";
983-
}
971+
if (parentOp->getNumResults() != op.getNumOperands())
972+
return op.emitOpError() << "parent of result must have same arity";
973+
for (auto e : llvm::zip(results, operands))
974+
if (std::get<0>(e).getType() != std::get<1>(e).getType())
975+
return op.emitOpError()
976+
<< "types mismatch between result op and its parent";
984977
return success();
985978
}
986979

@@ -1452,16 +1445,6 @@ static mlir::ParseResult parseWhereOp(OpAsmParser &parser,
14521445
}
14531446

14541447
static LogicalResult verify(fir::WhereOp op) {
1455-
// Verify that the entry of each child region does not have arguments.
1456-
for (auto &region : op.getOperation()->getRegions()) {
1457-
if (region.empty())
1458-
continue;
1459-
1460-
for (auto &b : region)
1461-
if (b.getNumArguments() != 0)
1462-
return op.emitOpError(
1463-
"requires that child entry blocks have no arguments");
1464-
}
14651448
if (op.getNumResults() != 0 && op.otherRegion().empty())
14661449
return op.emitOpError("must have an else block if defining values");
14671450

0 commit comments

Comments
 (0)