summaryrefslogtreecommitdiff
path: root/mlir
diff options
context:
space:
mode:
authorHarsh Menon <harsh@nod-labs.com>2023-05-12 11:09:40 -0700
committerHarsh Menon <harsh@nod-labs.com>2023-05-12 11:56:19 -0700
commit3971e80fc53928558604033330b18fa297191005 (patch)
tree96e41e52d89335be3ba8a322639a731aa07169a9 /mlir
parent6d861d498de1320d22771c329ec69f9419ef06b7 (diff)
downloadllvm-3971e80fc53928558604033330b18fa297191005.tar.gz
Add additional criteria for hoisting vector.transfer_reads
Non-subview uses of an alloc outside the current loop can be safely ignored when considering hoisting vector transfer_reads. This patch adds a condition to check for that case and updates the unit test accordingly. Differential Revision: https://reviews.llvm.org/D150469
Diffstat (limited to 'mlir')
-rw-r--r--mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp2
-rw-r--r--mlir/test/Dialect/Linalg/hoisting.mlir2
2 files changed, 4 insertions, 0 deletions
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
index 01b893a0e0a5..306762b2da5b 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -71,6 +71,8 @@ static bool noAliasingUseInLoop(vector::TransferReadOp transferRead,
}
if (isMemoryEffectFree(user) || isa<vector::TransferReadOp>(user))
continue;
+ if (!loop->isAncestor(user))
+ continue;
return false;
}
return true;
diff --git a/mlir/test/Dialect/Linalg/hoisting.mlir b/mlir/test/Dialect/Linalg/hoisting.mlir
index 02b03eeacc30..546b1bb2cd75 100644
--- a/mlir/test/Dialect/Linalg/hoisting.mlir
+++ b/mlir/test/Dialect/Linalg/hoisting.mlir
@@ -696,6 +696,7 @@ transform.sequence failures(propagate) {
// CHECK: "some_use"(%[[D0]], %[[D1]], %[[CAST]]) : (vector<32x64xf32>, vector<32x128xf32>, memref<32x128xf32,
// CHECK-SAME: strided<[128, 1], offset: ?>>) -> ()
// CHECK: }
+// CHECK: memref.dealloc %[[ALLOC]] : memref<32x64xf32>
// CHECK: return
func.func @hoist_vector_transfer_read() {
%c0 = arith.constant 0 : index
@@ -710,6 +711,7 @@ func.func @hoist_vector_transfer_read() {
%3 = vector.transfer_read %memref0[%c0, %c0], %cst_2 {in_bounds = [true, true]} : memref<32x64xf32>, vector<32x64xf32>
"some_use"(%3, %2, %subview2) : (vector<32x64xf32>, vector<32x128xf32>, memref<32x128xf32, strided<[128, 1], offset: ?>>) -> ()
}
+ memref.dealloc %memref0 : memref<32x64xf32>
return
}