summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-03-27 19:51:21 -0700
committerGitHub <noreply@github.com>2023-03-27 19:51:21 -0700
commit579870b714e76cc92300cef1fdf091993bb55954 (patch)
tree20e4c85ddc34a84706b30338b310e97862d2fe15 /source
parent84dc318576e19ef1f86f6b012ba911c4b63f788d (diff)
Apply IR simplifcation immediately after specialization to avoid duplicates. (#2739)
* Apply IR simplifcation immediately after specialization to avoid duplicates. * Update source/slang/slang-ir-specialize.cpp Co-authored-by: Ellie Hermaszewska <github@sub.monoid.al> --------- Co-authored-by: Yong He <yhe@nvidia.com> Co-authored-by: Ellie Hermaszewska <github@sub.monoid.al>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-specialize.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-ir-specialize.cpp b/source/slang/slang-ir-specialize.cpp
index 05c28d131..d2e042363 100644
--- a/source/slang/slang-ir-specialize.cpp
+++ b/source/slang/slang-ir-specialize.cpp
@@ -2439,6 +2439,16 @@ IRInst* specializeGenericImpl(
// value.
cloneInstDecorationsAndChildren(
&env, module, specializeInst, specializedVal);
+
+ // Perform IR simplifications to fold constants in this specialized value if it is a function, so
+ // further specializations from the specialized function will have as simple specialization
+ // arguments as possible to avoid creating specializations that eventually simplified into
+ // the same thing.
+ if (auto func = as<IRFunc>(specializedVal))
+ {
+ simplifyFunc(func);
+ }
+
return specializedVal;
}