diff options
| author | Yong He <yonghe@outlook.com> | 2023-06-29 17:38:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-29 17:38:46 -0700 |
| commit | 8f269e5fd63e06323b933e958017301b7115b924 (patch) | |
| tree | c08291b6a648d7428f35bcf79f761562efd13b3e /source | |
| parent | 47d0e8abe4f2fe3c2eede35079676210d1db0b1a (diff) | |
Apply SCCP on global scope before unrolling loops. (#2952)
* Apply SCCP on global scope before unrolling loops.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit.cpp | 3 | ||||
| -rw-r--r-- | source/slang/slang-ir-loop-unroll.cpp | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index b34483cf2..bd6542e2a 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -399,6 +399,9 @@ Result linkAndOptimizeIR( // Unroll loops. if (codeGenContext->getSink()->getErrorCount() == 0) { + applySparseConditionalConstantPropagationForGlobalScope( + irModule, codeGenContext->getSink()); + if (!unrollLoopsInModule(irModule, codeGenContext->getSink())) return SLANG_FAIL; } diff --git a/source/slang/slang-ir-loop-unroll.cpp b/source/slang/slang-ir-loop-unroll.cpp index a05700277..05e829827 100644 --- a/source/slang/slang-ir-loop-unroll.cpp +++ b/source/slang/slang-ir-loop-unroll.cpp @@ -88,7 +88,7 @@ List<IRBlock*> collectBlocksInLoop(IRGlobalValueWithCode* func, IRLoop* loopIns static int _getLoopMaxIterationsToUnroll(IRLoop* loopInst) { - static constexpr int kMaxIterationsToAttempt = 256; + static constexpr int kMaxIterationsToAttempt = 4096; auto forceUnrollDecor = loopInst->findDecoration<IRForceUnrollDecoration>(); if (!forceUnrollDecor) @@ -99,7 +99,7 @@ static int _getLoopMaxIterationsToUnroll(IRLoop* loopInst) if (maxIterCount && maxIterCount->getValue() != 0) { maxIterations = - Math::Clamp(maxIterations, (int)maxIterCount->getValue() + 1, kMaxIterationsToAttempt); + Math::Min((int)maxIterCount->getValue() + 1, kMaxIterationsToAttempt); } return maxIterations; } |
