Add RegionBranchOpInterface on affine.for op so that transforms relying
on RegionBranchOpInterface can support affine.for. E.g.:
buffer-deallocation pass.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/include/mlir/Dialect/Affine/IR/AffineOps.td | ||
---|---|---|
343–348 | You can do DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorEntryOperands"]> in the declaration to request declarations to be emitted for additional interface methods. | |
mlir/lib/Dialect/Affine/IR/AffineOps.cpp | ||
1746–1748 | I am a bit rusty on what the interface expects here, so just pointing out that the loop may have zero iterations and branch into the body. |
Thanks for adding this.
mlir/lib/Dialect/Affine/IR/AffineOps.cpp | ||
---|---|---|
1746–1748 | That is a great observation and this is wrong for the scf::ForOp, as well. In both cases (so independent of index value) the loop might branch into the body or return to the parent. We could be clever here and if the loop is known to have at least one trip, omit the immediate return to the body. IIRC there is some helper to reason about trip counts. |
You can do DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorEntryOperands"]> in the declaration to request declarations to be emitted for additional interface methods.