From 579870b714e76cc92300cef1fdf091993bb55954 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 27 Mar 2023 19:51:21 -0700 Subject: 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 --------- Co-authored-by: Yong He Co-authored-by: Ellie Hermaszewska --- source/slang/slang-ir-specialize.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source') 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(specializedVal)) + { + simplifyFunc(func); + } + return specializedVal; } -- cgit v1.2.3