Extensions
Forms
4 (4 Legacy)
Data
Intel XED v2026.08.23

PSHUFB picks bytes by index. Each byte of the second operand selects which byte of the first operand goes to its position in the result, and a selector with bit 7 set writes zero there instead. Only the low four bits of a selector count (three in the MMX form), so 10h selects byte 0 rather than giving zero. Because the selectors come from a register and not from an immediate, one instruction applies any byte permutation, chosen at run time or loaded from a table. In the intrinsic _mm_shuffle_epi8(a, b), a holds the data and b the selectors.

It turns up in three roles:

  • Fixed rearrangements, with a constant selector vector: reversing the order of the 16 bytes (the byte-order swap of a whole vector, which Intel’s optimization manual uses in a reverse memory copy), gathering the bytes of interest to one end, or spreading them out.
  • Broadcasting a byte. All-zero selectors copy byte 0 everywhere. Compiling for SSSE3, GCC 14 and Clang 23 at -O2 turn _mm_set1_epi8(c) into MOVD, PXOR and PSHUFB; AVX2 has VPBROADCASTB for this.
  • Table lookup. With a table of 16 bytes as the data and values of 0 to 15 as selectors, PSHUFB looks up 16 entries at once. Splitting each byte into its low and high halves (a shift, and an AND with 0Fh) gives two lookups that together cover all 256 byte values; vector bit counting, hexadecimal conversion and character classification can be built this way.

The legacy form with a memory operand needs it aligned to 16 bytes. The VEX and EVEX forms, VPSHUFB, work within each 128-bit lane: a 256-bit shuffle cannot move a byte from one half of the register to the other, and each half needs its own copy of a lookup table. VPERMB of AVX512_VBMI permutes bytes across a whole register.

In the optimization guide

What the optimization guide says about PSHUFB, a line per claim. Each links to the claim in the guide, with its sources and where they differ.

Silvermont to Goldmont Plus

  • Front end: Silvermont decodes SSSE3 and SSE4 instructions that use xmm8 to xmm15 slowly, as they exceed 3 bytes of prefixes and escapes. sources differ
  • Vectors and cryptography: pshufb, pmulld, paddq and psubq are slow on Silvermont and much faster from Goldmont on.

Forms

Every encoding of PSHUFB that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
PSHUFB mm, m64 PSHUFB_MMXq_MEMqNP 0F 38 00 /rSSSE3 + MMX
PSHUFB mm, mm PSHUFB_MMXq_MMXqNP 0F 38 00 /rSSSE3 + MMX
PSHUFB xmm, m128 PSHUFB_XMMdq_MEMdq66 0F 38 00 /rSSSE3
PSHUFB xmm, xmm PSHUFB_XMMdq_XMMdq66 0F 38 00 /rSSSE3

Latency and throughput

What the scheduling models of LLVM 23.1.2 give for each form, not measurements: latency / reciprocal throughput in cycles, the ports under them. A row is a model, or models that agree; a dash, a form that its processors lack. Memory forms: latency from the address, ports without the load and store units. Which processors each model covers.
Modelmm, m64mm, mmxmm, m128xmm, xmm
Sandy Bridge6 / 0.5p151 / 0.5p157 / 0.5p151 / 0.5p15
Haswell6 / 1p51 / 1p57 / 1p51 / 1p5
Broadwell6 / 1p51 / 1p56 / 1p51 / 1p5
Skylake, Skylake-SP6 / 1p051 / 1p057 / 1p51 / 1p5
Ice Lake6 / 1p051 / 1p057 / 0.5p151 / 0.5p15
Alder Lake, Sapphire Rapids11 / 1p053 / 1p058 / 0.5p151 / 0.5p15
Lunar Lake11 / 0.5V0 V1 V2 V33 / 0.5V0 V1 V2 V37 / 2V2 V31 / 0.5V2 V3
Bonnell1 / 1p01 / 1p05 / 4p14 / 3p01
Silvermont4 / 1FPC01 / 1FPC08 / 5FPC05 / 5FPC0
Piledriver8 / 1.5FPU1 FPXBR3 / 1FPU1 FPXBR8 / 1.5FPU1 FPXBR3 / 1FPU1 FPXBR
Zen, Zen 28 / 0.5FPU1 FPU21 / 0.5FPU1 FPU28 / 0.5FPU1 FPU21 / 0.5FPU1 FPU2
Zen 3, Zen 48 / 0.5FP1 FP21 / 0.5FP1 FP28 / 0.5FP1 FP21 / 0.5FP1 FP2
Jaguar7 / 1FPU0 FPU1 VALU0 VALU12 / 0.5FPU0 FPU1 VALU0 VALU17 / 2FPU0 FPU1 VALU0 VALU12 / 2FPU0 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.

