diff options
| author | Yong He <yonghe@outlook.com> | 2022-12-19 11:47:19 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-19 11:47:19 -0800 |
| commit | 216dfba0af66210a46ef0df18beb73d975fdf727 (patch) | |
| tree | f397ea5bf8d47d7a5d90dc95edfb472f2e49d762 /source/slang/slang-ir-ssa-simplification.cpp | |
| parent | 36220da1e29c891972fef32c8575c15f868b9959 (diff) | |
Separate primal computations from unzipped function into an explicit function. (#2569)
Co-authored-by: Yong He <yhe@nvidia.com>
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++; + } + } } |
