From 216dfba0af66210a46ef0df18beb73d975fdf727 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 19 Dec 2022 11:47:19 -0800 Subject: Separate primal computations from unzipped function into an explicit function. (#2569) Co-authored-by: Yong He --- source/slang/slang-ir-peephole.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ir-peephole.cpp') diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp index 66cde68de..21e17b546 100644 --- a/source/slang/slang-ir-peephole.cpp +++ b/source/slang/slang-ir-peephole.cpp @@ -241,16 +241,21 @@ struct PeepholeContext : InstPassBase } } - bool processModule() + bool processFunc(IRInst* func) { SharedIRBuilder* sharedBuilder = &sharedBuilderStorage; sharedBuilder->init(module); sharedBuilderStorage.deduplicateAndRebuildGlobalNumberingMap(); changed = false; - processAllInsts([this](IRInst* inst) { processInst(inst); }); + processChildInsts(func, [this](IRInst* inst) { processInst(inst); }); return changed; } + + bool processModule() + { + return processFunc(module->getModuleInst()); + } }; bool peepholeOptimize(IRModule* module) @@ -259,4 +264,10 @@ bool peepholeOptimize(IRModule* module) return context.processModule(); } +bool peepholeOptimize(IRInst* func) +{ + PeepholeContext context = PeepholeContext(func->getModule()); + return context.processFunc(func); +} + } // namespace Slang -- cgit v1.2.3