Instruction
VPCMPISTRI
Compares two zero-terminated strings in XMM registers as an immediate says, returning an index in ECX; VEX form.
- Extensions
- Forms
- 4 (4 VEX)
- Data
- Intel XED v2026.08.23
VPCMPISTRI is the VEX encoding of SSE4.2’s PCMPISTRI, whose page covers the control byte, the four comparisons, the flags and the traps. The VEX form changes little: it needs AVX, exists only at 128 bits (both vendors raise #UD for VEX.L = 1 or a VEX.vvvv other than 1111b), reads memory at any alignment as the legacy form already does, and writes only ECX and the flags, so there is no destination register to clear. There is no EVEX form. VEX.W is ignored: on Zen 5, the recorded W1 encoding, which XED calls VPCMPISTRI64, returned the same index as the W0 one, 14 for the highest equal-ordered match of “abc” in “xxabcxxxxxxxxxab”.
In compiled code
With -march=x86-64-v3 or x86-64-v4, every _mm_cmpistri in our
builds at -O2 becomes VPCMPISTRI in GCC 14 and Clang 23, with an
unaligned _mm_loadu_si128 of the text folded into the memory
operand. In a loop that also tests _mm_cmpistrz, GCC follows each
VPCMPISTRI with a VPCMPISTRM for ZF and Clang runs
VPCMPISTRI twice, as for the legacy form.
AMD’s latency spreadsheet for Zen 5 gives the VEX row the legacy row’s figures, four macro-ops and one every two cycles, without a latency. VPCMPESTRI takes the lengths from EAX and EDX.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VPCMPISTRI xmm, m128, imm8
VPCMPISTRI_XMMdq_MEMdq_IMMb | VEX.128.66.0F3A.W0 63 /r ib | AVX |
VPCMPISTRI xmm, xmm, imm8
VPCMPISTRI_XMMdq_XMMdq_IMMb | VEX.128.66.0F3A.W0 63 /r ib | AVX |
VPCMPISTRI xmm, m128, imm8 64-bit mode only
VPCMPISTRI64_XMMdq_MEMdq_IMMb | VEX.128.66.0F3A.W1 63 /r ib | AVX |
VPCMPISTRI xmm, xmm, imm8 64-bit mode only
VPCMPISTRI64_XMMdq_XMMdq_IMMb | VEX.128.66.0F3A.W1 63 /r ib | AVX |
Latency and throughput
| Model | xmm, m128, imm8 | xmm, xmm, imm8 |
|---|---|---|
| Sandy Bridge, Haswell | 17 / 3p0 | 11 / 3p0 |
| Broadwell | 16 / 3p0 | 11 / 3p0 |
| Skylake, Skylake-SP, Ice Lake | 16 / 3p0 | 10 / 3p0 |
| Alder Lake, Sapphire Rapids, Lunar Lake | 31 / 3p0 | 11 / 3p0 |
| Piledriver | 16 / 3EX0 FPFMA FPU1 | 11 / 3EX0 FPFMA FPU1 |
| Zen, Zen 2 | 100 / 0.25 | 100 / 0.25 |
| Zen 3, Zen 4 | 9 / 2FP0 FP1 FP2 FP3 | 2 / 2FP0 FP1 FP2 FP3 |
| Jaguar | 12 / 2ALU0 FPA FPU0 FPU1 VALU1 | 7 / 2ALU0 FPA FPU0 FPU1 VALU1 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
n = 8 if imm8 & 1 else 16 # words, bytes
w = 128 // n # bits each
m = (1 << w) - 1
k = 1 << w - 1 if imm8 & 2 else 0 # signed
a = xmm1.read()
b = src2.read()
la = lb = n # lengths: up to the
for i in range(n): # first null element
if a >> w * i & m == 0 and la == n:
la = i
if b >> w * i & m == 0 and lb == n:
lb = i
agg = imm8 >> 2 & 3
# (v >> w * i & m ^ k) - k: element i of v,
# sign-extended where k is its sign bit
r = 0
for j in range(n): # bit j: src2's
y = (b >> w * j & m ^ k) - k # element j
bit = 0
if agg == 0: # equal any: y is
for i in range(la): # in xmm1
x = (a >> w * i & m ^ k) - k
if j < lb and x == y:
bit = 1
elif agg == 1: # ranges: y is in
for i in range(0, la - 1, 2):
t = w * i # a pair's range
lo = (a >> t & m ^ k) - k
hi = (a >> t + w & m ^ k) - k
if j < lb and lo <= y <= hi:
bit = 1
elif agg == 2: # equal each
x = (a >> w * j & m ^ k) - k
if j < la and j < lb:
bit = x == y
else: # 1 past both ends
bit = j >= la and j >= lb
else: # equal ordered: xmm1
bit = 1 # from element j on;
# what would fall past the end of the
# register matches, and an empty xmm1
# everywhere, as in Intel's manual
# (AMD's clears these bits)
for i in range(min(la, n - j)):
x = (a >> w * i & m ^ k) - k
u = j + i
z = (b >> w * u & m ^ k) - k
if u >= lb or x != z:
bit = 0
r |= bit << j
p = imm8 >> 4 & 3
if p == 1: # negated
r ^= (1 << n) - 1
elif p == 3: # negated within src2
r ^= (1 << lb) - 1
idx = n # none set
for j in range(n): # imm8[6]: the
if r >> j & 1: # highest set bit,
if imm8 & 0x40 or idx == n:
idx = j # else the lowest
ecx = idx # bits 63:32 cleared
cf = r != 0
zf = lb < n # src2 is short
sf = la < n # xmm1 is short
of = r & 1
af = pf = 0Run on AMD Zen 5 (EPYC 9645): 6 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VPCMPISTRI xmm, xmm/m128, imm8 | ||
xmm | explicit | read |
xmm/m128 | explicit | read |
imm8 | explicit | read |
rCX | implicit | write |
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| M | M | M | 0 | 0 | M |
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- All forms
avx-type-4
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VPCMPISTRI, 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_cmpistra
int _mm_cmpistra(__m128i A, __m128i B, const int M) |
|
_mm_cmpistrc
int _mm_cmpistrc(__m128i A, __m128i B, const int M) |
|
_mm_cmpistri
int _mm_cmpistri(__m128i A, __m128i B, const int M) |
|
_mm_cmpistro
int _mm_cmpistro(__m128i A, __m128i B, const int M) |
|
_mm_cmpistrs
int _mm_cmpistrs(__m128i A, __m128i B, const int M) |
|
_mm_cmpistrz
int _mm_cmpistrz(__m128i A, __m128i B, const int M) |
|
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 |
|---|---|---|
AVX | AVX | 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, Sierra Forest, Clearwater Forest, Knights Landing, Knights Mill, Bulldozer, Piledriver, Zen, Zen+, Zen 2, Zen 3, Zen 4, Zen 5, Zen 6 |
More AVX instructions
- VPADDUSW
- VPADDW
- VPALIGNR
- VPAND
- VPANDN
- VPAVGB
- VPAVGW
- VPBLENDVB
- VPBLENDW
- VPCLMULQDQ
- VPCMPEQB
- VPCMPEQD
- VPCMPEQQ
- VPCMPEQW
- VPCMPESTRI
- VPCMPESTRM
- VPCMPGTB
- VPCMPGTD
- VPCMPGTQ
- VPCMPGTW
- VPCMPISTRM
- VPERM2F128
- VPERMILPD
- VPERMILPS
- VPEXTRB
- VPEXTRD
- VPEXTRQ
- VPEXTRW
- VPHADDD
- VPHADDSW
- VPHADDW
- VPHMINPOSUW
- VPHSUBD
- VPHSUBSW
- VPHSUBW
- VPINSRB
- VPINSRD
- VPINSRQ
- VPINSRW
- VPMADDUBSW
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-267 (PCMPISTRI)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 4: 128-Bit, 256-Bit, and 512-Bit Media Instructions (26568, rev. 3.27, July 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.