summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-10-09 18:26:28 -0700
committerGitHub <noreply@github.com>2025-10-10 01:26:28 +0000
commit3cf1f5a616917480c63b76aae906dc36b29e46ce (patch)
treeabbc4538e17be1163c06c950b4afdacd227fe39c /source/slang/slang-emit.cpp
parent4e4aad5a0493defde1e0ef29f27e5d663c1182cd (diff)
Small fix to buffer load specialization pass to allow more specialization to happen. (#8653)
This allows us to further cleanup unnecessary copies in the target code we generate. Part of effort of #8652.
Diffstat (limited to 'source/slang/slang-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index 804a44b81..7d72fb77f 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -1402,6 +1402,12 @@ Result linkAndOptimizeIR(
// function parameters, reults, etc. is invalid.
// We clean up the usages of resource values here.
specializeResourceUsage(codeGenContext, irModule);
+
+ // Specialize calls to functions with values loaded from an immutable location,
+ // so that we directly load the value inside the callee, instead of loading the
+ // value outside of the callee and copy it in. This is necessary to avoid copying
+ // large values (e.g. arrays) in registers, where most of the elements are not
+ // actually used.
specializeFuncsForBufferLoadArgs(codeGenContext, irModule);
// Push `structuredBufferLoad` to the end of access chain to avoid loading unnecessary data.