@@ -1004,6 +1004,27 @@ func.func @vector_load(%arg0 : memref<4xf32, #spirv.storage_class<StorageBuffer>
1004
1004
return %0: vector <4 xf32 >
1005
1005
}
1006
1006
1007
+
1008
+ // CHECK-LABEL: @vector_load_single_elem
1009
+ // CHECK-SAME: (%[[ARG0:.*]]: memref<4xf32, #spirv.storage_class<StorageBuffer>>)
1010
+ // CHECK: %[[S0:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] : memref<4xf32, #spirv.storage_class<StorageBuffer>> to !spirv.ptr<!spirv.struct<(!spirv.array<4 x f32, stride=4> [0])>, StorageBuffer>
1011
+ // CHECK: %[[C0:.+]] = arith.constant 0 : index
1012
+ // CHECK: %[[S1:.+]] = builtin.unrealized_conversion_cast %[[C0]] : index to i32
1013
+ // CHECK: %[[CST1:.+]] = spirv.Constant 0 : i32
1014
+ // CHECK: %[[CST2:.+]] = spirv.Constant 0 : i32
1015
+ // CHECK: %[[CST3:.+]] = spirv.Constant 1 : i32
1016
+ // CHECK: %[[S4:.+]] = spirv.AccessChain %[[S0]][%[[CST1]], %[[S1]]] : !spirv.ptr<!spirv.struct<(!spirv.array<4 x f32, stride=4> [0])>, StorageBuffer>, i32, i32
1017
+ // CHECK: %[[S5:.+]] = spirv.Load "StorageBuffer" %[[S4]] : f32
1018
+ // CHECK: %[[R0:.+]] = builtin.unrealized_conversion_cast %[[S5]] : f32 to vector<1xf32>
1019
+ // CHECK: return %[[R0]] : vector<1xf32>
1020
+ func.func @vector_load_single_elem (%arg0 : memref <4 xf32 , #spirv.storage_class <StorageBuffer >>) -> vector <1 xf32 > {
1021
+ %idx = arith.constant 0 : index
1022
+ %cst_0 = arith.constant 0.000000e+00 : f32
1023
+ %0 = vector.load %arg0 [%idx ] : memref <4 xf32 , #spirv.storage_class <StorageBuffer >>, vector <1 xf32 >
1024
+ return %0: vector <1 xf32 >
1025
+ }
1026
+
1027
+
1007
1028
// CHECK-LABEL: @vector_load_2d
1008
1029
// CHECK-SAME: (%[[ARG0:.*]]: memref<4x4xf32, #spirv.storage_class<StorageBuffer>>) -> vector<4xf32> {
1009
1030
// CHECK: %[[S0:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] : memref<4x4xf32, #spirv.storage_class<StorageBuffer>> to !spirv.ptr<!spirv.struct<(!spirv.array<16 x f32, stride=4> [0])>, StorageBuffer>
@@ -1046,6 +1067,24 @@ func.func @vector_store(%arg0 : memref<4xf32, #spirv.storage_class<StorageBuffer
1046
1067
return
1047
1068
}
1048
1069
1070
+ // CHECK-LABEL: @vector_store_single_elem
1071
+ // CHECK-SAME: (%[[ARG0:.*]]: memref<4xf32, #spirv.storage_class<StorageBuffer>>
1072
+ // CHECK-SAME: %[[ARG1:.*]]: vector<1xf32>
1073
+ // CHECK: %[[S0:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] : memref<4xf32, #spirv.storage_class<StorageBuffer>> to !spirv.ptr<!spirv.struct<(!spirv.array<4 x f32, stride=4> [0])>, StorageBuffer>
1074
+ // CHECK: %[[S1:.+]] = builtin.unrealized_conversion_cast %[[ARG1]] : vector<1xf32> to f32
1075
+ // CHECK: %[[C0:.+]] = arith.constant 0 : index
1076
+ // CHECK: %[[S2:.+]] = builtin.unrealized_conversion_cast %[[C0]] : index to i32
1077
+ // CHECK: %[[CST1:.+]] = spirv.Constant 0 : i32
1078
+ // CHECK: %[[CST2:.+]] = spirv.Constant 0 : i32
1079
+ // CHECK: %[[CST3:.+]] = spirv.Constant 1 : i32
1080
+ // CHECK: %[[S4:.+]] = spirv.AccessChain %[[S0]][%[[CST1]], %[[S2]]] : !spirv.ptr<!spirv.struct<(!spirv.array<4 x f32, stride=4> [0])>, StorageBuffer>, i32, i32 -> !spirv.ptr<f32, StorageBuffer>
1081
+ // CHECK: spirv.Store "StorageBuffer" %[[S4]], %[[S1]] : f32
1082
+ func.func @vector_store_single_elem (%arg0 : memref <4 xf32 , #spirv.storage_class <StorageBuffer >>, %arg1 : vector <1 xf32 >) {
1083
+ %idx = arith.constant 0 : index
1084
+ vector.store %arg1 , %arg0 [%idx ] : memref <4 xf32 , #spirv.storage_class <StorageBuffer >>, vector <1 xf32 >
1085
+ return
1086
+ }
1087
+
1049
1088
// CHECK-LABEL: @vector_store_2d
1050
1089
// CHECK-SAME: (%[[ARG0:.*]]: memref<4x4xf32, #spirv.storage_class<StorageBuffer>>
1051
1090
// CHECK-SAME: %[[ARG1:.*]]: vector<4xf32>
0 commit comments