[Mlir-commits] [mlir] [MLIR] Introduce support for early exits (PR #166688)
Mehdi Amini
llvmlistbot at llvm.org
Sun Mar 1 03:21:17 PST 2026
================
@@ -558,6 +571,89 @@ func.func @accelerator_compute(i64, i1) -> i64 { // An SSACFG region
}
```
+#### Region Terminator
----------------
joker-eph wrote:
> Why does it matter if the property is static or dynamic?
Static properties are encoded on the OperationName itself, which is common for all instances of Operation. While dynamic properties are per-instance.
Just like in C++ you wouldn't handle static properties of a class by adding instance members...
> the differentiating point of encoding information in OperationState is that you can look it up without having to know the kind of op.
You can check traits without knowing the kind of op.
(By the way you refer to `OperationState` but to be more precise we should refer to `Operation` right? OperationState is the transient "Builder").
> It even works for unregistered ops.
Yes encoding the information on `Operation` itself makes it available to unregistered ops.
Here is a quick port of the current patchto use an interface:
https://github.com/llvm/llvm-project/commit/0a5bf777880bc2dcab0c69d6ea614c51ddb32999
Now the complication with this will come from supporting unregistered ops. That is all these APIs:
```
bool hasNestedPredecessors(Operation *op);
bool hasBreakingControlFlowOps(Operation *op);
void collectAllNestedPredecessors(Operation *op,
SmallVector<Operation *> &predecessors);
```
Have to be changed:
```
bool mightHaveNestedPredecessors(Operation *op);
bool mightHaveBreakingControlFlowOps(Operation *op);
/// !! This will collect unregistered op also, callers can't just cast the result to
/// RegionBranchTerminatorOpInterface, have to handle conservatively, add bailout-path, etc.
void collectAllNestedMaybePredecessors(Operation *op,
SmallVector<Operation *> &predecessors);
```
https://github.com/llvm/llvm-project/pull/166688
More information about the Mlir-commits
mailing list