[Mlir-commits] [mlir] 3971e80 - Add additional criteria for hoisting vector.transfer_reads
Harsh Menon
llvmlistbot at llvm.org
Fri May 12 11:56:54 PDT 2023
Author: Harsh Menon
Date: 2023-05-12T11:56:19-07:00
New Revision: 3971e80fc53928558604033330b18fa297191005
URL: https://github.com/llvm/llvm-project/commit/3971e80fc53928558604033330b18fa297191005
DIFF: https://github.com/llvm/llvm-project/commit/3971e80fc53928558604033330b18fa297191005.diff
LOG: 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
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
mlir/test/Dialect/Linalg/hoisting.mlir
Removed:
################################################################################
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
}
More information about the Mlir-commits
mailing list