Instruction
VMPSADBW
Computes, per 128-bit lane, word sums of absolute differences between a 4-byte block of the second source and eight sliding blocks of the first.
VMPSADBW is the VEX form of SSE4.1’s MPSADBW, whose page covers the eight sliding sums of absolute differences and their use in motion estimation. The VEX encoding takes a separate destination, reads memory at any alignment and clears the register above the vector length; VEX.128 needs AVX and VEX.256 AVX2.
Two lanes, two controls
The ymm form repeats the operation in each 128-bit lane, and each lane
has its own fields in the immediate: bits 2:0 steer the low lane, as in
the xmm form, and bits 5:3 the high lane, so only bits 7:6 are ignored.
On Zen 5, the recorded vmpsadbw ymm8, ymm15, ymm0, 0x2c took the high
lane’s block from its doubleword 1, as bits 4:3 = 01b select, and its
windows from byte 4, as bit 5 selects. With zeros in that block and
bytes 00h to 0Fh in the high lane of YMM15, words 8 to 15 came out as
16h, 1Ah and so on up to 32h, the plain byte sum of each window.
AVX10.2 adds EVEX forms at all three widths, with a write mask per word and a different prefix (F3 rather than 66); the 512-bit form gives its upper two lanes the controls of the lower two. Zen 5 has no AVX10.2, so the probe left them unrun.
In compiled code
In our builds at -O2, _mm_mpsadbw_epu8 and _mm256_mpsadbw_epu8
compile to VMPSADBW in GCC 14 and Clang 23 with -march=x86-64-v3 and
x86-64-v4. Clang 23 also accepts -mavx10.2 and compiles
_mm512_mpsadbw_epu8 and its masked form to the EVEX zmm form; GCC 14
has no such option. The eight sums written as two loops over
fixed-size global arrays are vectorized differently: Clang widens the
windows with VPMOVZXBW and takes each difference
as VPMAXUW minus VPMINUW, and
neither compiler emits VMPSADBW.
AMD’s latency spreadsheet for Zen 5 gives every VEX row a latency of 5 cycles: four macro-ops and one every two cycles for the xmm register form, six and one every three with memory, three and four for the ymm register and memory forms, one every two cycles.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VMPSADBW xmm, xmm, m128, imm8
VMPSADBW_XMMdq_XMMdq_MEMdq_IMMb | VEX.128.66.0F3A.WIG 42 /r ib | AVX |
VMPSADBW xmm, xmm, xmm, imm8
VMPSADBW_XMMdq_XMMdq_XMMdq_IMMb | VEX.128.66.0F3A.WIG 42 /r ib | AVX |
VMPSADBW ymm, ymm, m256, imm8
VMPSADBW_YMMqq_YMMqq_MEMqq_IMMb | VEX.256.66.0F3A.WIG 42 /r ib | AVX2 |
VMPSADBW ymm, ymm, ymm, imm8
VMPSADBW_YMMqq_YMMqq_YMMqq_IMMb | VEX.256.66.0F3A.WIG 42 /r ib | AVX2 |
VMPSADBW xmm {k}{z}, xmm, xmm, imm8
VMPSADBW_XMMu16_MASKmskw_XMMu8_XMMu8_IMM8_AVX512 | EVEX.128.F3.0F3A.W0 42 /r ib | AVX10.2 |
VMPSADBW xmm {k}{z}, xmm, m128, imm8
VMPSADBW_XMMu16_MASKmskw_XMMu8_MEMu8_IMM8_AVX512 | EVEX.128.F3.0F3A.W0 42 /r ib | AVX10.2 |
VMPSADBW ymm {k}{z}, ymm, ymm, imm8
VMPSADBW_YMMu16_MASKmskw_YMMu8_YMMu8_IMM8_AVX512 | EVEX.256.F3.0F3A.W0 42 /r ib | AVX10.2 |
VMPSADBW ymm {k}{z}, ymm, m256, imm8
VMPSADBW_YMMu16_MASKmskw_YMMu8_MEMu8_IMM8_AVX512 | EVEX.256.F3.0F3A.W0 42 /r ib | AVX10.2 |
VMPSADBW zmm {k}{z}, zmm, zmm, imm8
VMPSADBW_ZMMu16_MASKmskw_ZMMu8_ZMMu8_IMM8_AVX512 | EVEX.512.F3.0F3A.W0 42 /r ib | AVX10.2 |
VMPSADBW zmm {k}{z}, zmm, m512, imm8
VMPSADBW_ZMMu16_MASKmskw_ZMMu8_MEMu8_IMM8_AVX512 | EVEX.512.F3.0F3A.W0 42 /r ib | AVX10.2 |
Latency and throughput
| Model | xmm, xmm, m128, imm8 | xmm, xmm, xmm, imm8ymm, ymm, ymm, imm8 | ymm, ymm, m256, imm8 |
|---|---|---|---|
| Sandy Bridge | 13 / 1p015 | 7 / 1p015 | |
| Haswell | 13 / 2p05 | 7 / 2p05 | 14 / 2p05 |
| Broadwell | 12 / 2p05 | 7 / 2p05 | 13 / 2p05 |
| Skylake, Skylake-SP | 10 / 2p5 | 4 / 2p5 | 11 / 2p5 |
| Ice Lake | 10 / 1p15 | 4 / 1p15 | 11 / 1p15 |
| Alder Lake, Sapphire Rapids | 11 / 1p15 | 4 / 1p15 | 12 / 1p15 |
| Lunar Lake | 11 / 1V2 V3 | 4 / 1V2 V3 | 12 / 1V2 V3 |
| Piledriver | 14 / 4FPMMA FPU0 | 8 / 4FPMMA FPU0 | |
| Zen, Zen 2 | 100 / 0.25 | 100 / 0.25 | 100 / 0.25 |
| Zen 3, Zen 4 | 11 / 2FP0 FP1 FP2 FP3 | 4 / 2FP0 FP1 FP2 FP3 | 11 / 2FP0 FP1 FP2 FP3 |
| Jaguar | 8 / 2FPU0 VIMUL | 3 / 2FPU0 VIMUL |
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 = 0x06: the windows from byte 4, the block doubleword 2. The sources are drawn in doublewords, with a tick between bytes; each bar under xmm2 is a window, joined to the word it makes. The ymm and zmm forms do the same in each 128-bit lane, with imm8[5:3] for lanes 1 and 3. The EVEX forms write under a mask: where its bit is 0, the element keeps its old value, or zeroes it with {z}.
With imm8 = 0x06, result word i is the sum of the absolute differences between bytes 4+i to 7+i of xmm2 and bytes 8 to 11 of xmm3, byte by byte. Result words 7 to 0: r7, unchanged (bit 6 of k1 is 0), r5, r4, r3, r2, r1, r0.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
for l in range(VL // 128): # each 128-bit lane
c = imm8 >> 3 * l # lane 1: imm8[5:3]
p = 16 * l + 4 * (c >> 2 & 1) # the windows of ymm2
q = 16 * l + 4 * (c & 3) # the block of src3
for i in range(8):
s = 0
for j in range(4):
x = ymm2.b[p + i + j]
s += abs(x - src3.b[q + j])
ymm1.w[8 * l + i] = s
# imm8[7:6] are ignored, and imm8[5:3] by the xmm forms
# ymm1 is zeroed from bit VL upRun on AMD Zen 5 (EPYC 9645): 8 cases.
for l in range(VL // 128): # each 128-bit lane
c = imm8 >> 3 * (l % 2) # lanes 1, 3: imm8[5:3]
p = 16 * l + 4 * (c >> 2 & 1) # the windows of zmm2
q = 16 * l + 4 * (c & 3) # the block of src3
for i in range(8):
s = 0
for j in range(4):
x = zmm2.b[p + i + j]
s += abs(x - src3.b[q + j])
if k1[8 * l + i]: # 1 without a write mask
zmm1.w[8 * l + i] = s
elif zeroing:
zmm1.w[8 * l + i] = 0
# else: the word keeps its value
# imm8[7:6] are ignored
# src3 is read whatever the mask: a fault in it is not
# suppressed
# zmm1 is zeroed from bit VL upNot run on a processor: none of these processors has AVX10.2.
Operands
| Operand | Kind | Action |
|---|---|---|
VMPSADBW xmm, xmm, xmm/m128, imm8 VMPSADBW ymm, ymm, ymm/m256, imm8 | ||
xmm, ymm | explicit | write |
xmm, ymm | explicit | read |
xmm/m128, ymm/m256 | explicit | read |
imm8 | explicit | read |
VMPSADBW xmm {k}{z}, xmm, xmm/m128, imm8 VMPSADBW ymm {k}{z}, ymm, ymm/m256, imm8 VMPSADBW zmm {k}{z}, zmm, zmm/m512, imm8 | ||
xmm, ymm, zmm | explicit | write (masked) |
{k} | explicit | read (write mask) |
xmm, ymm, zmm | explicit | read |
xmm/m128, ymm/m256, zmm/m512 | 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.
- VEX forms
avx-type-4- EVEX forms
AVX512-E4NF
Attributes
What else XED records about the forms. How to read.
- EVEX forms
- write masking
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VMPSADBW, 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 |
|---|---|
_mm_mpsadbw_epu8
__m128i _mm_mpsadbw_epu8(__m128i X, __m128i Y, const int M) |
|
_mm_mask_mpsadbw_epu8
__m128i _mm_mask_mpsadbw_epu8(__m128i W, __mmask8 U, __m128i A, __m128i B, const int imm) |
|
_mm_maskz_mpsadbw_epu8
__m128i _mm_maskz_mpsadbw_epu8(__mmask8 U, __m128i A, __m128i B, const int imm) |
|
_mm256_mpsadbw_epu8
__m256i _mm256_mpsadbw_epu8(__m256i X, __m256i Y, const int M) |
|
_mm256_mask_mpsadbw_epu8
__m256i _mm256_mask_mpsadbw_epu8(__m256i W, __mmask16 U, __m256i A, __m256i B, const int imm) |
|
_mm256_maskz_mpsadbw_epu8
__m256i _mm256_maskz_mpsadbw_epu8(__mmask16 U, __m256i A, __m256i B, const int imm) |
|
_mm512_mpsadbw_epu8
__m512i _mm512_mpsadbw_epu8(__m512i A, __m512i B, const int imm) |
|
_mm512_mask_mpsadbw_epu8
__m512i _mm512_mask_mpsadbw_epu8(__m512i W, __mmask32 U, __m512i A, __m512i B, const int imm) |
|
_mm512_maskz_mpsadbw_epu8
__m512i _mm512_maskz_mpsadbw_epu8(__mmask32 U, __m512i A, __m512i B, const int imm) |
|
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.
More AVX instructions
- VMOVDQU
- VMOVHLPS
- VMOVHPD
- VMOVHPS
- VMOVLHPS
- VMOVLPD
- VMOVLPS
- VMOVMSKPD
- VMOVMSKPS
- VMOVNTDQ
- VMOVNTDQA
- VMOVNTPD
- VMOVNTPS
- VMOVQ
- VMOVSD
- VMOVSHDUP
- VMOVSLDUP
- VMOVSS
- VMOVUPD
- VMOVUPS
- VMULPD
- VMULPS
- VMULSD
- VMULSS
- VORPD
- VORPS
- VPABSB
- VPABSD
- VPABSW
- VPACKSSDW
- VPACKSSWB
- VPACKUSDW
- VPACKUSWB
- VPADDB
- VPADDD
- VPADDQ
- VPADDSB
- VPADDSW
- VPADDUSB
- VPADDUSW
More AVX2 instructions
- VBROADCASTI128
- VBROADCASTSD
- VBROADCASTSS
- VEXTRACTI128
- VGATHERDPD
- VGATHERDPS
- VGATHERQPD
- VGATHERQPS
- VINSERTI128
- VMOVNTDQA
- VPABSB
- VPABSD
- VPABSW
- VPACKSSDW
- VPACKSSWB
- VPACKUSDW
- VPACKUSWB
- VPADDB
- VPADDD
- VPADDQ
- VPADDSB
- VPADDSW
- VPADDUSB
- VPADDUSW
- VPADDW
- VPALIGNR
- VPAND
- VPANDN
- VPAVGB
- VPAVGW
- VPBLENDD
- VPBLENDVB
- VPBLENDW
- VPBROADCASTB
- VPBROADCASTD
- VPBROADCASTQ
- VPBROADCASTW
- VPCMPEQB
- VPCMPEQD
- VPCMPEQQ
More AVX10.2 instructions
- VFNMADD132BF16
- VFNMADD213BF16
- VFNMADD231BF16
- VFNMSUB132BF16
- VFNMSUB213BF16
- VFNMSUB231BF16
- VFPCLASSBF16
- VGETEXPBF16
- VGETMANTBF16
- VMAXBF16
- VMINBF16
- VMINMAXBF16
- VMINMAXPD
- VMINMAXPH
- VMINMAXPS
- VMINMAXSD
- VMINMAXSH
- VMINMAXSS
- VMOVD
- VMOVW
- VMULBF16
- VPDPBSSD
- VPDPBSSDS
- VPDPBSUD
- VPDPBSUDS
- VPDPBUUD
- VPDPBUUDS
- VPDPWSUD
- VPDPWSUDS
- VPDPWUSD
- VPDPWUSDS
- VPDPWUUD
- VPDPWUUDS
- VRCPBF16
- VREDUCEBF16
- VRNDSCALEBF16
- VRSQRTBF16
- VSCALEFBF16
- VSQRTBF16
- VSUBBF16
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-132 (MPSADBW)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- Intel Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 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.