Skip to content

Commit

Permalink
Extend polygeist subindex lowering to multidim memrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbopet committed Jan 29, 2022
1 parent f7afb69 commit afc0b95
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/polygeist/Passes/LowerPolygeistOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ struct SubIndexToReinterpretCast
rewriter.create<ConstantIndexOp>(op.getLoc(), innerSize));

llvm::SmallVector<OpFoldResult> sizes, strides;
for (auto dim : shape.drop_front()) {
sizes.push_back(rewriter.getIndexAttr(dim));
strides.push_back(rewriter.getIndexAttr(1));
int64_t strideAcc = 1;
for (auto dim : llvm::reverse(shape.drop_front())) {
sizes.insert(sizes.begin(), rewriter.getIndexAttr(dim));
strides.insert(strides.begin(), rewriter.getIndexAttr(strideAcc));
strideAcc *= dim;
}

rewriter.replaceOpWithNewOp<memref::ReinterpretCastOp>(
Expand Down

0 comments on commit afc0b95

Please sign in to comment.