summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-07-19 13:50:49 -0700
committerGitHub <noreply@github.com>2023-07-19 13:50:49 -0700
commit1cfb1c85b52e00cde2d21874a88cda2c22d18b62 (patch)
treea38b24534d865ffe33a3d0fc030f5449ba729e28 /source/slang/slang-emit.cpp
parent1fe5e83f3dcc8ef0efa2dd083ebdfab5d0f101a9 (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-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index f07dc97f8..6a43ff8c2 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -329,7 +329,6 @@ Result linkAndOptimizeIR(
}
lowerOptionalType(irModule, sink);
- simplifyIR(irModule, sink);
switch (target)
{
@@ -356,6 +355,8 @@ Result linkAndOptimizeIR(
#endif
validateIRModuleIfEnabled(codeGenContext, irModule);
+ simplifyIR(irModule, sink);
+
// It's important that this takes place before defunctionalization as we
// want to be able to easily discover the cooperate and fallback funcitons
// being passed to saturated_cooperation
@@ -475,10 +476,6 @@ Result linkAndOptimizeIR(
if (sink->getErrorCount() != 0)
return SLANG_FAIL;
-
- // TODO(DG): There are multiple DCE steps here, which need to be changed
- // so that they don't just throw out any non-entry point code
- // Debugging code for IR transformations...
#if 0
dumpIRIfEnabled(codeGenContext, irModule, "SPECIALIZED");
#endif
@@ -493,9 +490,6 @@ Result linkAndOptimizeIR(
//
simplifyIR(irModule, sink);
-#if 0
- dumpIRIfEnabled(codeGenContext, irModule, "AFTER DCE");
-#endif
validateIRModuleIfEnabled(codeGenContext, irModule);
// We don't need the legalize pass for C/C++ based types
@@ -529,7 +523,6 @@ Result linkAndOptimizeIR(
legalizeExistentialTypeLayout(
irModule,
sink);
- eliminateDeadCode(irModule);
#if 0
dumpIRIfEnabled(codeGenContext, irModule, "EXISTENTIALS LEGALIZED");
@@ -550,7 +543,6 @@ Result linkAndOptimizeIR(
legalizeResourceTypes(
irModule,
sink);
- eliminateDeadCode(irModule);
// Debugging output of legalization
#if 0
@@ -565,7 +557,6 @@ Result linkAndOptimizeIR(
legalizeEmptyTypes(
irModule,
sink);
- eliminateDeadCode(irModule);
}
// Once specialization and type legalization have been performed,
@@ -599,7 +590,7 @@ Result linkAndOptimizeIR(
{
specializeArrayParameters(codeGenContext, irModule);
}
- simplifyIR(irModule, sink);
+ eliminateDeadCode(irModule);
// Rewrite functions that return arrays to return them via `out` parameter,
// since our target languages doesn't allow returning arrays.
@@ -842,9 +833,9 @@ Result linkAndOptimizeIR(
// functions, so there might still be invalid code in
// our IR module.
//
- // We run IR simplification passes again to clean things up.
+ // We run DCE pass again to clean things up.
//
- simplifyIR(irModule, sink);
+ eliminateDeadCode(irModule);
if (isKhronosTarget(targetRequest))
{
@@ -885,10 +876,11 @@ Result linkAndOptimizeIR(
// Lower all bit_cast operations on complex types into leaf-level
// bit_cast on basic types.
lowerBitCast(targetRequest, irModule);
- simplifyIR(irModule, sink);
eliminateMultiLevelBreak(irModule);
+ simplifyIR(irModule, sink);
+
// As a late step, we need to take the SSA-form IR and move things *out*
// of SSA form, by eliminating all "phi nodes" (block parameters) and
// introducing explicit temporaries instead. Doing this at the IR level