From 4c18313333034af02d644732b8353bb0c7731848 Mon Sep 17 00:00:00 2001 From: Mike Danes Date: Sat, 22 Apr 2017 16:41:56 +0300 Subject: [PATCH] Simplify emitter's RegEncoding VC++ does't recognize that `(c ? x - 16 : x) & 7` is just `x & 7` and we end up with 5 instructions instead of 1. Commit migrated from https://github.com/dotnet/coreclr/commit/f6f991bac4ca614701627a4bd126d79b28d05514 --- src/coreclr/src/jit/emitxarch.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/coreclr/src/jit/emitxarch.cpp b/src/coreclr/src/jit/emitxarch.cpp index b495d01..7608130 100644 --- a/src/coreclr/src/jit/emitxarch.cpp +++ b/src/coreclr/src/jit/emitxarch.cpp @@ -332,16 +332,9 @@ bool IsXMMReg(regNumber reg) unsigned RegEncoding(regNumber reg) { #ifndef LEGACY_BACKEND - // XMM registers do not share the same reg numbers as integer registers. - // But register encoding of integer and XMM registers is the same. - // Therefore, subtract XMMBASE from regNumber to get the register encoding - // in case of XMM registers. - return (unsigned)((IsXMMReg(reg) ? reg - XMMBASE : reg) & 0x7); -#else // LEGACY_BACKEND - // Legacy X86: XMM registers share the same reg numbers as integer registers and - // hence nothing to do to get reg encoding. + static_assert((REG_XMM0 & 0x7) == 0, "bad XMMBASE"); +#endif return (unsigned)(reg & 0x7); -#endif // LEGACY_BACKEND } // Utility routines that abstract the logic of adding REX.W, REX.R, REX.X, REX.B and REX prefixes -- 2.7.4