Instruction
MOVBE
Loads or stores a 16-, 32- or 64-bit value with its byte order reversed; APX adds a register-to-register form.
MOVBE is a load or a store that reverses the byte order on the way, for data kept big-endian: network headers, many file formats, hash outputs such as SHA-256’s. It replaces a plain move followed or preceded by BSWAP, and the store form leaves its source register untouched, which a BSWAP in place would not. One operand must be memory: there is no register-to-register form outside APX, and BSWAP covers that case. Flags are unchanged.
Compilers find it
Nobody needs an intrinsic. With -mmovbe or an -march that has it
(x86-64-v3, haswell, znver1 and later), GCC 14 and Clang 23 at -O2 turn
__builtin_bswap32 of a value loaded with memcpy into a single
movbe eax, dword ptr [rdi], and a 64-bit byte-swapped store into
movbe qword ptr [rdi], rsi. They even recognize the portable
expression p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3] and emit the
same single MOVBE. Without the flag they load and BSWAP, or for 16
bits load and rol ax, 8. A swap of a value already in a register
stays a BSWAP.
Register widths
As for other 16-bit writes, MOVBE to a 16-bit register keeps bits 63:16,
and to a 32-bit one clears bits 63:32: on Zen 5, movbe cx, word ptr [...] replaced only CX, and movbe ecx, dword ptr [...] left 0 in the
upper half of RCX. This is the 16-bit byte swap that BSWAP lacks, whose
16-bit form is undefined. Zen 5 ran every size of both forms with
distinct byte patterns, and each came out reversed.
Encoding
MOVBE is 0F 38 F0 (load) and 0F 38 F1 (store); the same bytes with an F2 prefix are CRC32. APX’s EVEX forms add the register-to-register move. The CPUID bit is leaf 1, ECX bit 22. Intel’s Atom had MOVBE before Intel’s big cores, which gained it with Haswell; AMD’s processors have it from Zen on, and Excavator before. AMD’s Zen 5 guide lists MOVBE as a single macro-op.
In the optimization guide
What the optimization guide says about MOVBE, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Silvermont to Goldmont Plus
- Out-of-order and in-order execution: LLVM’s tuning for all four cores loads the operand of
pushandcallinto a register first, and prefersmovbeto a load and abswap.
Tremont
- Integer execution: LLVM’s tuning prefers
movbeto a load andbswap, or tobswapand a store, on this core.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
MOVBE r16/32/64, m16/32/64
MOVBE_GPRv_MEMv | 0F 38 F0 /r | MOVBE |
MOVBE m16/32/64, r16/32/64
MOVBE_MEMv_GPRv | 0F 38 F1 /r | MOVBE |
MOVBE r16/32/64, r16/32/64
MOVBE_GPRv_GPRv_APX | EVEX.LLZ.NP.MAP4.SCALABLE 60 /rEVEX.LLZ.NP.MAP4.SCALABLE 61 /r | APX_F + MOVBE |
MOVBE r16/32/64, m16/32/64
MOVBE_GPRv_MEMv_APX | EVEX.LLZ.NP.MAP4.SCALABLE 60 /r | APX_F + MOVBE |
MOVBE m16/32/64, r16/32/64
MOVBE_MEMv_GPRv_APX | EVEX.LLZ.NP.MAP4.SCALABLE 61 /r | APX_F + MOVBE |
Latency and throughput
| Model | r16, m16 | r32, m32 | r64, m64 | m16, r16 | m32, r32 | m64, r64 |
|---|---|---|---|---|---|---|
| Haswell | 6 / 0.5p15 | 6 / 0.5p15 | 6 / 0.5p15 | 2 / 1p06 | 2 / 1p15 | 2 / 1p15 |
| Broadwell, Skylake, Skylake-SP | 6 / 0.5p15 | 6 / 0.5p15 | 6 / 0.5p15 | 2 / 1p15 | 2 / 1p15 | 2 / 1p15 |
| Ice Lake | 6 / 0.5p15 | 6 / 0.5p15 | 6 / 0.5p15 | 2 / 0.5p15 | 2 / 0.5p15 | 2 / 0.5p15 |
| Alder Lake, Sapphire Rapids | 7 / 0.5p0 p1 p5 p6 p11 | 6 / 1p1 | 7 / 1p016 | 12 / 0.5p06 | 12 / 1p1 | 12 / 1p016 |
| Lunar Lake | 100 / 1.33p135 | 100 / 1.33p135 | 100 / 1.33p135 | 12 / 0.5p024 | 12 / 0.5p135 | 12 / 0.5p012345 |
| Bonnell | 1 / 1p0 | 1 / 1p0 | 1 / 1p0 | 1 / 1p0 | 1 / 1p0 | 1 / 1p0 |
| Silvermont | 4 / 1IEC0 IEC1 MEC | 4 / 1IEC0 IEC1 MEC | 4 / 1IEC0 IEC1 MEC | 1 / 1IEC0 IEC1 MEC | 1 / 1IEC0 IEC1 MEC | 1 / 1IEC0 IEC1 MEC |
| Zen | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 | 5 / 0.5ALU0 ALU1 ALU2 ALU3 |
| Zen 2 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 |
| Zen 3, Zen 4 | 4 / 1ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 5 / 0.33ALU0 ALU1 ALU2 ALU3 | 1 / 1ALU0 ALU1 ALU2 ALU3 | 1 / 1ALU0 ALU1 ALU2 ALU3 | 1 / 1ALU0 ALU1 ALU2 ALU3 |
| Jaguar | 4 / 1ALU0 ALU1 | 4 / 1ALU0 ALU1 | 4 / 1ALU0 ALU1 | 1 / 1SAGU | 1 / 1SAGU | 1 / 1SAGU |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
v = src.read()
r = 0
for i in range(OSIZE // 8):
r = r << 8 | (v >> 8 * i & 0xFF) # the bytes in reverse order
dest.write(r) # a 16-bit register keeps bits 63:16, a
# 32-bit one gets bits 63:32 cleared
Run on AMD Zen 5 (EPYC 9645): 30 cases. The APX forms were not run: none of these processors has APX.
Operands
| Operand | Kind | Action |
|---|---|---|
MOVBE m16/32/64, r16/32/64 | ||
m16/32/64 | explicit | write |
r16/32/64 | explicit | read |
MOVBE r16/32/64, r/m16/32/64 | ||
r16/32/64 | explicit | write |
r/m16/32/64 | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- Legacy forms
- none in XED
- EVEX forms
APX-EVEX-INT
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to MOVBE, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
_loadbe_i16
short _loadbe_i16(const void *__P) |
|
_loadbe_i32
int _loadbe_i32(const void *__P) |
|
_loadbe_i64
long long _loadbe_i64(const void *__P) |
|
_storebe_i16
void _storebe_i16(void *__P, short __D) |
|
_storebe_i32
void _storebe_i32(void *__P, int __D) |
|
_storebe_i64
void _storebe_i64(void *__P, long long __D) |
|
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 |
|---|---|---|
MOVBE | MOVBE | Haswell, Broadwell, Skylake, Comet Lake, Cannon Lake, Ice Lake (client), Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Bonnell, Saltwell, Silvermont, Goldmont, Goldmont Plus, Tremont, Snow Ridge, Lakefield, Sierra Forest, Clearwater Forest, Knights Landing, Knights Mill, Zen, Zen+, Zen 2, Zen 3, Zen 4, Zen 5, Zen 6 |
APX_F_MOVBE | APX_F + MOVBE | Nova Lake, Diamond Rapids |
More APX 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. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - 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-45 (MOVBE)
- Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 2026)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
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 intrinsics and their signatures come from Clang and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.