This is an archive of the discontinued LLVM Phabricator instance.

[mlir][scf] Implement BufferizableOpInterface for scf::WhileOp
ClosedPublic

Authored by springerm on May 4 2022, 8:25 AM.

Details

Summary

This follows the same implementation strategy as scf::ForOp.

This implementation works well in cases where each yielded value (from either body/condition region) is equivalent to the corresponding bbArg of the parent block. In that case, each OpResult of the loop may be aliasing with the corresponding OpOperand of the loop (and with no other OpOperand).

In the absence of said equivalence relationship, new buffer copies must be inserted, so that the aliasing OpOperand/OpResult contract of scf::WhileOp is honored. In essence, by yielding a newly allocated buffer, we can enforce the specified may-alias relationship. (Newly allocated buffers cannot alias with any OpOperands of the loop.)

Depends On D124934

Diff Detail

Event Timeline

springerm created this revision.May 4 2022, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 8:25 AM
springerm requested review of this revision.May 4 2022, 8:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 8:25 AM
bkramer accepted this revision.May 5 2022, 11:47 AM

Not an expert on this, but looks fine to me.

mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
700
This revision is now accepted and ready to land.May 5 2022, 11:47 AM
This revision was automatically updated to reflect the committed changes.
springerm marked an inline comment as done.