diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-08-14 03:23:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-14 00:23:32 -0700 |
| commit | 0403e0556b470f6b316153caea2dc6f5c314da5b (patch) | |
| tree | 1271dbddc28a6fccaa680dd3a6dc68fadcf45115 /source/slang/slang-ir-simplify-cfg.cpp | |
| parent | e689d5ee8e9724fee018aa14be24f9679ec5c851 (diff) | |
Fix issue with nested loop unrolling (#3100)
* Do not eliminate single-iter-loops that have inner loops using their break label.
* Add test
* Delete out-old.hlsl
* Update slang-ir-autodiff-cfg-norm.cpp
* Fix whitespace
Diffstat (limited to 'source/slang/slang-ir-simplify-cfg.cpp')
| -rw-r--r-- | source/slang/slang-ir-simplify-cfg.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/slang-ir-simplify-cfg.cpp b/source/slang/slang-ir-simplify-cfg.cpp index c4c5b584e..f2d0c4555 100644 --- a/source/slang/slang-ir-simplify-cfg.cpp +++ b/source/slang/slang-ir-simplify-cfg.cpp @@ -94,6 +94,29 @@ static bool isTrivialSingleIterationLoop( } } } + + // We'll also check if there's an inner loop that is breaking out into this loop's break block. + // If so, we cannot remove it right away since it interferes with the multi-level break elimination + // logic. + // + // Track the break block backwards through the dominator tree, and see if we find a loop block + // that is not the current loop. + // + auto currBlock = loop->getBreakBlock(); + for (;;) + { + auto parent = context.domTree->getImmediateDominator(currBlock); + if (!parent) + break; + currBlock = parent; + if (auto _loop = as<IRLoop>(currBlock->getTerminator())) + { + if (loop != _loop) + return false; + if (loop == _loop) + break; + } + } return true; } |
