summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-loop-unroll.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-12-15 17:05:32 -0800
committerGitHub <noreply@github.com>2023-12-15 17:05:32 -0800
commitb507d881ca47135bfa46237767e7183f61e7d8e3 (patch)
tree3bbe4652a6972d940fd4df92a113b760c3a9e115 /source/slang/slang-ir-loop-unroll.cpp
parentf8b3027d0be0b890152a6a649822741cd3a3b6b6 (diff)
Add ConstBufferPointer::subscript. (#3415)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-loop-unroll.cpp')
-rw-r--r--source/slang/slang-ir-loop-unroll.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/slang/slang-ir-loop-unroll.cpp b/source/slang/slang-ir-loop-unroll.cpp
index 31715e7b1..d998f5e61 100644
--- a/source/slang/slang-ir-loop-unroll.cpp
+++ b/source/slang/slang-ir-loop-unroll.cpp
@@ -67,6 +67,7 @@ static int _getLoopMaxIterationsToUnroll(IRLoop* loopInst)
}
static void _foldAndSimplifyLoopIteration(
+ TargetRequest* targetRequest,
IRBuilder& builder,
List<IRBlock*>& clonedBlocks,
IRBlock* firstIterationBreakBlock,
@@ -80,7 +81,7 @@ static void _foldAndSimplifyLoopIteration(
{
for (auto inst : b->getChildren())
{
- tryReplaceInstUsesWithSimplifiedValue(builder.getModule(), inst);
+ tryReplaceInstUsesWithSimplifiedValue(targetRequest, builder.getModule(), inst);
}
}
@@ -88,7 +89,7 @@ static void _foldAndSimplifyLoopIteration(
// the phi arguments for next iteration evaluated (args in the new loop inst).
for (auto inst : firstIterationBreakBlock->getChildren())
{
- tryReplaceInstUsesWithSimplifiedValue(builder.getModule(), inst);
+ tryReplaceInstUsesWithSimplifiedValue(targetRequest, builder.getModule(), inst);
}
// Fold conditional branches into unconditional branches if the condition is known.
@@ -147,6 +148,7 @@ static void _foldAndSimplifyLoopIteration(
// Returns true if we can statically determine that the loop terminated within the iteration limit.
// This operation assumes the loop does not have `continue` jumps, i.e. continueBlock == targetBlock.
static bool _unrollLoop(
+ TargetRequest* targetRequest,
IRModule* module,
IRLoop* loopInst,
List<IRBlock*>& blocks)
@@ -339,7 +341,7 @@ static bool _unrollLoop(
// conditional jumps can be folded into unconditional jumps.
_foldAndSimplifyLoopIteration(
- builder, clonedBlocks, firstIterationBreakBlock, unreachableBlock);
+ targetRequest, builder, clonedBlocks, firstIterationBreakBlock, unreachableBlock);
// Now we have peeled off one iteration from the loop, we check if there are any
// branches into next iteration, if not, the loop terminates and we are done.
@@ -433,6 +435,7 @@ List<IRLoop*> collectLoopsInFunc(IRGlobalValueWithCode* func, const TFunc& filte
}
bool unrollLoopsInFunc(
+ TargetRequest* targetRequest,
IRModule* module,
IRGlobalValueWithCode* func,
DiagnosticSink* sink)
@@ -450,7 +453,7 @@ bool unrollLoopsInFunc(
auto blocks = collectBlocksInRegion(func, loop);
auto loopLoc = loop->sourceLoc;
- if (!_unrollLoop(module, loop, blocks))
+ if (!_unrollLoop(targetRequest, module, loop, blocks))
{
if (sink)
sink->diagnose(loopLoc, Diagnostics::cannotUnrollLoop);
@@ -465,7 +468,7 @@ bool unrollLoopsInFunc(
return true;
}
-bool unrollLoopsInModule(IRModule* module, DiagnosticSink* sink)
+bool unrollLoopsInModule(TargetRequest* targetRequest, IRModule* module, DiagnosticSink* sink)
{
SLANG_PROFILE;
@@ -476,7 +479,7 @@ bool unrollLoopsInModule(IRModule* module, DiagnosticSink* sink)
if (auto func = as<IRGlobalValueWithCode>(inst))
{
- bool result = unrollLoopsInFunc(module, func, sink);
+ bool result = unrollLoopsInFunc(targetRequest, module, func, sink);
if (!result)
return false;
}