Add RegionBranchOpInterface on affine.for op so that transforms relying
on RegionBranchOpInterface can support affine.for. E.g.:
You can do DeclareOpInterfaceMethods<RegionBranchOpInterface, ["getSuccessorEntryOperands"]> in the declaration to request declarations to be emitted for additional interface methods.
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.
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.