diff options
Diffstat (limited to 'source/slang/slang-ir-ssa-simplification.cpp')
| -rw-r--r-- | source/slang/slang-ir-ssa-simplification.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/source/slang/slang-ir-ssa-simplification.cpp b/source/slang/slang-ir-ssa-simplification.cpp index f723325c4..4b604e03a 100644 --- a/source/slang/slang-ir-ssa-simplification.cpp +++ b/source/slang/slang-ir-ssa-simplification.cpp @@ -10,8 +10,6 @@ namespace Slang { - struct IRModule; - // Run a combination of SSA, SCCP, SimplifyCFG, and DeadCodeElimination pass // until no more changes are possible. void simplifyIR(IRModule* module) @@ -37,4 +35,27 @@ namespace Slang iterationCounter++; } } + + void simplifyFunc(IRGlobalValueWithCode* func) + { + bool changed = true; + const int kMaxIterations = 8; + int iterationCounter = 0; + while (changed && iterationCounter < kMaxIterations) + { + changed = false; + changed |= applySparseConditionalConstantPropagation(func); + changed |= peepholeOptimize(func); + changed |= simplifyCFG(func); + + // Note: we disregard the `changed` state from dead code elimination pass since + // SCCP pass could be generating temporarily evaluated constant values and never actually use them. + // DCE will always remove those nearly generated consts and always returns true here. + eliminateDeadCode(func); + + changed |= constructSSA(func); + + iterationCounter++; + } + } } |
