Pin pcmpstr length-15 boundaries, unsigned singleton ranges and scale-1 indexing #975
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/982"
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 Leyukaka on 2026-11-23T19:47:24Z.
Change
This adds four inputs to
tests/cpu/avx_pcmpstr.pythat close five gaps in the test coverage oftools/cpu_avx_pcmpstr_aot.py. Each gap is a small mutation of the translator that passescpu_aot_avx_pcmpstronmain. The native fixture DLL stays the reference; the translator does not change.(1, 15)mag < limit->mag < limit - 1u"A" * 15 + "\x00"on both sideslen1 < limit - 1u[10, 10]and first B word 10vpcmpistrm_uw_ranges_mpos_bit)vpcmpistri xmm1, [rdx+rcx*1], 0The singleton range only catches a translator that special-cases equal bounds in unsigned ranges: inclusive bounds were already pinned by the existing word pairs, and the signed-byte ranges export already meets an equal-bounds range. The scale-1 control takes the same rejection branch as the existing
[rdx+rcx*4]control; it guards against a future change that would accept scale 1. With the new inputs, the check runs 1,274 differential cases and 32 unit rejection controls;docs/experiments.mdis updated to those counts (it said 1,028 and 30).Verification
On
d62e61f(based onmainat23d2e93), Windows 11 build 26300, MSVC 14.44.35207, Python 3.14:The test passes and prints
1274 VEX.128 AVX packed string compare cases across 22 exports matched native and referenceand32 unit rejection controls and 5 PE-patched rejection controls passed. The docs check passes.Each mutation was applied to
tools/cpu_avx_pcmpstr_aot.pyone at a time, the project was rebuilt so the translation was regenerated, andcpu_aot_avx_pcmpstrwas run with themainand the branch versions ofavx_pcmpstr.py. With the unmutated translator both pass. Onmain, the test passed under all five mutations; on this branch it fails under each of them.The five edits to
tools/cpu_avx_pcmpstr_aot.py:return mag < limit ? mag : limit;->return mag < limit - 1u ? mag : limit;while (len2 < limit && pcmp_elem(b, len2, is_word, is_signed) != 0) ++len2;->while (len2 < limit - 1u && ...) ++len2;followed byif (len2 == limit - 1u) ++len2;if (!is_signed && pcmp_elem(a, j, ...) == pcmp_elem(a, j + 1u, ...)) continue;len1 < limit->len1 < limit - 1uin theFlagsinitializer (SF)or ins.memory_index != R.NONE->or (ins.memory_index != R.NONE and ins.memory_index_scale != 1)Checklist
AI-assisted.