cpu: lower VEX.256 YMM VPMULDQ, VPMULUDQ, VPMULHRSW, and VPSADBW in cpu_avx_int_aot #2109
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2117"
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-25T00:47:27Z.
Change
Enable VEX.256 (
L=1, AVX2, register-onlyYMM0..YMM5) lowering forvpmuldq,vpmuludq,vpmulhrsw, andvpsadbwintools/cpu_avx_int_aot.py, and add a source-built differential fixture and CTest (cpu_aot_avx_int_ymm_mul_sad):vpmuldq,vpmuludq,vpmulhrsw, andvpsadbwinWIDE_BINARY_HELPERSandWIDE_BINARY_CODESso each 128-bit lane ([127:0]and[255:128]) runs independently through the existing portable 128-bit helpers viawide128.host_has_avx2()under_MSC_VER(checkingCPUID.01H:ECX[27:28],_xgetbv(0) & 6 == 6,CPUID.00H:EAX >= 7, andCPUID.07H.0:EBX[5]) so native differential tests skip cleanly (exit 77) on non-AVX2 hosts while still running AOT lowering and rejection checks.tests/cpu/avx_int_ymm_mul_sad.asm(registered; coverage: source cpu_aot_avx_int_ymm_mul_sad),tests/cpu/avx_int_ymm_mul_sad.def, differential harnesstests/cpu/avx_int_ymm_mul_sad_check.py, and CMake targets/testcpu_aot_avx_int_ymm_mul_sadwithSKIP_RETURN_CODE 77andFORM_COVERAGE_RECORD.Verification
Commit:
53f15645(based onupstream/main3ebc3523).cmake --preset dev && cmake --build --preset dev --target cpu_avx_int_ymm_addsub cpu_avx_int_ymm_addsub_lifted cpu_avx_int_ymm_minmax cpu_avx_int_ymm_minmax_lifted cpu_avx_int_ymm_sat cpu_avx_int_ymm_sat_lifted cpu_avx_int_ymm_abs_sign_shuf cpu_avx_int_ymm_abs_sign_shuf_lifted cpu_avx_int_ymm_mul_sad_original cpu_avx_int_ymm_mul_sad_original_lifted cpu_avx_int_ymm_mul_sad_altered cpu_avx_int_ymm_mul_sad_altered_lifted-> exit0, 0 errors, 0 warnings.cmake --preset release && cmake --build --preset release --target ...(same 12 targets) -> exit0, 0 errors, 0 warnings.ctest --preset dev --no-tests=error -R "^cpu_aot_avx_int_ymm" -E "cpu_native_archive_" -V->5/5 Passed(0 capability skips).ctest --preset release --no-tests=error -R "^cpu_aot_avx_int_ymm" -E "cpu_native_archive_" -V->5/5 Passed(cpu_aot_avx_int_ymm_mul_sad0.28s; 0 capability skips).FORM_COVERAGE_RECORD(devandrelease) ->ret,vmovdqu,vpmuldq,vpmulhrsw,vpmuludq,vpsadbw,vzeroupper.out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py-> exit0(form coverage checks passed).out/pe-env/Scripts/python.exe -B tests/docs_links_check.py-> exit0.out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py-> exit0.VPMULDQfromWIDE_BINARY_CODES, disabling them256memory-operand rejection guard inlift_code(), and dropping+ 0x4000rounding inop_vpmulhrsweach causedctest --preset dev -R "^cpu_aot_avx_int_ymm_mul_sad$"to fail (exit8).No capability skips (exit 77) observed on this AVX2-capable host.
Evidence and follow-up
tests/cpu/avx_int_ymm_mul_sad.asmandtests/cpu/avx_int_ymm_mul_sad.defare source-built MASM fixtures authored directly in this repository under the MIT license. The harness validates 10 exports (including destination aliasing,YMM -> XMMupper-lane zero-extension, and chained ops) over 1840 native/lifted/reference cases with unaligned-buffer guard checks, 14 rejection controls (m256memory operands, EVEX, nonvolatileYMM6..15, undefined sources, missingret, carved-out 128-bit forms), 5 faulty reference mutants, and 4ALTER_YMMbuild controls.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:05:38Z.
Review: COMMENTED
Review of head
53f15645e45b5311ed669fdf446ef8a4d9f9e438(PR #2117).Verdict: no blocking findings. P1=0, P2=0.
Checked:
git diff --stat origin/main...HEAD: 5 files, +491. Touchestools/cpu_avx_int_aot.py,CMakeLists.txt, and the new fixture,.defand check script.wide128is correct for all four ops.op_vpmuldqandop_vpmuludqmultiply dwords 0 and 2 into two qwords.op_vpmulhrswcomputes(a*b + 0x4000) >> 15, keeping the low 16 bits.op_vpsadbwproduces two 16-bit sums in the low bits of each qword.avx_int_ymm_mul_sad_check.pyis written independently of the C++ helpers (struct-based).drop_roundfor vpmulhrsw, and altered-build controls.SKIP_RETURN_CODE 77follow the siblingcpu_avx_int_ymm_*tests.FORM_COVERAGE_RECORDis set.Build and test on Windowspass,Run platform-independent Python checks on Linuxpass, andAssemble and translate gfx1013 fixturespass. The O2 job and the chart job were skipped. Mergeable state was UNKNOWN at review time.Commands run locally, in the PR worktree:
python3 tests/docs_links_check.py-> self-test passed; 18 Markdown files and 395 links checked.python3 tests/bidi_controls_check.py-> 1427 files checked, no bidirectional controls.git diff --check origin/main...HEAD-> clean.Not run locally:
iced_x86/pefile. Neither is available on this Linux host (iced_x86is missing), so the test can't run here.Nits (non-blocking):
host_has_avx2()is now exported from the sharedPRELUDEunder_MSC_VER, so it ends up in every AOT output. Sibling tests define their own copy in Python (avx_int_ymm_minmax_check.py:152,avx_int_ymm_sat_check.py:177). Consider reusing the exported symbol across those tests in a follow-up. This is a cleanup only.AI-assisted; commands listed were executed locally.