Skip to content

Commit

Permalink
add test: unused memory space cast
Browse files Browse the repository at this point in the history
  • Loading branch information
jorendumoulin committed Nov 20, 2023
1 parent f66b7e7 commit d73ea53
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/filecheck/transforms/set-memory-space.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,39 @@
//CHECK-NEXT: "func.return"() : () -> ()
//CHECK-NEXT: }) : () -> ()
//CHECK-NEXT: }) : () -> ()

// -----

// ignore unused memory_space_cast

"builtin.module"() ({
"func.func"() <{function_type = (memref<64xi32>, memref<64xi32>, memref<64xi32>) -> (), sym_name = "simple_mult", sym_visibility = "public"}> ({
^bb0(%arg0: memref<64xi32>, %arg1: memref<64xi32>, %arg2: memref<64xi32>):
"memref.memory_space_cast"(%arg0) : (memref<64xi32>) -> memref<64xi32, 5 : i32>
"linalg.generic"(%arg0, %arg1, %arg2) <{indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = [#linalg.iterator_type<parallel>], operandSegmentSizes = array<i32: 2, 1>}> ({
^bb0(%arg3: i32, %arg4: i32, %arg5: i32):
%0 = "arith.muli"(%arg3, %arg4) : (i32, i32) -> i32
"linalg.yield"(%0) : (i32) -> ()
}) : (memref<64xi32>, memref<64xi32>, memref<64xi32>) -> ()
"func.return"() : () -> ()
}) : () -> ()
}) : () -> ()

//CHECK: "builtin.module"() ({
//CHECK-NEXT: "func.func"() <{"sym_name" = "simple_mult", "function_type" = (memref<64xi32, 0 : i32>, memref<64xi32, 0 : i32>, memref<64xi32, 0 : i32>) -> (), "sym_visibility" = "public"}> ({
//CHECK-NEXT: ^0(%arg0 : memref<64xi32, 0 : i32>, %arg1 : memref<64xi32, 0 : i32>, %arg2 : memref<64xi32, 0 : i32>):
//CHECK-NEXT: %0 = "memref.memory_space_cast"(%arg0) : (memref<64xi32, 0 : i32>) -> memref<64xi32, 5 : i32>
//CHECK-NEXT: %1 = "memref.alloc"() <{"operandSegmentSizes" = array<i32: 0, 0>}> {"alignment" = 64 : i64} : () -> memref<64xi32, 1 : i32>
//CHECK-NEXT: %2 = "memref.alloc"() <{"operandSegmentSizes" = array<i32: 0, 0>}> {"alignment" = 64 : i64} : () -> memref<64xi32, 1 : i32>
//CHECK-NEXT: %3 = "memref.alloc"() <{"operandSegmentSizes" = array<i32: 0, 0>}> {"alignment" = 64 : i64} : () -> memref<64xi32, 1 : i32>
//CHECK-NEXT: "memref.copy"(%arg0, %1) : (memref<64xi32, 0 : i32>, memref<64xi32, 1 : i32>) -> ()
//CHECK-NEXT: "memref.copy"(%arg1, %2) : (memref<64xi32, 0 : i32>, memref<64xi32, 1 : i32>) -> ()
//CHECK-NEXT: "linalg.generic"(%1, %2, %3) <{"indexing_maps" = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], "iterator_types" = [#linalg.iterator_type<parallel>], "operandSegmentSizes" = array<i32: 2, 1>}> ({
//CHECK-NEXT: ^1(%arg3 : i32, %arg4 : i32, %arg5 : i32):
//CHECK-NEXT: %4 = "arith.muli"(%arg3, %arg4) : (i32, i32) -> i32
//CHECK-NEXT: "linalg.yield"(%4) : (i32) -> ()
//CHECK-NEXT: }) : (memref<64xi32, 1 : i32>, memref<64xi32, 1 : i32>, memref<64xi32, 1 : i32>) -> ()
//CHECK-NEXT: "memref.copy"(%3, %arg2) : (memref<64xi32, 1 : i32>, memref<64xi32, 0 : i32>) -> ()
//CHECK-NEXT: "func.return"() : () -> ()
//CHECK-NEXT: }) : () -> ()
//CHECK-NEXT: }) : () -> ()

0 comments on commit d73ea53

Please sign in to comment.