diff options
| author | Yong He <yonghe@outlook.com> | 2023-05-31 14:28:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-31 14:28:45 -0700 |
| commit | 02bb741a8d1b4ed31a65c46b7e43d153b42a7b73 (patch) | |
| tree | 1a548e812568de27b8fffcc2e251596e9d729177 /source/slang/slang-lower-to-ir.cpp | |
| parent | 5dd401e416e18fdfe904a66284b0cf56cf256ec7 (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.cpp | 9 |
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); |
