diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index 771882b6190d69..553ec02ed576b6 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -2388,6 +2388,7 @@ void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi) * small encoding (0 through 3), and vice versa. */ +#if DEBUG const emitter::opSize emitter::emitSizeEncode[] = { emitter::OPSZ1, emitter::OPSZ2, OPSIZE_INVALID, emitter::OPSZ4, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, emitter::OPSZ8, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, @@ -2398,6 +2399,7 @@ const emitter::opSize emitter::emitSizeEncode[] = { const emitAttr emitter::emitSizeDecode[emitter::OPSZ_COUNT] = {EA_1BYTE, EA_2BYTE, EA_4BYTE, EA_8BYTE, EA_16BYTE, EA_32BYTE}; +#endif /***************************************************************************** * diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index 4b7af2f73e31dc..a30a828af25122 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -488,8 +488,10 @@ class emitter #define OPSIZE_INVALID ((opSize)0xffff) +#if DEBUG static const emitter::opSize emitSizeEncode[]; static const emitAttr emitSizeDecode[]; +#endif static emitter::opSize emitEncodeSize(emitAttr size); static emitAttr emitDecodeSize(emitter::opSize ensz); @@ -1047,7 +1049,7 @@ class emitter } #endif // TARGET_LOONGARCH64 - emitAttr idOpSize() + emitAttr idOpSize() const { return emitDecodeSize(_idOpSize); } @@ -2856,15 +2858,19 @@ inline emitAttr emitActualTypeSize(T type) { assert(size == EA_1BYTE || size == EA_2BYTE || size == EA_4BYTE || size == EA_8BYTE || size == EA_16BYTE || size == EA_32BYTE); + emitter::opSize result = static_cast(genLog2(static_cast(size))); - return emitSizeEncode[((int)size) - 1]; + assert(result == emitSizeEncode[static_cast(size) - 1]); + return result; } /* static */ inline emitAttr emitter::emitDecodeSize(emitter::opSize ensz) { - assert(((unsigned)ensz) < OPSZ_COUNT); + assert(static_cast(ensz) < OPSZ_COUNT); + emitAttr result = static_cast(1 << static_cast(ensz)); - return emitSizeDecode[ensz]; + assert(result == emitSizeDecode[ensz]); + return result; } /***************************************************************************** diff --git a/src/coreclr/jit/emitxarch.h b/src/coreclr/jit/emitxarch.h index 13f79bc3833cca..e35c79556a9b82 100644 --- a/src/coreclr/jit/emitxarch.h +++ b/src/coreclr/jit/emitxarch.h @@ -705,15 +705,19 @@ void emitAdjustStackDepth(instruction ins, ssize_t val); inline emitter::opSize emitEncodeScale(size_t scale) { assert(scale == 1 || scale == 2 || scale == 4 || scale == 8); + emitter::opSize result = static_cast(genLog2(static_cast(scale))); - return emitSizeEncode[scale - 1]; + assert(result == emitSizeEncode[scale - 1]); + return result; } inline emitAttr emitDecodeScale(unsigned ensz) { assert(ensz < 4); + emitAttr result = static_cast(1 << ensz); - return emitter::emitSizeDecode[ensz]; + assert(result == emitter::emitSizeDecode[ensz]); + return result; } /************************************************************************/