summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-07-16 11:35:46 -0400
committerGitHub <noreply@github.com>2024-07-16 08:35:46 -0700
commit12ecc43ae07035d951beb531058ba27bdfb9c0de (patch)
treeb1ae149ff81711776ad10d4ff8fd708ac9fea314 /source
parent6bcf92d28d919eba7607c93c8581966875d2add6 (diff)
SCCP instead of CFG since SCCP removes code of unused branches, not CFG (#4640)
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit.cpp2
-rw-r--r--source/slang/slang-ir-legalize-is-texture-access.cpp21
-rw-r--r--source/slang/slang-ir-legalize-is-texture-access.h2
3 files changed, 13 insertions, 12 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index d3f6ebd8d..cb8460173 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -911,7 +911,7 @@ Result linkAndOptimizeIR(
legalizeVectorTypes(irModule, sink);
// Legalize `__isTextureAccess` and related.
- legalizeIsTextureAccess(irModule);
+ legalizeIsTextureAccess(irModule, sink);
// Once specialization and type legalization have been performed,
// we should perform some of our basic optimization steps again,
diff --git a/source/slang/slang-ir-legalize-is-texture-access.cpp b/source/slang/slang-ir-legalize-is-texture-access.cpp
index 929da591b..a3540e3f2 100644
--- a/source/slang/slang-ir-legalize-is-texture-access.cpp
+++ b/source/slang/slang-ir-legalize-is-texture-access.cpp
@@ -8,7 +8,7 @@
#include "slang-parameter-binding.h"
#include "slang-ir-legalize-image-subscript.h"
#include "slang-ir-legalize-varying-params.h"
-#include "slang-ir-simplify-cfg.h"
+#include "slang-ir-sccp.h"
namespace Slang
{
@@ -17,9 +17,9 @@ namespace Slang
return as<IRImageSubscript>(getRootAddr(inst->getOperand(0)));
}
- void legalizeIsTextureAccess(IRModule* module)
+ void legalizeIsTextureAccess(IRModule* module, DiagnosticSink* sink)
{
- HashSet<IRFunc*> functionsToSimplifyCFG;
+ HashSet<IRFunc*> functionsToSCCP;
IRBuilder builder(module);
for (auto globalInst : module->getModuleInst()->getChildren())
{
@@ -41,7 +41,7 @@ namespace Slang
else
{
inst->replaceUsesWith(builder.getBoolValue(false));
- functionsToSimplifyCFG.add(func);
+ functionsToSCCP.add(func);
}
inst->removeAndDeallocate();
continue;
@@ -53,7 +53,7 @@ namespace Slang
else
{
inst->replaceUsesWith(builder.getBoolValue(false));
- functionsToSimplifyCFG.add(func);
+ functionsToSCCP.add(func);
}
inst->removeAndDeallocate();
continue;
@@ -66,7 +66,7 @@ namespace Slang
else
{
inst->replaceUsesWith(builder.getBoolValue(false));
- functionsToSimplifyCFG.add(func);
+ functionsToSCCP.add(func);
}
inst->removeAndDeallocate();
continue;
@@ -75,10 +75,11 @@ namespace Slang
}
}
}
- // Requires a simplifyCFG to ensure Slang does not evaluate 'IRTextureType' code path for
- // 'inst' for when 'inst' is not a 'IRTextureType'/TextureAccessor
- for(auto func : functionsToSimplifyCFG)
- simplifyCFG(func, CFGSimplificationOptions::getFast());
+ // Requires a SCCP to ensure Slang does not evaluate 'IRTextureType' code path
+ // and unresolved 'isTextureAccess' operations for when 'inst' is not a
+ // 'IRTextureType'/`TextureAccessor`
+ for (auto func : functionsToSCCP)
+ applySparseConditionalConstantPropagation(func, sink);
}
}
diff --git a/source/slang/slang-ir-legalize-is-texture-access.h b/source/slang/slang-ir-legalize-is-texture-access.h
index eccfe8fcb..9b9e1cca0 100644
--- a/source/slang/slang-ir-legalize-is-texture-access.h
+++ b/source/slang/slang-ir-legalize-is-texture-access.h
@@ -7,5 +7,5 @@ namespace Slang
{
class DiagnosticSink;
- void legalizeIsTextureAccess(IRModule* module);
+ void legalizeIsTextureAccess(IRModule* module, DiagnosticSink* sink);
}