cpu: lower 256-bit saturating add and subtract in AVX translator #1375
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1382"
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 tedin7 on 2026-11-24T10:02:17Z.
What
tools/cpu_avx_int_aot.pynow lowers the eight VEX.256 register formsvpaddsb,vpaddsw,vpaddusb,vpaddusw,vpsubsb,vpsubsw,vpsubusb,vpsubuswthrough the existing two-halfwide128path, reusing the 128-bit helpers. Subtract computes first source minus second source.op_vpaddswis new and serves only the 256-bit form: the 128-bitvpaddswis owned bycpu_vex_aot.pyand stays rejected here (same pattern asvpaddw,vpaddd,vpsubw).tests/cpu/avx_int_ymm_sat.{asm,def}, checkavx_int_ymm_sat_check.py, CMake testcpu_aot_avx_int_ymm_sat(same registration and AVX2 skip as the min/max test),form_coverage.pyentry.avx_int_regs_check.py(translation level and PE-patched) andavx_int_ymm_addsub_check.pynamedvpaddsb; they now namevpackusdw(regs check) andvpmulhuw(addsub check), both still unsupported.docs/experiments.mddocuments the new form.Why
The 256-bit saturating forms were the next gap in the AVX2 integer family after add, subtract, compare, min, max, abs and sign. Every 128-bit helper already existed, so the lift is the same two-half dispatch with eight new table entries.
Tested
Windows (not run locally):
Ran on Linux:
vpaddsw); no open PR touches these files.llvm-ml-19and linked withlld-link-19(this also validates the MASM syntax). The realtranslate()ran on it. The C++ was built with MinGW GCC at -O0 and -O2, and native and lifted DLLs ran under Wine through a throwaway loader: 18 exports x 362 inputs matched the independent model bit for bit at both levels.vpaddsbreplaced by wrappingvpaddb,vpadduswreplaced by signedvpaddsw) each failed on exactly their own export.check_translator()of the four ymm checks andcheck_rejections()ofavx_int_regs_check.py(on an LLVM-built PE) pass;tests/form_coverage_check.py,docs_links_check.py,bidi_controls_check.py,py_compileandgit diff --checkpass.op_vpaddswhelper in the shared prelude.MSVC/ML64 was NOT run locally, and the check script itself was not run end to end (it loads the DLLs with ctypes, which needs Windows); the loader above stood in for it.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T10:07:05Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit
f5c0be11d5cbde7f471f90505b5d0950e3d86475:tests/form_coverage_check.pyok (40.5s)--preset dev):cpu_avx_int_ymm_sat*,cpu_avx_int_regs_*):3.46s(configure1.61s)ctest --preset dev -R '^(cpu_aot_avx_int_ymm_sat|cpu_aot_avx_int_regs)$' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (cpu_aot_avx_int_regs0.26s,cpu_aot_avx_int_ymm_sat0.30s)/O2(--preset release):cpu_avx_int_ymm_sat*,cpu_avx_int_regs_*):1.57s(configure1.68s)ctest --preset release -R '^(cpu_aot_avx_int_ymm_sat|cpu_aot_avx_int_regs)$' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (cpu_aot_avx_int_regs0.25s,cpu_aot_avx_int_ymm_sat0.30s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T10:07:17Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
f5c0be1ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.