[mlir][sparse] hoists alloca outside the outermost loop. (#70085)

This commit is contained in:
Peiming Liu
2023-10-24 11:22:50 -07:00
committed by GitHub
parent f418319730
commit 43961264c8

View File

@@ -592,8 +592,12 @@ public:
Value lvlCoords, vref;
{
OpBuilder::InsertionGuard guard(rewriter);
auto loop = op->getParentOfType<LoopLikeOpInterface>();
if (loop) {
Operation *loop = op;
// Finds the outermost loop.
while (auto l = loop->getParentOfType<LoopLikeOpInterface>())
loop = l;
if (llvm::isa<LoopLikeOpInterface>(loop)) {
// Hoists alloca outside the loop to avoid stack overflow.
rewriter.setInsertionPoint(loop);
}