Instruction
MOVSX
Copies a signed byte or word into a wider register, extending its sign bit.
- Extensions
- Forms
- 7 (7 Legacy)
- Data
- Intel XED v2026.08.23
MOVSX reads a signed byte or word and writes it to a wider register,
filling the bits above it with copies of its sign bit. It is how
compiled code loads signed char and short values: GCC 14 and
Clang 23 at -O2 compile a read of *p, with p a short *, to
movsx eax, word ptr [rdi] for an int result and to
movsx rax, word ptr [rdi] for a long. MOVZX fills
with zeros instead.
From 32 to 64 bits
No MOVSX takes a 32-bit source. Widening an int to 64 bits is
MOVSXD, which GCC and Clang both print as
movsxd rax, edi; CDQE does the same for EAX
alone in two bytes, and both compilers use it on an int that a call
returned. The everyday case is an int array index: a[i] needs i
sign-extended before it can enter a 64-bit address, where an unsigned
index needs only a 32-bit MOV such as mov esi, esi.
Who extends a small argument
For int f(short s) { return s; }, GCC emits movsx eax, di, while
Clang emits a plain mov eax, edi and trusts the caller to have
extended the argument; the
System V page explains why that
holds in practice but is not promised. Plain char is signed on x86-64
(sizes of C types), and both compilers treat
it the same way.
Sizes
- A 32-bit destination clears bits 63:32, so
movsx eax, byte ptr [rdi]leaves a negative byte as a positive 64-bit value; alongresult needs the 64-bit destination. A 16-bit destination keeps bits 63:16, like any 16-bit write. - A word source with a 16-bit destination has nothing to extend: it copies the word.
- GNU’s AT&T syntax names both sizes, source first:
movsbw,movsbl,movsbq,movswl,movswq, andmovslqfor MOVSXD.
Instead of a byte or word MOV
A MOV into AL or AX merges the new bits with the rest of the register, so later readers wait for both; MOVSX into a 32- or 64-bit register replaces it whole. Intel’s optimization manual uses MOVSX that way to break such a dependency (Section 13.2.5). It also counts MOVSX among the register moves that Ivy Bridge cannot eliminate, where MOVZX from a low byte register qualifies (Example 3-21), and its Coding Rule 34 prefers zero extension where either will do.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
MOVSX r16/32/64, m8
MOVSX_GPRv_MEMb | 0F BE /r | Base instruction set |
MOVSX r16/32/64, m16 not in 64-bit mode
MOVSX_GPRv_MEMw | 0F BF /r | Base instruction set |
MOVSX r64, m16 64-bit mode only
MOVSX_GPR64_MEMw | REX.W 0F BF /r | Base instruction set |
MOVSX r16, m16 64-bit mode only
MOVSX_GPR16_MEMw | 66 0F BF /r | Base instruction set |
MOVSX r32, m16 64-bit mode only
MOVSX_GPR32_MEMw | 0F BF /r | Base instruction set |
MOVSX r16/32/64, r8
MOVSX_GPRv_GPR8 | 0F BE /r | Base instruction set |
MOVSX r16/32/64, r16
MOVSX_GPRv_GPR16 | 0F BF /r | Base instruction set |
Latency and throughput
| Model | r16, m8 | r32, m8r64, m8r64, m16r32, m16 | r16, r8 | r32, r8r64, r8r32, r16r64, r16 |
|---|---|---|---|---|
| Sandy Bridge | 5 / 0.5p23 | 5 / 0.5p23 | 1 / 0.33p015 | 1 / 0.33p015 |
| Haswell, Broadwell, Skylake, Skylake-SP, Ice Lake | 5 / 0.5p23 | 5 / 0.5p23 | 1 / 0.25p0156 | 1 / 0.25p0156 |
| Alder Lake, Sapphire Rapids | 6 / 0.33p1 p5 p11 | 6 / 0.33p2 p3 p10 | 1 / 0.33p1 p5 p11 | 1 / 0.33p1 p5 p11 |
| Lunar Lake | 6 / 0.33p135 | 6 / 0.33p20 p21 p22 | 1 / 0.33p135 | 1 / 0.33p135 |
| Bonnell | 3 / 1.5p1 | 1 / 1p0 | 2 / 1p01 | 1 / 1p0 |
| Silvermont | 3 / 1MEC | 3 / 1MEC | 1 / 0.5IEC0 IEC1 | 1 / 0.5IEC0 IEC1 |
| Piledriver | 5 / 1AGLU01 Load | 5 / 1AGLU01 Load | 1 / 1EX0 EX1 | 1 / 1EX0 EX1 |
| Zen | 4 / 0.5AGU0 AGU1 | 4 / 0.5AGU0 AGU1 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Zen 2 | 4 / 0.33AGU0 AGU1 AGU2 | 4 / 0.33AGU0 AGU1 AGU2 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Zen 3, Zen 4 | 5 / 1AGU0 AGU1 AGU2 LSU Load | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | 1 / 1ALU0 ALU1 ALU2 ALU3 | 1 / 0.25ALU0 ALU1 ALU2 ALU3 |
| Jaguar | 3 / 1LAGU | 3 / 1LAGU | 1 / 0.5ALU0 ALU1 | 1 / 0.5ALU0 ALU1 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
dest.write(sext(src)) # from 8 or 16 bits to OSIZE: a 16-bit
# register keeps bits 63:16, a 32-bit one
# gets bits 63:32 cleared
# MOVSX r16, r/m16 has nothing to extend: it copies the wordRun on AMD Zen 5 (EPYC 9645): 90 cases. The forms that 64-bit mode lacks were not run: the probe runs in 64-bit mode.
Operands
| Operand | Kind | Action |
|---|---|---|
MOVSX r16/32/64, r/m8 MOVSX r16/32/64, m16 not in 64-bit mode MOVSX r16, m16 64-bit mode only MOVSX r32, m16 64-bit mode only MOVSX r64, m16 64-bit mode only | ||
r16/32/64 | explicit | write |
r/m8, m16 | explicit | read |
MOVSX r16/32/64, r16 | ||
r16/32/64 | explicit | write |
r16 | explicit | read |
Flags
None: XED records no flag that the forms test or change.
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
I386 | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More General-purpose instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-120 (MOVSX/
MOVSXD) - AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The timings come from LLVM's scheduling models, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.