summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-loop-unroll.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-loop-unroll.cpp')
-rw-r--r--source/slang/slang-ir-loop-unroll.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-ir-loop-unroll.cpp b/source/slang/slang-ir-loop-unroll.cpp
index 2f689ebde..4f9b8d272 100644
--- a/source/slang/slang-ir-loop-unroll.cpp
+++ b/source/slang/slang-ir-loop-unroll.cpp
@@ -603,6 +603,16 @@ void eliminateContinueBlocks(IRModule* module, IRLoop* loopInst)
builder.setInsertInto(innerBreakableRegionBreakBlock);
_moveParams(innerBreakableRegionBreakBlock, continueBlock);
builder.emitBranch(continueBlock);
+
+ // If the original loop can be executed up to N times, the new loop may be executed
+ // upto N+1 times (although most insts are skipped in the last traversal)
+ //
+ if (auto maxItersDecoration = loopInst->findDecoration<IRLoopMaxItersDecoration>())
+ {
+ auto maxIters = maxItersDecoration->getMaxIters();
+ maxItersDecoration->removeAndDeallocate();
+ builder.addLoopMaxItersDecoration(loopInst, maxIters + 1);
+ }
}
void eliminateContinueBlocksInFunc(IRModule* module, IRGlobalValueWithCode* func)