diff options
| author | Yong He <yonghe@outlook.com> | 2023-07-19 13:50:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-19 13:50:49 -0700 |
| commit | 1cfb1c85b52e00cde2d21874a88cda2c22d18b62 (patch) | |
| tree | a38b24534d865ffe33a3d0fc030f5449ba729e28 /source/slang/slang-ir-peephole.cpp | |
| parent | 1fe5e83f3dcc8ef0efa2dd083ebdfab5d0f101a9 (diff) | |
Optimize specialization, and remove unnecessary calls to `simplifyIR`. (#2999)
* Remove unneccessary calls to `simplifyIR`.
* fix.
* Delete obsolete hoistConst pass.
* Fix.
* Small improvements.
* Fix.
* Fix enum lowering.
* fix
* tweaks.
* tweaks.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-peephole.cpp')
| -rw-r--r-- | source/slang/slang-ir-peephole.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp index 376795855..ac026b563 100644 --- a/source/slang/slang-ir-peephole.cpp +++ b/source/slang/slang-ir-peephole.cpp @@ -235,9 +235,6 @@ struct PeepholeContext : InstPassBase return false; } - RefPtr<IRDominatorTree> domTree; - IRGlobalValueWithCode* domTreeFunc = nullptr; - void processInst(IRInst* inst) { if (as<IRGlobalValueWithCode>(inst)) @@ -746,13 +743,8 @@ struct PeepholeContext : InstPassBase auto parentFunc = getParentFunc(inst); if (!parentFunc) break; - if (domTreeFunc != parentFunc) - { - domTree = computeDominatorTree(parentFunc); - domTreeFunc = parentFunc; - } - if (!domTree) - break; + + auto domTree = parentFunc->getModule()->findOrCreateDominatorTree(parentFunc); if (domTree->dominates(argValue, inst)) { @@ -816,6 +808,8 @@ struct PeepholeContext : InstPassBase bool processFunc(IRInst* func) { + func->getModule()->invalidateAllAnalysis(); + bool result = false; for (;;) { @@ -847,6 +841,22 @@ bool peepholeOptimize(IRInst* func) return context.processFunc(func); } +bool peepholeOptimizeGlobalScope(IRModule* module) +{ + PeepholeContext context = PeepholeContext(module); + bool result = false; + for (;;) + { + context.changed = false; + for (auto globalInst : module->getGlobalInsts()) + context.processInst(globalInst); + result |= context.changed; + if (!context.changed) + break; + } + return result; +} + bool tryReplaceInstUsesWithSimplifiedValue(IRModule* module, IRInst* inst) { if (inst != tryConstantFoldInst(module, inst)) |
