cpu: lower 32-bit and 64-bit integer bit-scan, bit-count, byte-swap, and bit-test instructions #285
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/289"
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-21T20:55:40Z.
Change
bsf,bsr,bswap,popcnt,lzcnt,bt,bts,btr,btc) intools/ffx_version_query.py, preserving zero-extending 32-bit writes, exact ZF/CF flag updates, and rejecting memory-operandbt/bts/btr/btc.tests/cpu/bit_ops.asm,tests/cpu/bit_ops.def) and differential test (tests/cpu/bit_ops.py) wired intoCMakeLists.txtascpu_aot_bit_ops, verifying all 19 exports (32-bit and 64-bit, includingbtc64_immand a memory-operandbtrejection control) against both the native DLL and a reference model.bit_ops->cpu_aot_bit_opsintools/form_coverage.py(+9 Integer mnemonics 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_bit_ops_liftedfailed with:cmake --build --preset dev --target cpu_bit_ops_liftedsucceeded.ctest --preset dev --no-tests=error -R "^(cpu_aot_bit_ops|cpu_aot_shift_count|cpu_aot_version_query|cpu_aot_address_size)$" -V: 4/4 passed (1605 integer bit-op cases (BSF, BSR, BSWAP, POPCNT, LZCNT, BT/BTS/BTR/BTC) matched native and translated DLLs).python -B tests/form_coverage_check.py:form coverage checks passed.Evidence and follow-up
bsf,bsr,bswap,bt,btc,btr,bts,lzcnt,popcnt) todocs/coverage/x64_zen2.tsvcoverage.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:16:41Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
93468fa209ℹ️ 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:11:56Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
93468faℹ️ 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:21:48Z.
Addressed in
236630c: added ahost_has_popcnt_lzcnt()CPUID check (leaf 1 ECX bit 23 for POPCNT and leaf0x80000001ECX bit 5 for LZCNT) in the portable lifted DLL before loading/invoking the native fixture, exiting 77 when absent, and registeredSKIP_RETURN_CODE 77oncpu_aot_bit_opsinCMakeLists.txt.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T22:16:41Z.
Code review location:
tests/cpu/bit_ops.py; line 132On an otherwise supported x64 Windows host without LZCNT, such as Intel Sandy Bridge or Ivy Bridge, this loop unconditionally invokes the native LZCNT fixtures. Those processors execute the encoding as BSR, so an input of 1 returns 0 instead of 31 or 63, causing
cpu_aot_bit_opsto fail despite a correct translation. Hosts without POPCNT instead encounter an illegal-instruction error. Check the respective host CPUID features before invoking these native cases, while retaining the lifted/reference checks, following the existing AVX guard intests/cpu/heap_layout.py.AGENTS.md reference: AGENTS.md:L37-L39
Useful? React with 👍 / 👎.