Shuffle bytes by index: each byte of the result is the byte of xmm1 that the index byte in the same place numbers, within the lane; an index with bit 7 set gives 0.
PSHUFB with an example index vectorWith the example indices, result bytes 15 to 0: a11, a6, a2, a10, a5, 0, a14, a1, a9, a15, a0, a7, a12, a12, 0, a3.0123567910111214154813xmm1aa3a12a12a7a0a15a9a1a14a5a10a2a6a1100xmm1380CC70F91E805A26Bxmm2index

Example index vector in xmm2 (element 0 on the right, in hex); only its low 4 bits and bit 7 count.

With the example indices, result bytes 15 to 0: a11, a6, a2, a10, a5, 0, a14, a1, a9, a15, a0, a7, a12, a12, 0, a3.

Operation

What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.

PSHUFB mm, mm/m64
src1 = mm1.read()  # mm1 as it was
for i in range(8):
    x = src2.b[i]
    if x & 0x80:
        mm1.b[i] = 0
    else:
        mm1.b[i] = src1.b[x & 7]
# x87: TOP = 0, all tags valid, bits 79:64 of mm1's register all ones

Run on AMD Zen 5 (EPYC 9645): 2 cases.

PSHUFB xmm, xmm/m128
src1 = xmm1.read()  # xmm1 as it was
for i in range(16):
    x = src2.b[i]
    if x & 0x80:
        xmm1.b[i] = 0
    else:
        xmm1.b[i] = src1.b[x & 15]
# bits 128 and up of the register are unchanged

Run on AMD Zen 5 (EPYC 9645): 2 cases.

Operands

What each form reads and writes, as Intel XED records it: the operands of its syntax, in order, and the implicit ones that the syntax does not name. How to read.
OperandKindAction
PSHUFB mm, mm/m64
mmexplicitread, write
mm/m64explicitread
PSHUFB xmm, xmm/m128
xmmexplicitread, write
xmm/m128explicitread

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.

PSHUFB mm, mm/m64
mmx-mem
PSHUFB xmm, xmm/m128
SSE_TYPE_4

Attributes

What else XED records about the forms. How to read.

PSHUFB mm, mm/m64
may abort a TSX transaction
PSHUFB xmm, m128
aligned memory operand

Intrinsics

The C intrinsics of Clang 23.1.2 that compile to PSHUFB, 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.

IntrinsicCompiles to
_mm_shuffle_epi8 __m128i _mm_shuffle_epi8(__m128i __a, __m128i __b)

PSHUFB xmm, xmm Legacy -mssse3

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.

CPUID requirements and processors of the XED ISA sets above. Alternatives are separated by “or”; processors follow XED’s chip model, whose AMD processors end with Zen 2, and the CPU data of this site for Zen 3 to Zen 6.
ISA setCPUIDProcessors
SSSE3MMX

SSSE3 + MMX
CPUID.01H:ECX[9] SSSE3
CPUID.01H:EDX[23] MMX

XED and Intel’s SDM differ: For the forms on MMX registers that SSE2 added (PADDQ, PMULUDQ and PSUBQ) and those of SSSE3, XED also asks for the MMX bit, CPUID.01H:EDX[23], besides SSE2, CPUID.01H:EDX[26], or SSSE3, CPUID.01H:ECX[9]. Revision 093 of Intel’s SDM names SSE2 or SSSE3 alone for these forms.

Sources: Intel XED v2026.08.23, datafiles/cpuid.xed.txt; Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026), PADDQ, PMULUDQ and PSUBQ: the opcode tables, pages 4-201, 4-395 and 4-487; PABSB/PABSW/PABSD/PABSQ and PSHUFB, pages 4-177 and 4-422, and the entries of the other SSSE3 instructions.

Core (Merom, Conroe), Penryn, Nehalem, Westmere, Sandy Bridge, Ivy Bridge, 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, K10 (Family 10h), Bulldozer, Piledriver, Zen, Zen+, Zen 2, Zen 3, Zen 4, Zen 5, Zen 6
SSSE3

SSSE3
CPUID.01H:ECX[9] SSSE3

Same as SSSE3MMX

Note: XED's AMD_K10 inherits everything from its Westmere chip, including SSSE3, SSE4.1, SSE4.2, AES-NI and PCLMULQDQ; GCC's -march=amdfam10 has none of them.

More SSSE3 instructions

Sources

  1. Intel XED v2026.08.23 (commit 0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model.
  2. The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s -march feature sets and AMD’s Processor Programming References, which the page of each processor cites.
  3. 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.
  4. LLVM 23.1.2's x86 scheduling models (commit 85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them.
  5. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-422 (PSHUFB)
  6. 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 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.