From 4dbc74a953ae1b34ce64a4eaef3aa7feb73663b9 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 13 Feb 2023 10:38:14 -0800 Subject: Add Loop Unrolling Pass. (#2644) Co-authored-by: Yong He --- source/slang/slang-emit.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/slang/slang-emit.cpp') diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 2ef0a5647..c49265fe7 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -34,6 +34,7 @@ #include "slang-ir-lower-optional-type.h" #include "slang-ir-lower-bit-cast.h" #include "slang-ir-lower-reinterpret.h" +#include "slang-ir-loop-unroll.h" #include "slang-ir-metadata.h" #include "slang-ir-optix-entry-point-uniforms.h" #include "slang-ir-restructure.h" @@ -377,6 +378,16 @@ Result linkAndOptimizeIR( // since we may be missing out cases prevented by the functions that we just specialzied. performMandatoryEarlyInlining(irModule); + // Unroll loops. + if (codeGenContext->getSink()->getErrorCount() == 0) + { + SharedIRBuilder sharedBuilder(irModule); + sharedBuilder.deduplicateAndRebuildGlobalNumberingMap(); + if (!unrollLoopsInModule(&sharedBuilder, irModule, codeGenContext->getSink())) + return SLANG_FAIL; + } + + dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-AUTODIFF"); enableIRValidationAtInsert(); changed |= processAutodiffCalls(irModule, sink); -- cgit v1.2.3