cpu: lower AVX2 integer broadcasts and variable per-lane shifts #334
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/339"
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 Vonsek on 2026-11-21T22:41:05Z.
Change
vpbroadcastb,vpbroadcastw,vpbroadcastd,vpbroadcastq) and variable per-lane vector shifts (vpsllvd,vpsrlvd,vpsravd,vpsllvq,vpsrlvq) intools/ffx_version_query.py, zeroing the upper 128 bits on 128-bit VEX destinations and clamping out-of-range shift counts to match hardware.tests/cpu/avx2_shifts.asm,tests/cpu/avx2_shifts.def) and differential test (tests/cpu/avx2_shifts.py) wired intoCMakeLists.txtascpu_aot_avx2_shiftswith ahost_has_avx2()check (OSXSAVE,XCR0YMM state, and CPUID leaf 7 EBX bit 5AVX2) andSKIP_RETURN_CODE 77on unsupported hosts.avx2_shifts->cpu_aot_avx2_shiftsintools/form_coverage.py(+9 AVX2 mnemonics, raising AVX2 from 0/28 to 9/28 indocs/coverage/x64_zen2.tsv) and document the test indocs/experiments.md.Verification
Tested on Windows 11 (VS 2022 Build Tools 17.14, MSVC 19.44, ML64 14.44, Windows SDK 10.0.26100, Python 3.12):
cmake --build --preset dev --target cpu_avx2_shifts_liftedfailed with:cmake --build --preset dev --target cpu_avx2_shifts_liftedsucceeded.ctest --preset dev --no-tests=error -R "^(cpu_aot_avx2_shifts|cpu_aot_bmi1|cpu_aot_shift_count|cpu_aot_version_query|cpu_aot_address_size)$" -V: 5/5 passed (12 AVX2 broadcast and variable-shift vector cases matched native and translated DLLs).python -B tests/form_coverage_check.py:form coverage checks passed.Evidence and follow-up
vpbroadcastb,vpbroadcastw,vpbroadcastd,vpbroadcastq,vpsllvd,vpsrlvd,vpsravd,vpsllvq,vpsrlvq) todocs/coverage/x64_zen2.tsvcoverage.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:49:49Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
8706760643ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:44:51Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
8706760ℹ️ 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.
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T22:53:11Z.
Guarded the AVX2 broadcast and variable-shift handlers with
i.encoding == EncodingKind.VEXso EVEX/broadcast/opmask forms are rejected, and added a synthetic EVEX{1to8}vpsllvdrejection check intests/cpu/avx2_shifts.py.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:49:50Z.
Code review location:
tools/ffx_version_query.py; line 232For an EVEX input such as
vpsllvd ymm0, ymm1, dword ptr [rdx]{1to8}, iced reports the same mnemonic, so this new branch accepts it without checking the encoding or broadcast modifier. Hardware reuses one 32-bit count for all lanes, butcaddr + nreads eight different counts, silently changing the result and potentially accessing memory beyond the four-byte operand. Reject non-VEX/broadcast encodings before emitting this loop, or implement their semantics, and cover the rejection with a synthetic-byte case.Useful? React with 👍 / 👎.