summaryrefslogtreecommitdiff
path: root/source/slang/slang-lower-to-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-05-31 14:28:45 -0700
committerGitHub <noreply@github.com>2023-05-31 14:28:45 -0700
commit02bb741a8d1b4ed31a65c46b7e43d153b42a7b73 (patch)
tree1a548e812568de27b8fffcc2e251596e9d729177 /source/slang/slang-lower-to-ir.cpp
parent5dd401e416e18fdfe904a66284b0cf56cf256ec7 (diff)
Preserve type cast during AST constant folding. (#2912)
* Preserve type cast during AST constant folding. Fixes #2891. * Fix. * Fix truncating. * fix test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
-rw-r--r--source/slang/slang-lower-to-ir.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index b36f0dc94..144875e8c 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -1432,6 +1432,15 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower
tryEnv);
}
+ LoweredValInfo visitTypeCastIntVal(TypeCastIntVal* val)
+ {
+ TryClauseEnvironment tryEnv;
+ auto baseVal = lowerVal(context, val->base);
+ SLANG_ASSERT(baseVal.flavor == LoweredValInfo::Flavor::Simple);
+ auto type = lowerType(context, val->type);
+ return LoweredValInfo::simple(getBuilder()->emitCast(type, baseVal.val));
+ }
+
LoweredValInfo visitWitnessLookupIntVal(WitnessLookupIntVal* val)
{
auto witnessVal = lowerVal(context, val->witness);