Skip to content

Commit 2c3ba9f

Browse files
authored
[mlir][Linalg] Unrestrict redundant transfer hoisting from func.func (#79516)
All the hoistRedundantVectorTransfers op does is walk the target operation, which does not have to be restricted to func.func.
1 parent d0f4663 commit 2c3ba9f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

mlir/include/mlir/Dialect/Linalg/Transforms/Hoisting.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
#define MLIR_DIALECT_LINALG_TRANSFORMS_HOISTING_H_
1111

1212
namespace mlir {
13+
class Operation;
1314
class RewriterBase;
14-
namespace func {
15-
class FuncOp;
16-
} // namespace func
1715
namespace scf {
1816
class ForOp;
1917
} // namespace scf
@@ -43,7 +41,7 @@ namespace linalg {
4341
///
4442
/// WARNING: This hoisting does not model parallelism and is generally incorrect
4543
/// when used on distributed loops with memref semantics!
46-
void hoistRedundantVectorTransfers(func::FuncOp func);
44+
void hoistRedundantVectorTransfers(Operation *root);
4745

4846
} // namespace linalg
4947
} // namespace mlir

mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ static bool noAliasingUseInLoop(vector::TransferReadOp transferRead,
7373
return true;
7474
}
7575

76-
void mlir::linalg::hoistRedundantVectorTransfers(func::FuncOp func) {
76+
void mlir::linalg::hoistRedundantVectorTransfers(Operation *root) {
7777
bool changed = true;
7878
while (changed) {
7979
changed = false;
8080
// First move loop invariant ops outside of their loop. This needs to be
8181
// done before as we cannot move ops without interrupting the function walk.
82-
func.walk(
82+
root->walk(
8383
[&](LoopLikeOpInterface loopLike) { moveLoopInvariantCode(loopLike); });
8484

85-
func.walk([&](vector::TransferReadOp transferRead) {
85+
root->walk([&](vector::TransferReadOp transferRead) {
8686
if (!isa<MemRefType>(transferRead.getShapedType()))
8787
return WalkResult::advance();
8888

0 commit comments

Comments
 (0)