Skip to content

Commit a7b968a

Browse files
Adding memref normalization of affine.prefetch (#89675)
Added support for memref-normalization for prefetch. Signed-off-by: Alexandre Eichenberger <[email protected]>
1 parent 8d28e58 commit a7b968a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

mlir/include/mlir/Dialect/Affine/IR/AffineOps.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ def AffineParallelOp : Affine_Op<"parallel",
742742
}
743743

744744
def AffinePrefetchOp : Affine_Op<"prefetch",
745-
[DeclareOpInterfaceMethods<AffineMapAccessInterface>]> {
745+
[DeclareOpInterfaceMethods<AffineMapAccessInterface>,
746+
MemRefsNormalizable]> {
746747
let summary = "affine prefetch operation";
747748
let description = [{
748749
The `affine.prefetch` op prefetches data from a memref location described

mlir/test/Dialect/MemRef/normalize-memrefs-ops.mlir

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,19 @@ func.func @test_norm_reinterpret_cast(%arg0 : memref<3xf32, #map_1d_tile>) -> (m
149149
// CHECK: memref.reinterpret_cast %[[v0]] to offset: [0], sizes: [3, 1, 1], strides: [1, 1, 1] : memref<3xf32> to memref<3x1x1xf32>
150150
return %1 : memref<3x1x1xf32>
151151
}
152+
153+
154+
// -----
155+
156+
// Test normalization of memrefs for prefetch.affine
157+
158+
// CHECK-LABEL: func.func @prefetch_normalize
159+
// CHECK-SAME: ([[PARAM_0_:%.+]]: memref<16x32xf32>) {
160+
func.func @prefetch_normalize(%arg0: memref<512xf32, affine_map<(d0) -> (d0 floordiv 32, d0 mod 32)>>) -> () {
161+
// CHECK: affine.for [[I_0_:%.+]] = 0 to 8 {
162+
affine.for %arg3 = 0 to 8 {
163+
// CHECK: affine.prefetch [[PARAM_0_]]{{.}}[[I_0_]] floordiv 32, [[I_0_]] mod 32], read, locality<3>, data : memref<16x32xf32>
164+
affine.prefetch %arg0[%arg3], read, locality<3>, data : memref<512xf32, affine_map<(d0) -> (d0 floordiv 32, d0 mod 32)>>
165+
}
166+
return
167+
}

0 commit comments

Comments
 (0)