summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/jit/x86/beam_asm.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/beam/jit/x86/beam_asm.hpp')
-rw-r--r--erts/emulator/beam/jit/x86/beam_asm.hpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/erts/emulator/beam/jit/x86/beam_asm.hpp b/erts/emulator/beam/jit/x86/beam_asm.hpp
index dee1edebb5..5e83c7e83c 100644
--- a/erts/emulator/beam/jit/x86/beam_asm.hpp
+++ b/erts/emulator/beam/jit/x86/beam_asm.hpp
@@ -795,7 +795,20 @@ protected:
void mov_imm(x86::Gp to, T value) {
static_assert(std::is_integral<T>::value || std::is_pointer<T>::value);
if (value) {
- a.mov(to, imm(value));
+ /* Generate the shortest instruction to set the register to an
+ * immediate.
+ *
+ * 48 c7 c0 2a 00 00 00 mov rax, 42
+ * b8 2a 00 00 00 mov eax, 42
+ *
+ * 49 c7 c0 2a 00 00 00 mov r8, 42
+ * 41 b8 2a 00 00 00 mov r8d, 42
+ */
+ if (Support::isUInt32((Uint)value)) {
+ a.mov(to.r32(), imm(value));
+ } else {
+ a.mov(to, imm(value));
+ }
} else {
/*
* Generate the shortest instruction to set the register to zero.