1
+ // RUN: mlir-opt -convert-to-spirv="run-signature-conversion=false run-vector-unrolling=false" -cse -split-input-file %s | FileCheck %s
2
+
3
+ module attributes {
4
+ spirv.target_env = #spirv.target_env <
5
+ #spirv.vce <v1.0 , [Shader ], [SPV_KHR_storage_buffer_storage_class ]>, #spirv.resource_limits <>>
6
+ } {
7
+
8
+ // CHECK-LABEL: @load_store_float_rank_zero
9
+ // CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<1 x f32, stride=4> [0])>, StorageBuffer>, %[[ARG1:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<1 x f32, stride=4> [0])>, StorageBuffer>
10
+ // CHECK: %[[CST0:.*]] = spirv.Constant 0 : i32
11
+ // CHECK: %[[AC0:.*]] = spirv.AccessChain %[[ARG0]][%[[CST0]], %[[CST0]]] : !spirv.ptr<!spirv.struct<(!spirv.array<1 x f32, stride=4> [0])>, StorageBuffer>, i32, i32
12
+ // CHECK: %[[LOAD:.*]] = spirv.Load "StorageBuffer" %[[AC0]] : f32
13
+ // CHECK: %[[AC1:.*]] = spirv.AccessChain %[[ARG1]][%[[CST0]], %[[CST0]]] : !spirv.ptr<!spirv.struct<(!spirv.array<1 x f32, stride=4> [0])>, StorageBuffer>, i32, i32
14
+ // CHECK: spirv.Store "StorageBuffer" %[[AC1]], %[[LOAD]] : f32
15
+ // CHECK: spirv.Return
16
+ func.func @load_store_float_rank_zero (%arg0: memref <f32 >, %arg1: memref <f32 >) {
17
+ %0 = memref.load %arg0 [] : memref <f32 >
18
+ memref.store %0 , %arg1 [] : memref <f32 >
19
+ return
20
+ }
21
+
22
+ // CHECK-LABEL: @load_store_int_rank_one
23
+ // CHECK-SAME: %[[ARG0:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<4 x i32, stride=4> [0])>, StorageBuffer>, %[[ARG1:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<4 x i32, stride=4> [0])>, StorageBuffer>, %[[ARG2:.*]]: i32
24
+ // CHECK: %[[CST0:.*]] = spirv.Constant 0 : i32
25
+ // CHECK: %[[AC0:.*]] = spirv.AccessChain %[[ARG0]][%[[CST0]], %[[ARG2]]] : !spirv.ptr<!spirv.struct<(!spirv.array<4 x i32, stride=4> [0])>, StorageBuffer>, i32, i32
26
+ // CHECK: %[[LOAD:.*]] = spirv.Load "StorageBuffer" %[[AC0]] : i32
27
+ // CHECK: %[[AC1:.*]] = spirv.AccessChain %[[ARG1]][%[[CST0]], %[[ARG2]]] : !spirv.ptr<!spirv.struct<(!spirv.array<4 x i32, stride=4> [0])>, StorageBuffer>, i32, i32
28
+ // CHECK: spirv.Store "StorageBuffer" %[[AC1]], %[[LOAD]] : i32
29
+ // CHECK: spirv.Return
30
+ func.func @load_store_int_rank_one (%arg0: memref <4 xi32 >, %arg1: memref <4 xi32 >, %arg2 : index ) {
31
+ %0 = memref.load %arg0 [%arg2 ] : memref <4 xi32 >
32
+ memref.store %0 , %arg1 [%arg2 ] : memref <4 xi32 >
33
+ return
34
+ }
35
+
36
+ } // end module
0 commit comments