Notes
- The destination is always an even/odd pair of opmask registers. The ModR/M
reg field names one of them; its low bit is ignored, so the even register gets src1's matches and the next one src2's.
- There is no write-mask and no
{z}: every element pair is compared, and both mask registers are fully overwritten — bits above the element count are zeroed.
- Every element of src1 is compared with every element of src2 — across 128-bit lanes, unlike most shuffles and unpacks. That is N² comparisons (256 for
VP2INTERSECTD zmm).
- Duplicates only matter as booleans: an element matching three times still sets one bit. To count or pair up matches you need something else, e.g. a
VPCMPEQD of src1 against each broadcast element of src2.
- Typical use: intersecting two sorted ID lists 16 at a time —
VPCOMPRESSD with the even mask extracts the common elements from src1.
- As of 2026 it has shipped on Intel Tiger Lake only (later Intel cores dropped it) and on AMD Zen 5. Check
CPUID.(EAX=07H, ECX=0):EDX[8] before using it.