diff options
| author | Julius Ikkala <julius.ikkala@gmail.com> | 2025-07-17 11:46:12 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-17 08:46:12 +0000 |
| commit | b138e3f4b64e8f096c30d200dbafc701f0da6356 (patch) | |
| tree | 7a634f615a0d57b90cf24fef5c4d56369449423c /source | |
| parent | 3485710e93d833a1c7b691af707cfd8962af7d17 (diff) | |
Fix BitCast emitting bit shifts with too small integer types (#7792)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-extract-value-from-type.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/slang/slang-ir-extract-value-from-type.cpp b/source/slang/slang-ir-extract-value-from-type.cpp index 8f72c1623..1e70a28c9 100644 --- a/source/slang/slang-ir-extract-value-from-type.cpp +++ b/source/slang/slang-ir-extract-value-from-type.cpp @@ -331,12 +331,21 @@ IRInst* extractMultiByteValueAtOffset( src, restSize, offset + firstHalfSize); + + auto resultType = builder.getUIntType(); + if (size > 4) + { + resultType = builder.getUInt64Type(); + firstHalf = builder.emitCast(resultType, firstHalf); + secondHalf = builder.emitCast(resultType, secondHalf); + } + uint32_t shift = firstHalfSize * 8; auto resultValue = builder.emitBitOr( - builder.getUIntType(), + resultType, firstHalf, builder.emitShl( - builder.getUIntType(), + resultType, secondHalf, builder.getIntValue(builder.getUIntType(), shift))); return resultValue; |
