[Mlir-commits] [mlir] [MLIR] Introduce support for early exits (PR #166688)
Matthias Springer
llvmlistbot at llvm.org
Wed Feb 25 05:17:12 PST 2026
================
@@ -558,6 +571,89 @@ func.func @accelerator_compute(i64, i1) -> i64 { // An SSACFG region
}
```
+#### Region Terminator
----------------
matthias-springer wrote:
I'm trying to understand why `num-breaking-regions` has to be defined in the language reference as opposed to an optional op interface. (Note that we also do not mention the `RegionBranchOpInterface` anywhere, apart from one paragraph that you just added.)
The obvious problem with early exit is this sentence in the current wording of the language reference: `Terminator operations without successors can only pass control back to the containing operation.`
Let's consider the following design for a moment. I feel like something will break, but I can't pinpoint it.
* Rephrase lang ref: `Terminator operations without successors can only pass control back to an enclosing operation.`
* Add new op interface `RegionTerminatorOpInterface`, with an interface method `getNumBreakingRegions()`. The default implementation is `return 1;`. Registered ops that do not implement the `RegionTerminatorOpInterface` are assumed to have `num-breaking-regions=0` or `num-breaking-regions=1`. ([As you said](https://github.com/llvm/llvm-project/pull/166688/changes#r2832663234), it will eventually become mandatory to implement that interface.) Unregistered ops that are at the end of a block have an unknown number of breaking regions. Unregistered ops that are in the middle of a block have `num-breaking-regions=0`. (They are not even terminators.)
https://github.com/llvm/llvm-project/pull/166688
More information about the Mlir-commits
mailing list