Skip to content

Commit 4f47c98

Browse files
Groverksslegrosbuffle
authored andcommitted
[mlir][memref] Fix offset update in emulating narrow type for strided memref (llvm#67714)
The offset when converting type in emulating narrow types did not account for the offset in strided memrefs. This patch fixes this.
1 parent e905fbe commit 4f47c98

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ void memref::populateMemRefNarrowTypeEmulationConversions(
272272

273273
StridedLayoutAttr layoutAttr;
274274
if (offset != 0) {
275+
// Check if the number of bytes are a multiple of the loadStoreWidth
276+
// and if so, divide it by the loadStoreWidth to get the offset.
277+
if ((offset * width) % loadStoreWidth != 0)
278+
return std::nullopt;
279+
offset = (offset * width) / loadStoreWidth;
280+
275281
layoutAttr = StridedLayoutAttr::get(ty.getContext(), offset,
276282
ArrayRef<int64_t>{1});
277283
}

0 commit comments

Comments
 (0)