[Mlir-commits] [mlir] [MLIR] Introduce support for early exits (PR #166688)
Mehdi Amini
llvmlistbot at llvm.org
Fri Feb 20 12:16:32 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
+merely propagate the break (`PropagateControlFlowBreak`). A loop nested inside
+another loop carries both traits simultaneously: it handles breaks targeting
+itself, and propagates breaks that target an outer loop through it.
+
+Region terminators may carry values. When breaking out of a loop that produces
----------------
joker-eph wrote:
Yes, done
https://github.com/llvm/llvm-project/pull/166688
More information about the Mlir-commits
mailing list