This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Code motion always-executed ops outside an execute-region
Needs ReviewPublic

Authored by wsmoses on Jan 6 2022, 3:03 PM.

Details

Summary

Execute regions permit operations which contain only one block to contain multiple blocks. Any instruction prior to a conditional branch is always executed and thus can be moved outside the region

Diff Detail

Event Timeline

wsmoses created this revision.Jan 6 2022, 3:03 PM
wsmoses requested review of this revision.Jan 6 2022, 3:03 PM
rriddle added inline comments.Jan 6 2022, 3:05 PM
mlir/lib/Dialect/SCF/SCF.cpp
256

Movement is not supported as a root update,

wsmoses added inline comments.Jan 6 2022, 3:07 PM
mlir/lib/Dialect/SCF/SCF.cpp
256

What would the appropriate mechanism be?

rriddle added inline comments.Jan 6 2022, 3:14 PM
mlir/lib/Dialect/SCF/SCF.cpp
256

"Root updates" support touching the operation itself, not any kind of nested operations/control flow/etc. I don't think we have any API that supports tracking individual operation movements, just at the block/region level. I suppose conceptually, we could naively split the block around the operation and then merge that block into the desired block location. That would avoid the need to touch the exposed rewriter API. We could also add API specifically for per-operation movement, but we'll need to add support to dialect conversion for tracking/undoing that. (Maybe an easy first step would be adding the desired API, but naively using the existing block related API underneath. We could optimize with a better implementation later).