summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-simplify-cfg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-simplify-cfg.cpp')
-rw-r--r--source/slang/slang-ir-simplify-cfg.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang/slang-ir-simplify-cfg.cpp b/source/slang/slang-ir-simplify-cfg.cpp
index af0e7c0ce..db0274d32 100644
--- a/source/slang/slang-ir-simplify-cfg.cpp
+++ b/source/slang/slang-ir-simplify-cfg.cpp
@@ -6,7 +6,7 @@
namespace Slang
{
-bool processFunc(IRFunc* func)
+bool processFunc(IRGlobalValueWithCode* func)
{
auto firstBlock = func->getFirstBlock();
if (!firstBlock)
@@ -23,6 +23,15 @@ bool processFunc(IRFunc* func)
workList.fastRemoveAt(0);
while (block)
{
+ if (auto loop = as<IRLoop>(block->getTerminator()))
+ {
+ auto continueBlock = loop->getContinueBlock();
+ if (continueBlock && !continueBlock->hasMoreThanOneUse())
+ {
+ loop->continueBlock.set(loop->getTargetBlock());
+ continueBlock->removeAndDeallocate();
+ }
+ }
// If `block` does not end with an unconditional branch, bail.
if (block->getTerminator()->getOp() != kIROp_unconditionalBranch)
break;
@@ -33,6 +42,8 @@ bool processFunc(IRFunc* func)
// merge point in CFG. Such blocks will have more than one use.
if (successor->hasMoreThanOneUse())
break;
+ if (block->hasMoreThanOneUse())
+ break;
changed = true;
Index paramIndex = 0;
auto inst = successor->getFirstDecorationOrChild();
@@ -79,4 +90,9 @@ bool simplifyCFG(IRModule* module)
return changed;
}
+bool simplifyCFG(IRGlobalValueWithCode* func)
+{
+ return processFunc(func);
+}
+
} // namespace Slang