Skip to content

Commit 9751e1a

Browse files
committed
address review comments
1 parent 2a1b83d commit 9751e1a

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

mlir/include/mlir/Interfaces/MemorySlotInterfaces.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ struct MemorySlot {
2626

2727
/// Memory slot attached with information about its destructuring procedure.
2828
struct DestructurableMemorySlot : public MemorySlot {
29-
/// Maps an index within the memory slot to the element type of the pointer
30-
/// that will be generated to access the element directly.
29+
/// Maps an index within the memory slot to the corresponding subelement type.
3130
DenseMap<Attribute, Type> elementPtrs;
3231
};
3332

mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ bool LLVM::StoreOp::canRewire(const DestructurableMemorySlot &slot,
251251
if (getVolatile_())
252252
return false;
253253

254-
// A load always accesses the first element of the destructured slot.
254+
// A store always accesses the first element of the destructured slot.
255255
auto index = IntegerAttr::get(IntegerType::get(getContext(), 32), 0);
256256
Type subslotType = getTypeAtIndex(slot, index);
257257
if (!subslotType)
@@ -468,9 +468,6 @@ bool LLVM::GEPOp::canRewire(const DestructurableMemorySlot &slot,
468468
// dynamic indices can never be properly rewired.
469469
if (!getDynamicIndices().empty())
470470
return false;
471-
//// TODO: This is not necessary, I think.
472-
// if (slot.elemType != getElemType())
473-
// return false;
474471
Type reachedType = getResultPtrElementType();
475472
if (!reachedType || getIndices().size() < 2)
476473
return false;

mlir/test/Dialect/LLVMIR/sroa.mlir

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ llvm.func @store_first_field(%arg: i32) {
223223
%0 = llvm.mlir.constant(1 : i32) : i32
224224
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
225225
%1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> !llvm.ptr
226-
// CHECK: llvm.store %{{.*}}, %[[ALLOCA]] : i32
226+
// CHECK-NEXT: llvm.store %{{.*}}, %[[ALLOCA]] : i32
227227
llvm.store %arg, %1 : i32, !llvm.ptr
228228
llvm.return
229229
}
@@ -236,7 +236,7 @@ llvm.func @store_first_field_different_type(%arg: f32) {
236236
%0 = llvm.mlir.constant(1 : i32) : i32
237237
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
238238
%1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> !llvm.ptr
239-
// CHECK: llvm.store %[[ARG]], %[[ALLOCA]] : f32
239+
// CHECK-NEXT: llvm.store %[[ARG]], %[[ALLOCA]] : f32
240240
llvm.store %arg, %1 : f32, !llvm.ptr
241241
llvm.return
242242
}
@@ -249,7 +249,7 @@ llvm.func @store_sub_field(%arg: f32) {
249249
%0 = llvm.mlir.constant(1 : i32) : i32
250250
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i64
251251
%1 = llvm.alloca %0 x !llvm.struct<"foo", (i64, i32)> : (i32) -> !llvm.ptr
252-
// CHECK: llvm.store %[[ARG]], %[[ALLOCA]] : f32
252+
// CHECK-NEXT: llvm.store %[[ARG]], %[[ALLOCA]] : f32
253253
llvm.store %arg, %1 : f32, !llvm.ptr
254254
llvm.return
255255
}
@@ -261,7 +261,7 @@ llvm.func @load_first_field() -> i32 {
261261
%0 = llvm.mlir.constant(1 : i32) : i32
262262
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
263263
%1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> !llvm.ptr
264-
// CHECK: %[[RES:.*]] = llvm.load %[[ALLOCA]] : !llvm.ptr -> i32
264+
// CHECK-NEXT: %[[RES:.*]] = llvm.load %[[ALLOCA]] : !llvm.ptr -> i32
265265
%2 = llvm.load %1 : !llvm.ptr -> i32
266266
// CHECK: llvm.return %[[RES]] : i32
267267
llvm.return %2 : i32
@@ -274,7 +274,7 @@ llvm.func @load_first_field_different_type() -> f32 {
274274
%0 = llvm.mlir.constant(1 : i32) : i32
275275
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i32
276276
%1 = llvm.alloca %0 x !llvm.struct<"foo", (i32, i32, i32)> : (i32) -> !llvm.ptr
277-
// CHECK: %[[RES:.*]] = llvm.load %[[ALLOCA]] : !llvm.ptr -> f32
277+
// CHECK-NEXT: %[[RES:.*]] = llvm.load %[[ALLOCA]] : !llvm.ptr -> f32
278278
%2 = llvm.load %1 : !llvm.ptr -> f32
279279
// CHECK: llvm.return %[[RES]] : f32
280280
llvm.return %2 : f32
@@ -286,9 +286,8 @@ llvm.func @load_first_field_different_type() -> f32 {
286286
llvm.func @load_sub_field() -> i32 {
287287
%0 = llvm.mlir.constant(1 : i32) : i32
288288
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x i64 : (i32) -> !llvm.ptr
289-
// CHECK-NOT: llvm.alloca
290289
%1 = llvm.alloca %0 x !llvm.struct<(i64, i32)> : (i32) -> !llvm.ptr
291-
// CHECK: %[[RES:.*]] = llvm.load %[[ALLOCA]]
290+
// CHECK-NEXT: %[[RES:.*]] = llvm.load %[[ALLOCA]]
292291
%res = llvm.load %1 : !llvm.ptr -> i32
293292
// CHECK: llvm.return %[[RES]] : i32
294293
llvm.return %res : i32
@@ -302,7 +301,7 @@ llvm.func @vector_store_type_mismatch(%arg: vector<4xi32>) {
302301
%0 = llvm.mlir.constant(1 : i32) : i32
303302
// CHECK: %[[ALLOCA:.*]] = llvm.alloca %{{.*}} x vector<4xf32>
304303
%1 = llvm.alloca %0 x !llvm.struct<"foo", (vector<4xf32>)> : (i32) -> !llvm.ptr
305-
// CHECK: llvm.store %[[ARG]], %[[ALLOCA]]
304+
// CHECK-NEXT: llvm.store %[[ARG]], %[[ALLOCA]]
306305
llvm.store %arg, %1 : vector<4xi32>, !llvm.ptr
307306
llvm.return
308307
}

0 commit comments

Comments
 (0)