Skip to content

Commit 4396126

Browse files
authored
[mlir][sparse] hoists alloca outside the outermost loop. (#70085)
1 parent f418319 commit 4396126

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,12 @@ class SparseTensorInsertConverter : public OpConversionPattern<InsertOp> {
592592
Value lvlCoords, vref;
593593
{
594594
OpBuilder::InsertionGuard guard(rewriter);
595-
auto loop = op->getParentOfType<LoopLikeOpInterface>();
596-
if (loop) {
595+
Operation *loop = op;
596+
// Finds the outermost loop.
597+
while (auto l = loop->getParentOfType<LoopLikeOpInterface>())
598+
loop = l;
599+
600+
if (llvm::isa<LoopLikeOpInterface>(loop)) {
597601
// Hoists alloca outside the loop to avoid stack overflow.
598602
rewriter.setInsertionPoint(loop);
599603
}

0 commit comments

Comments
 (0)