diff options
| author | Yong He <yonghe@outlook.com> | 2022-02-25 20:49:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-25 20:49:31 -0800 |
| commit | c31577953d5041c82375c22d847c2eba06106c58 (patch) | |
| tree | bc685a8b63fc13cb85d160ae13df950056ca6e91 /source/slang/slang-ir-ssa-simplification.cpp | |
| parent | 8990d270e3a0c01b1f7abbf4f79556c5ef82a096 (diff) | |
Improved SCCP, inlining and resource specialization passes, legalize `ImageSubscript` for GLSL (#2146)
Diffstat (limited to 'source/slang/slang-ir-ssa-simplification.cpp')
| -rw-r--r-- | source/slang/slang-ir-ssa-simplification.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/slang/slang-ir-ssa-simplification.cpp b/source/slang/slang-ir-ssa-simplification.cpp new file mode 100644 index 000000000..fcc6dc4ae --- /dev/null +++ b/source/slang/slang-ir-ssa-simplification.cpp @@ -0,0 +1,36 @@ +// slang-ir-ssa-simplification.cpp +#include "slang-ir-ssa-simplification.h" +#include "slang-ir.h" +#include "slang-ir-ssa.h" +#include "slang-ir-sccp.h" +#include "slang-ir-dce.h" +#include "slang-ir-simplify-cfg.h" + +namespace Slang +{ + struct IRModule; + + // Run a combination of SSA, SCCP, SimplifyCFG, and DeadCodeElimination pass + // until no more changes are possible. + void simplifyIR(IRModule* module) + { + bool changed = true; + const int kMaxIterations = 8; + int iterationCounter = 0; + while (changed && iterationCounter < kMaxIterations) + { + changed = false; + changed |= applySparseConditionalConstantPropagation(module); + changed |= simplifyCFG(module); + + // 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(module); + + changed |= constructSSA(module); + + iterationCounter++; + } + } +} |
