cpu: lower AVX VEX.128 packed string compare instructions #946
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/953"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-23T18:33:34Z.
Change
Adds standalone VEX.128 (
W=0) AVX packed string compare lowering intools/cpu_avx_pcmpstr_aot.pyand source-built differential tests intests/cpu/avx_pcmpstr.{asm,def,py}(cpu_aot_avx_pcmpstr) covering four uncoveredAVXmnemonics indocs/coverage/x64_zen2.tsv:vpcmpestri,vpcmpestrm,vpcmpistri,vpcmpistrm(bothxmmand flatm128second operands)Key modeled behaviors and explicit rejections:
vpcmpestrmandvpcmpistrmwrite the 128-bit mask toXMM0and zeroYMM0[255:128]per VEX.128 semantics.vpcmpestriandvpcmpistrizero-extend the 32-bitECXindex intoRCX.vpcmpestriandvpcmpestrmread only the low 32 bits ofRAXandRDXas signed lengths.AFandPFand updateCF,ZF,SF, andOFper the Intel SDM.VEX.256(L=1),VEX.W=1(vpcmpestri64,vpcmpestrm64), EVEX, legacy SSE4.2pcmp*str*, nonvolatile vector/GPR registers, writes tor8, reads through clobbered pointers, unsupported memory operands, prefixes, branches, undefined registers/flags, missingret, and unreachable instructions afterret.Verification
cpu_avx_pcmpstr_original,cpu_avx_pcmpstr_original_lifted,cpu_avx_pcmpstr_altered, andcpu_avx_pcmpstr_altered_liftedin bothdev(Debug) andrelease(/O2) presets with 0 errors and 0 warnings.ctest --preset dev --no-tests=error -R "^cpu_aot_(avx_pcmpstr|avx_horiz_fp|avx2_regs|avx_int_regs|avx_move_regs|sse41_42_misc)$" -V: 6/6 passed (cpu_aot_avx_pcmpstr:1028 VEX.128 AVX packed string compare cases across 22 exports matched native and reference; ALTER_IMM diverged on {'vpcmpestri_ub_eqany_pos_lsb': 72, 'vpcmpestrm_sb_ranges_neg_exp': 87, 'vpcmpistri_ub_eqord_pos_lsb': 3, 'vpcmpistrm_sw_eqany_mneg_exp': 4}; output mutation control caughtand30 unit rejection controls and 5 PE-patched rejection controls passed).ctest --preset release --no-tests=error -R "^cpu_aot_(avx_pcmpstr|avx_horiz_fp|avx2_regs|avx_int_regs|avx_move_regs|sse41_42_misc)$" -V: 6/6 passed (cpu_aot_avx_pcmpstr: 1,028 cases + 4ALTER_IMM+ 1 mutation + 30 unit + 5 PE-patched controls passed)..\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: passed..\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py: passed (13 Markdown files, 191 links)..\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py: passed (778 tracked files).Evidence and follow-up
tests/cpu/avx_pcmpstr.asm) and Python test/reference script (tests/cpu/avx_pcmpstr.py) submitted under the repository MIT license; no external binaries, dumps, or title assets used.cpu_aot_avx_pcmpstrusesSKIP_RETURN_CODE 77when CPUID/XCR0 indicates the host lacks AVX; all checks above executed and passed on an AVX-capable Windows x64 host.VEX.W=164-bit length variants (vpcmpestri64,vpcmpestrm64) remain out of scope.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T18:49:53Z.
I reproduced an optimized-build mismatch with a source-built VPCMPISTRM whose mask and flags are discarded. On the original branch, the native call faults on the unreadable memory source and the lifted call reaches the second store. The updated branch retains the guest read. Both versions now fault between the same two stores, and both complete the valid-buffer control. I also added a RET-only refusal so the uint64 return cannot come from the lowerer's initial RAX placeholder. The existing 1,028 comparisons and mutation controls still pass in both Windows presets.