[Mlir-commits] [mlir] [MLIR] Introduce support for early exits (PR #166688)
Mehdi Amini
llvmlistbot at llvm.org
Fri Feb 20 03:11:12 PST 2026
================
@@ -560,6 +571,86 @@ func.func @accelerator_compute(i64, i1) -> i64 { // An SSACFG region
}
```
+#### Region Terminator
+
+A `RegionTerminator` is a specialization of a block terminator (the `Terminator`
+trait) that transfer the control back to a parent operation. It can exit multiple nested regions in a single step, bypassing the
+normal `RegionBranchOpInterface` exit path for every intermediate level. In the
+generic operation format, the exit count appears in the successor-list brackets
+as a plain integer rather than a block label (see `num-breaking-regions` in the
+grammar above). Custom assembly formats may surface this as a literal integer
+argument (e.g. `scf.break 2`).
+
+`num-breaking-regions = N` means the operation exits **N region levels** in
+total, counting its own immediately enclosing region as 1:
+
+- `N = 1`: normal region exit â control is returned to the immediate parent
+ operation (e.g. `scf.yield` in `scf.if`, or `scf.break 1` in `scf.loop`).
+- `N = 2`: exits the current region and one additional ancestor region; the
+ intermediate parent op must define `PropagateControlFlowBreak`.
+- `N = K`: exits K region levels; the Kâ1 intermediate parent operations must
+ all define `PropagateControlFlowBreak`.
+
+The outermost operation that *receives* the break implements
+`HasBreakingControlFlowOpInterface`. It is distinct from intermediate ops that
----------------
joker-eph wrote:
scf.if does not have early exit itself, it only participates in early-exit for scf.loop.
The HasBreakingControlFlowOpInterface is only needed if you have terminator with N>1.
The PropagateControlFlowBreak takes care of scf.if.
https://github.com/llvm/llvm-project/pull/166688
More information about the Mlir-commits
mailing list