Skip to content

Commit 43ba999

Browse files
undordorAradME
andauthored
[mlir][scf] ExecuteRegionOp folders to consider no_inline attribute (#158083)
Fix missing handling of no_inline existence in ExecuteRegionOp folders. Co-authored-by: Dor Arad <[email protected]>
1 parent 9c91d4a commit 43ba999

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

mlir/lib/Dialect/SCF/IR/SCF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ struct MultiBlockExecuteInliner : public OpRewritePattern<ExecuteRegionOp> {
237237

238238
LogicalResult matchAndRewrite(ExecuteRegionOp op,
239239
PatternRewriter &rewriter) const override {
240+
if (op.getNoInline())
241+
return failure();
240242
if (!isa<FunctionOpInterface, ExecuteRegionOp>(op->getParentOp()))
241243
return failure();
242244

mlir/test/Dialect/SCF/canonicalize.mlir

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,24 @@ func.func @execute_region_no_inline() {
14831483

14841484
// -----
14851485

1486+
// CHECK-LABEL: func @execute_region_under_func_no_inline
1487+
func.func @execute_region_under_func_no_inline() {
1488+
"test.foo"() : () -> ()
1489+
%v = scf.execute_region -> i64 no_inline {
1490+
%x = "test.val"() : () -> i64
1491+
scf.yield %x : i64
1492+
}
1493+
"test.bar"(%v) : (i64) -> ()
1494+
return
1495+
}
1496+
1497+
// CHECK-NEXT: "test.foo"() : () -> ()
1498+
// CHECK-NEXT: scf.execute_region
1499+
// CHECK-NEXT: %[[VAL:.*]] = "test.val"() : () -> i64
1500+
// CHECK-NEXT: scf.yield %[[VAL]] : i64
1501+
1502+
// -----
1503+
14861504
// CHECK-LABEL: func @func_execute_region_inline
14871505
func.func @func_execute_region_inline() {
14881506
"test.foo"() : () -> ()

0 commit comments

Comments
 (0)