Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 4 additions & 0 deletions mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def ExecuteRegionOp : SCF_Op<"execute_region", [
```
}];

let arguments = (ins
UnitAttr:$no_inline
);

let results = (outs Variadic<AnyType>);

let regions = (region AnyRegion:$region);
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SCF/IR/SCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ struct SingleBlockExecuteInliner : public OpRewritePattern<ExecuteRegionOp> {

LogicalResult matchAndRewrite(ExecuteRegionOp op,
PatternRewriter &rewriter) const override {
if (!op.getRegion().hasOneBlock())
if (!op.getRegion().hasOneBlock() || op.getNoInline())
return failure();
replaceOpWithRegion(rewriter, op, op.getRegion());
return success();
Expand Down
22 changes: 22 additions & 0 deletions mlir/test/Dialect/SCF/canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,28 @@ func.func @execute_region_elim() {

// -----

// CHECK-LABEL: func @execute_region_elim_noinline
func.func @execute_region_elim_noinline() {
affine.for %i = 0 to 100 {
"test.foo"() : () -> ()
%v = scf.execute_region -> i64 {
%x = "test.val"() : () -> i64
scf.yield %x : i64
} {no_inline}
"test.bar"(%v) : (i64) -> ()
}
return
}

// CHECK-NEXT: affine.for %arg0 = 0 to 100 {
// CHECK-NEXT: "test.foo"() : () -> ()
// CHECK-NEXT: scf.execute_region
// CHECK-NEXT: %[[VAL:.*]] = "test.val"() : () -> i64
// CHECK-NEXT: scf.yield %[[VAL]] : i64
// CHECK-NEXT: }

// -----

// CHECK-LABEL: func @func_execute_region_elim
func.func @func_execute_region_elim() {
"test.foo"() : () -> ()
Expand Down