diff options
| author | Yong He <yonghe@outlook.com> | 2022-11-30 13:24:39 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-30 13:24:39 -0800 |
| commit | 09684224d5ab63f530d66c0be65fa50e6fc5290b (patch) | |
| tree | 292d0f257b3d5a5e027892a5a1e046d60166aadd /source/slang/slang-emit.cpp | |
| parent | f52b4de3b29ee27213b7d60fb620a0d5d50b49f9 (diff) | |
Support `no_diff` on existential typed params. (#2540)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit.cpp')
| -rw-r--r-- | source/slang/slang-emit.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index ca55a68bc..508402736 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -358,33 +358,36 @@ Result linkAndOptimizeIR( // perform specialization of functions based on parameter // values that need to be compile-time constants. // + // Specialization passes and auto-diff passes runs in an iterative loop + // since each pass can enable the other pass to progress further. + for (;;) + { + bool changed = false; - dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-SPECIALIZE"); - if (!codeGenContext->isSpecializationDisabled()) - specializeModule(irModule); - dumpIRIfEnabled(codeGenContext, irModule, "AFTER-SPECIALIZE"); - - applySparseConditionalConstantPropagation(irModule); - eliminateDeadCode(irModule); + dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-SPECIALIZE"); + if (!codeGenContext->isSpecializationDisabled()) + changed |= specializeModule(irModule); + dumpIRIfEnabled(codeGenContext, irModule, "AFTER-SPECIALIZE"); - lowerReinterpret(targetRequest, irModule, sink); - - validateIRModuleIfEnabled(codeGenContext, irModule); + validateIRModuleIfEnabled(codeGenContext, irModule); - // Inline calls to any functions marked with [__unsafeInlineEarly] again, - // since we may be missing out cases prevented by the functions that we just specialzied. - performMandatoryEarlyInlining(irModule); + // Inline calls to any functions marked with [__unsafeInlineEarly] again, + // since we may be missing out cases prevented by the functions that we just specialzied. + performMandatoryEarlyInlining(irModule); - dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-AUTODIFF"); - - processAutodiffCalls(irModule, sink); + dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-AUTODIFF"); + changed |= processAutodiffCalls(irModule, sink); + dumpIRIfEnabled(codeGenContext, irModule, "AFTER-AUTODIFF"); - dumpIRIfEnabled(codeGenContext, irModule, "AFTER-AUTODIFF"); + if (!changed) + break; + } + + lowerReinterpret(targetRequest, irModule, sink); validateIRModuleIfEnabled(codeGenContext, irModule); - applySparseConditionalConstantPropagation(irModule); - eliminateDeadCode(irModule); + simplifyIR(irModule); // For targets that supports dynamic dispatch, we need to lower the // generics / interface types to ordinary functions and types using |
