Skip to content

Commit c75f899

Browse files
committed
update comments
1 parent f2d5e8b commit c75f899

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,19 @@ static void atomicStore(OpBuilder &builder, Location loc,
364364
}
365365

366366
/// Generate a non-atomic read-modify-write sequence for subbyte storing.
367-
/// It has similar logic to `atomicStore`, but without the atomicity.
367+
/// It has similar logic to `atomicStore`, but without atomicity.
368368
static void rmwStore(OpBuilder &builder, Location loc,
369369
MemRefValue linearizedMemref, Value linearizedIndex,
370370
VectorValue valueToStore, Value mask) {
371371
assert(valueToStore.getType().getRank() == 1 && "expected 1-D vector");
372372

373-
// Load the original value from memory, and cast it to the original element
374-
// type.
375373
auto oneElemVecType =
376374
VectorType::get({1}, linearizedMemref.getType().getElementType());
377375
Value origVecValue = builder.create<vector::LoadOp>(
378376
loc, oneElemVecType, linearizedMemref, ValueRange{linearizedIndex});
379377
origVecValue = builder.create<vector::BitCastOp>(loc, valueToStore.getType(),
380378
origVecValue);
381379

382-
// Construct the final masked value and yield it.
383380
Value maskedValue =
384381
downcastSelectAndUpcast(builder, loc, valueToStore.getType(),
385382
oneElemVecType, mask, valueToStore, origVecValue);

mlir/test/Dialect/Vector/vector-emulate-narrow-type-unaligned-non-atomic.mlir

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
// memref.alloc exists here because sub-byte vector data types such as i2
55
// are currently not supported as input arguments.
66

7-
func.func @vector_store_i2_const_index_two_rmw(%arg0: vector<3xi2>) {
7+
func.func @vector_store_i2_const_index_two_partial_stores(%arg0: vector<3xi2>) {
88
%0 = memref.alloc() : memref<3x3xi2>
99
%c0 = arith.constant 0 : index
1010
%c2 = arith.constant 2 : index
1111
vector.store %arg0, %0[%c2, %c0] :memref<3x3xi2>, vector<3xi2>
1212
return
1313
}
14-
// Load from bit [12:18), byte [1:2] of total 3 bytes, both bytes needs rmw.
14+
// In this example, emit two RMW stores without full-width store.
15+
// Store bit [12:18), byte [1:2] to a 3-byte vector, both bytes are
16+
// accessed partially.
1517

16-
// CHECK: func @vector_store_i2_const_index_two_rmw(
18+
// CHECK: func @vector_store_i2_const_index_two_partial_stores(
1719
// CHECK-SAME: %[[ARG0:.+]]: vector<3xi2>)
1820
// CHECK: %[[ALLOC:.+]] = memref.alloc() : memref<3xi8>
1921
// CHECK: %[[C1:.+]] = arith.constant 1 : index
@@ -47,15 +49,17 @@ func.func @vector_store_i2_const_index_two_rmw(%arg0: vector<3xi2>) {
4749

4850
// -----
4951

50-
func.func @vector_store_i2_rmw(%arg0: vector<7xi2>) {
52+
func.func @vector_store_i2_two_partial_one_full_stores(%arg0: vector<7xi2>) {
5153
%0 = memref.alloc() : memref<3x7xi2>
5254
%c0 = arith.constant 0 : index
5355
%c1 = arith.constant 1 : index
5456
vector.store %arg0, %0[%c1, %c0] :memref<3x7xi2>, vector<7xi2>
5557
return
5658
}
5759

58-
// CHECK: func @vector_store_i2_rmw(
60+
// In this example, emit two RMW stores and one full-width store.
61+
62+
// CHECK: func @vector_store_i2_two_partial_one_full_stores(
5963
// CHECK-SAME: %[[ARG0:.+]]:
6064
// CHECK: %[[ALLOC:.+]] = memref.alloc() : memref<6xi8>
6165
// CHECK: %[[C1:.+]] = arith.constant 1 : index
@@ -94,16 +98,17 @@ func.func @vector_store_i2_rmw(%arg0: vector<7xi2>) {
9498

9599
// -----
96100

97-
func.func @vector_store_i2_single_rmw(%arg0: vector<1xi2>) {
101+
func.func @vector_store_i2_one_partial_store(%arg0: vector<1xi2>) {
98102
%0 = memref.alloc() : memref<4x1xi2>
99103
%c0 = arith.constant 0 : index
100104
%c1 = arith.constant 1 : index
101105
vector.store %arg0, %0[%c1, %c0] :memref<4x1xi2>, vector<1xi2>
102106
return
103107
}
104108

105-
// in this test, only emit 1 rmw store
106-
// CHECK: func @vector_store_i2_single_rmw(
109+
// in this test, only emit partial RMW store as the store is within one byte.
110+
111+
// CHECK: func @vector_store_i2_one_partial_store(
107112
// CHECK-SAME: %[[ARG0:.+]]: vector<1xi2>)
108113
// CHECK: %[[ALLOC:.+]] = memref.alloc() : memref<1xi8>
109114
// CHECK: %[[C0:.+]] = arith.constant 0 : index
@@ -116,4 +121,3 @@ func.func @vector_store_i2_single_rmw(%arg0: vector<1xi2>) {
116121
// CHECK: %[[SELECT:.+]] = arith.select %[[CST]], %[[INSERT]], %[[UPCAST]]
117122
// CHECK: %[[DOWNCAST:.+]] = vector.bitcast %[[SELECT]]
118123
// CHECK: vector.store %[[DOWNCAST]], %[[ALLOC]][%[[C0]]]
119-

0 commit comments

Comments
 (0)