Instruction
PSHUFW
Copies to an MMX register the words of another or of memory in the order four 2-bit fields of an immediate select; SSE.
- Extensions
- Forms
- 2 (2 Legacy)
- Data
- Intel XED v2026.08.23
PSHUFW rearranges the four words of an MMX register or a 64-bit memory operand into an MMX register, as an immediate says: bits 1:0 choose the source word for word 0, and so on up to bits 7:6 for word 3, and a word may be chosen more than once. It does not read its destination. It came with SSE, among the 64-bit integer instructions of Intel’s Volume 1, chapter 10, and AMD’s manual calls it an AMD extension to MMX as well. SSE2 carried the idea to XMM registers in three parts: PSHUFLW and PSHUFHW for words and PSHUFD for doublewords, whose page has a table of the usual immediates. Like every MMX instruction it switches the x87 unit to MMX use, as MOVD’s page explains.
On Zen 5, pshufw mm3, mm3, 6Ah, whose fields read 1, 2, 2, 2 from the
top, made word 3 a copy of word 1 and words 2 to 0 copies of word 2, all
taken from MM3’s old value: a register may shuffle itself.
In compiled code
The intrinsic is _mm_shuffle_pi16. In 64-bit code, GCC 14 and Clang 23
at -O2 keep __m64 values in XMM registers and compile it to PSHUFLW,
which shuffles the low quadword the same way. Only with -m32 does GCC
emit PSHUFW, from a register or straight from memory inside a loop;
Clang 23 uses PSHUFLW there too.
Intel’s entry says that a REX.R prefix lets this instruction reach XMM8-XMM15, though its operands are MMX registers, MM0 to MM7. AMD’s Zen 5 guide lists PSHUFW as one macro-op on any of the four FP pipes.
Forms
Latency and throughput
| Model | mm, m64, imm8 | mm, mm, imm8 |
|---|---|---|
| Sandy Bridge, Haswell, Broadwell, Skylake, Skylake-SP, Ice Lake | 6 / 1p5 | 1 / 1p5 |
| Alder Lake, Sapphire Rapids | 9 / 1p5 | 1 / 1p5 |
| Lunar Lake | 9 / 0.5V2 V3 | 1 / 0.5V2 V3 |
| Bonnell | 1 / 1p0 | 1 / 1p0 |
| Silvermont | 4 / 1FPC0 | 1 / 1FPC0 |
| Piledriver | 7 / 1.5FPU1 FPXBR | 2 / 1FPU1 FPXBR |
| Zen, Zen 2 | 8 / 0.5FPU1 FPU2 | 1 / 0.5FPU1 FPU2 |
| Zen 3, Zen 4 | 8 / 0.5FP1 FP2 | 1 / 0.5FP1 FP2 |
| Jaguar | 6 / 1FPU0 FPU1 VALU0 VALU1 | 1 / 0.5FPU0 FPU1 VALU0 VALU1 |
Data flow
Where the elements of the sources go, element 0 on the right; results that depend on a control value are drawn for an example. How to read.
Example: imm8 = 0x61 (0110 0001 in binary).
With imm8 = 0x61, result words 3 to 0: a1, a2, a0, a1.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
for i in range(4):
j = imm8 >> 2 * i & 3
mm1.w[i] = src2.w[j]
# x87: TOP = 0, all tags valid, bits 79:64 of mm1's register all onesRun on AMD Zen 5 (EPYC 9645): 2 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
PSHUFW mm, mm/m64, imm8 | ||
mm | explicit | write |
mm/m64 | explicit | read |
imm8 | 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.
- All forms
mmx-mem
Attributes
What else XED records about the forms. How to read.
- All forms
- may abort a TSX transaction
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 |
|---|---|---|
SSE | SSE | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More SSE 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-436 (PSHUFW)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 5: 64-Bit Media and x87 Floating-Point Instructions (26569, rev. 3.16, November 2021), Wayback Machine copy of AMD's PDF
- 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 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.