cpu: lift VEX.128 shifts with XMM or memory count #1334
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1341"
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-24T08:37:56Z.
What
tools/cpu_vex_aot.pyliftsvpsraw,vpsllwandvpsrlwwhen the count is an XMM register or a flat 16-byte memory operand ([rcx],[rdx],[r8]), in addition to the existing imm8 form. New C++ helpershift_countreads the low 64 bits of the count operand as one unsigned integer and saturates it to 16 before the existing shift helpers run, so no bit of the quadword is lost (2^32 and 2^32 + 1 clear a logical shift and fillvpsrawwith the sign). The upper quadword is ignored. The memory form is one 16-byte load, as for the other sources.tests/cpu/vex_words.asm/.defand the export list inCMakeLists.txt: six new functionssraw_count_reg,sraw_count_mem,sllw_count_reg,sllw_count_mem,srlw_count_reg,srlw_count_mem.tests/cpu/vex_words_check.py: the new functions join the shared native vs lifted loops (4096 pairs, guards, aliasing, RCX == RDX, misaligned). A dedicated check runs 56 low counts (0 to 39, 255, 0xffff, 0x10000, 0x7fffffff, 0x80000000, 0xffffffff, 2^32, 2^32 + 1, 2^32 + 15, 2^33 + 3, 2^48, 2^63, 2^64 - 1 and more) with four upper quadwords over 48 inputs (10752 cases per function) against an independent per-lane integer model, native and lifted. It also asserts that the model of a count truncated to 32 bits differs from the correct model.vpsraw xmm0,xmm1,xmm2is replaced byvpsllw ymm0,ymm1,xmm2(VEX.256), counts at[rbx]and[rcx+8],vpsrad(still unsupported) and avpsllwwith an undefined count register.docs/experiments.md: supported forms, count semantics, test description, controls.Why
These count forms were rejected as unsupported. The count semantics are those of the integer instructions: low quadword only, unsigned, saturating above 15. A narrower count type would turn 2^32 into 0 and silently change results. VEX.128 zeroes the upper YMM bits, which the profile never reads (unchanged).
Tested
Windows (not run locally):
and the same with
--preset release. MSVC/ML64 was NOT run locally: the MASM source is unassembled until CI.Linux (this branch, rebased on origin/main):
cpu_vex_aot.translate(), and the lifted C++ compiled with g++ at -O0 and -O2. The unmodifiedvex_words_check.py main()ran on Linux (AVX2 host) with the GNU as builds as native and the lifted shared objects, with only the library loader substituted: all checks passed at -O0 and -O2, including the 10752 count cases per function.python3 -m py_compileon the touched Python,check_rejected_encodings()(13 encodings),tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check; a scan found no local invex_words_check.pythat shadows a module name.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T08:46:36Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207) at commit
45e246e5(head of PR):--preset dev):cpu_vex_words_original,cpu_vex_words_original_lifted,cpu_vex_words_altered,cpu_vex_words_altered_lifted): PASSctest --preset dev -R '^cpu_aot_vex_words$' --no-tests=error --output-on-failure): 1/1 passed (2.39s)/O2(--preset release):cpu_vex_words_*):0.88s(configure1.59s)ctest --preset release -R '^cpu_aot_vex_words$' --no-tests=error --output-on-failure): 1/1 passed (2.28s)Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T08:46:48Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
45e246eℹ️ 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.