Skip to content

Commit

Permalink
Add tests for larger memref and vector
Browse files Browse the repository at this point in the history
  • Loading branch information
angelz913 committed Aug 9, 2024
1 parent 1c645ee commit 25416d5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions mlir/test/Conversion/ConvertToSPIRV/memref.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,33 @@ func.func @load_store_int_rank_one(%arg0: memref<4xi32>, %arg1: memref<4xi32>, %
return
}

// CHECK-LABEL: @load_store_larger_memref
// CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<8 x i32, stride=4> [0])>, StorageBuffer>, %[[ARG1:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<8 x i32, stride=4> [0])>, StorageBuffer>, %[[ARG2:.*]]: i32
// CHECK: %[[CST0:.*]] = spirv.Constant 0 : i32
// CHECK: %[[AC0:.*]] = spirv.AccessChain %[[ARG0]][%[[CST0]], %[[ARG2]]] : !spirv.ptr<!spirv.struct<(!spirv.array<8 x i32, stride=4> [0])>, StorageBuffer>, i32, i32
// CHECK: %[[LOAD:.*]] = spirv.Load "StorageBuffer" %[[AC0]] : i32
// CHECK: %[[AC1:.*]] = spirv.AccessChain %[[ARG1]][%[[CST0]], %[[ARG2]]] : !spirv.ptr<!spirv.struct<(!spirv.array<8 x i32, stride=4> [0])>, StorageBuffer>, i32, i32
// CHECK: spirv.Store "StorageBuffer" %[[AC1]], %[[LOAD]] : i32
// CHECK: spirv.Return
func.func @load_store_larger_memref(%arg0: memref<8xi32>, %arg1: memref<8xi32>, %arg2 : index) {
%0 = memref.load %arg0[%arg2] : memref<8xi32>
memref.store %0, %arg1[%arg2] : memref<8xi32>
return
}


// CHECK-LABEL: @load_store_vector
// CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<1 x vector<4xi32>, stride=16> [0])>, StorageBuffer>, %[[ARG1:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<1 x vector<4xi32>, stride=16> [0])>, StorageBuffer>
// CHECK: %[[CST0:.*]] = spirv.Constant 0 : i32
// CHECK: %[[AC0:.*]] = spirv.AccessChain %[[ARG0]][%[[CST0]], %[[CST0]]] : !spirv.ptr<!spirv.struct<(!spirv.array<1 x vector<4xi32>, stride=16> [0])>, StorageBuffer>, i32, i32
// CHECK: %[[LOAD:.*]] = spirv.Load "StorageBuffer" %[[AC0]] : vector<4xi32>
// CHECK: %[[AC1:.*]] = spirv.AccessChain %[[ARG1]][%[[CST0]], %[[CST0]]] : !spirv.ptr<!spirv.struct<(!spirv.array<1 x vector<4xi32>, stride=16> [0])>, StorageBuffer>, i32, i32
// CHECK: spirv.Store "StorageBuffer" %[[AC1]], %[[LOAD]] : vector<4xi32>
// CHECK: spirv.Return
func.func @load_store_vector(%arg0: memref<vector<4xi32>>, %arg1: memref<vector<4xi32>>) {
%0 = memref.load %arg0[] : memref<vector<4xi32>>
memref.store %0, %arg1[] : memref<vector<4xi32>>
return
}

} // end module

0 comments on commit 25416d5

Please sign in to comment.