cpu: lower 32-bit and 64-bit integer bit-scan, bit-count, byte-swap, and bit-test instructions #285

Merged
Vonsek merged 4 commits from upstream-pr/289 into main 2026-11-22 07:18:19 +00:00
Vonsek commented 2026-11-21 20:55:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T20:55:40Z.


Change

  • Lower 32-bit and 64-bit integer bit-scan, bit-count, byte-swap, and register bit-test instructions (bsf, bsr, bswap, popcnt, lzcnt, bt, bts, btr, btc) in tools/ffx_version_query.py, preserving zero-extending 32-bit writes, exact ZF/CF flag updates, and rejecting memory-operand bt/bts/btr/btc.
  • Add a source-built MASM fixture (tests/cpu/bit_ops.asm, tests/cpu/bit_ops.def) and differential test (tests/cpu/bit_ops.py) wired into CMakeLists.txt as cpu_aot_bit_ops, verifying all 19 exports (32-bit and 64-bit, including btc64_imm and a memory-operand bt rejection control) against both the native DLL and a reference model.
  • Classify bit_ops -> cpu_aot_bit_ops in tools/form_coverage.py (+9 Integer mnemonics in docs/coverage/x64_zen2.tsv) and document the test in docs/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):

  • Before the change, cmake --build --preset dev --target cpu_bit_ops_lifted failed with:
    ValueError: unsupported query operation at 0x100a: bsf eax,ecx
    
  • After the change:
    • cmake --build --preset dev --target cpu_bit_ops_lifted succeeded.
    • 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

  • Adds nine uncovered x64 Integer mnemonics (bsf, bsr, bswap, bt, btc, btr, bts, lzcnt, popcnt) to docs/coverage/x64_zen2.tsv coverage.
  • All binaries are source-built via MASM and CMake; no game files or external dumps are included.

Checklist

  • Focused, single-purpose change
  • Source-built test that fails without the change and passes with it
  • Verified locally on Windows
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534280433 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/289). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T20:55:40Z. --- ## Change - Lower 32-bit and 64-bit integer bit-scan, bit-count, byte-swap, and register bit-test instructions (`bsf`, `bsr`, `bswap`, `popcnt`, `lzcnt`, `bt`, `bts`, `btr`, `btc`) in `tools/ffx_version_query.py`, preserving zero-extending 32-bit writes, exact ZF/CF flag updates, and rejecting memory-operand `bt`/`bts`/`btr`/`btc`. - Add a source-built MASM fixture (`tests/cpu/bit_ops.asm`, `tests/cpu/bit_ops.def`) and differential test (`tests/cpu/bit_ops.py`) wired into `CMakeLists.txt` as `cpu_aot_bit_ops`, verifying all 19 exports (32-bit and 64-bit, including `btc64_imm` and a memory-operand `bt` rejection control) against both the native DLL and a reference model. - Classify `bit_ops` -> `cpu_aot_bit_ops` in `tools/form_coverage.py` (+9 Integer mnemonics in `docs/coverage/x64_zen2.tsv`) and document the test in `docs/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): - Before the change, `cmake --build --preset dev --target cpu_bit_ops_lifted` failed with: ```text ValueError: unsupported query operation at 0x100a: bsf eax,ecx ``` - After the change: - `cmake --build --preset dev --target cpu_bit_ops_lifted` succeeded. - `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 - Adds nine uncovered x64 Integer mnemonics (`bsf`, `bsr`, `bswap`, `bt`, `btc`, `btr`, `bts`, `lzcnt`, `popcnt`) to `docs/coverage/x64_zen2.tsv` coverage. - All binaries are source-built via MASM and CMake; no game files or external dumps are included. ## Checklist - [x] Focused, single-purpose change - [x] Source-built test that fails without the change and passes with it - [x] Verified locally on Windows
upstream-sync closed this pull request 2026-11-24 06:42:15 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:42:15 +00:00 (Migrated from github.com)

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6008560499 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/289#pullrequestreview-6008560499). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T22:16:41Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `93468fa209` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". 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". </details>
chatgpt-codex-connector[bot commented 2026-11-24 06:48:08 +00:00 (Migrated from github.com)

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.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T22:16:43.130139Z 93468fa Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070009157 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/289#issuecomment-7070009157). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T22:11:56Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"93468fa209b441d24d6bf3b9d481a3d29d7e4f6b","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T22:16:43.130139Z">2026-11-21T22:16:43.130139Z</relative-time> | `93468fa` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Vonsek commented 2026-11-24 06:48:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T22:21:48Z.


Addressed in 236630c: added a host_has_popcnt_lzcnt() CPUID check (leaf 1 ECX bit 23 for POPCNT and leaf 0x80000001 ECX bit 5 for LZCNT) in the portable lifted DLL before loading/invoking the native fixture, exiting 77 when absent, and registered SKIP_RETURN_CODE 77 on cpu_aot_bit_ops in CMakeLists.txt.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070127797 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/289#issuecomment-7070127797). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T22:21:48Z. --- Addressed in `236630c`: added a `host_has_popcnt_lzcnt()` CPUID check (leaf 1 ECX bit 23 for POPCNT and leaf `0x80000001` ECX bit 5 for LZCNT) in the portable lifted DLL before loading/invoking the native fixture, exiting 77 when absent, and registered `SKIP_RETURN_CODE 77` on `cpu_aot_bit_ops` in `CMakeLists.txt`.
chatgpt-codex-connector[bot commented 2026-11-24 06:50:36 +00:00 (Migrated from github.com)

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 132

@@ -0,0 +1,188 @@
+"""Compare native and translated x64 integer bit-scan, bit-count, byte-swap, and bit-test instructions."""
+import ctypes
+from pathlib import Path
+import sys
+
+import pefile
+from iced_x86 import Decoder
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "tools"))
+from cpu_leaf_aot import export_rva
+from cpu_ranges import function_ranges
+from ffx_version_query import INTEGER_HEADER, lower, region
+
+U64 = ctypes.c_uint64
+
+UNARY_OUT_EXPORTS = ("bsf32", "bsf64", "bsr32", "bsr64", "popcnt32", "popcnt64", "lzcnt32", "lzcnt64", "btc64_imm")
+UNARY_PLAIN_EXPORTS = ("bswap32", "bswap64")
+BINARY_OUT_EXPORTS = ("bt32", "bt64", "bts32", "bts64", "btr32", "btr64", "btc32", "btc64")
+
+
+def emit(image, output):
+    parts = [INTEGER_HEADER]
+    with pefile.PE(str(image), fast_load=True) as pe:
+        for name in UNARY_OUT_EXPORTS:
+            (bounds,) = function_ranges(pe, export_rva(pe, name))
+            body = region(pe, *bounds)
+            code = lower(body, ["rcx = a; rdx = out;"], {}, {}, {})
+            parts.append(f'extern "C" __declspec(dllexport) word {name}(word a, word out) {{\n{code}\n}}\n')
+        for name in UNARY_PLAIN_EXPORTS:
+            (bounds,) = function_ranges(pe, export_rva(pe, name))
+            body = region(pe, *bounds)
+            code = lower(body, ["rcx = a;"], {}, {}, {})
+            parts.append(f'extern "C" __declspec(dllexport) word {name}(word a) {{\n{code}\n}}\n')
+        for name in BINARY_OUT_EXPORTS:
+            (bounds,) = function_ranges(pe, export_rva(pe, name))
+            body = region(pe, *bounds)
+            code = lower(body, ["rcx = a; rdx = bit; r8 = out;"], {}, {}, {})
+            parts.append(f'extern "C" __declspec(dllexport) word {name}(word a, word bit, word out) {{\n{code}\n}}\n')
+    output.write_text("".join(parts), encoding="ascii")
+
+
+def load_lib(path):
+    lib = ctypes.CDLL(str(Path(path).resolve()))
+    for name in UNARY_OUT_EXPORTS:
+        fn = getattr(lib, name)
+        fn.argtypes, fn.restype = [U64, ctypes.POINTER(U64)], U64
+    for name in UNARY_PLAIN_EXPORTS:
+        fn = getattr(lib, name)
+        fn.argtypes, fn.restype = [U64], U64
+    for name in BINARY_OUT_EXPORTS:
+        fn = getattr(lib, name)
+        fn.argtypes, fn.restype = [U64, U64, ctypes.POINTER(U64)], U64
+    return lib
+
+
+def ref_bswap(a, bits):
+    size = bits // 8
+    return int.from_bytes((a & ((1 << bits) - 1)).to_bytes(size, "little"), "big")
+
+
+def ref_popcnt(a, bits):
+    v = (a & ((1 << bits) - 1)).bit_count()
+    return v, (1 if v == 0 else 0)
+
+
+def ref_lzcnt(a, bits):
+    a &= (1 << bits) - 1
+    if a == 0:
+        return bits, 2
+    v = bits - a.bit_length()
+    return v, (1 if v == 0 else 0)
+
+
+def ref_bt_op(op, a, bit, bits):
+    mask = (1 << bits) - 1
+    b = bit & (bits - 1)
+    cf = (a >> b) & 1
+    if op == "bt":
+        return a, cf  # bt does not write destination (rax keeps all 64 bits)
+    v = a & mask
+    if op == "bts":
+        v |= 1 << b
+    elif op == "btr":
+        v &= ~(1 << b)
+    elif op == "btc":
+        v ^= 1 << b
+    return v & mask, cf
+
+
+def check(native_path, lifted_path):
+    native, lifted = load_lib(native_path), load_lib(lifted_path)
+    slot = U64(0)
+    values = (
+        0, 1, 2, 0x80, 0x01020304, 0x55aa55aa, 0x7fffffff, 0x80000000, 0xffffffff,
+        0xdeadbeef00000000, 0xdeadbeef00000001, 0x0123456789abcdef,
+        0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff,
+    )
+    bits_list = (0, 1, 7, 15, 31, 32, 33, 47, 63, 64, 65, 0xffffffff)
+
+    cases = 0
+    for name, is_bsr, bits in (("bsf32", False, 32), ("bsf64", False, 64), ("bsr32", True, 32), ("bsr64", True, 64)):
+        mask = (1 << bits) - 1
+        for a in values:
+            masked = a & mask
+            for lib, label in ((native, "native"), (lifted, "lifted")):
+                slot.value = 0xdeadbeef
+                got = getattr(lib, name)(a, ctypes.byref(slot))
+                if masked == 0:
+                    if slot.value != 1:
+                        raise AssertionError(f"{label} {name}({a:#x}) ZF = {slot.value}, expected 1")
+                else:
+                    want = (masked.bit_length() - 1) if is_bsr else ((masked & -masked).bit_length() - 1)
+                    if (got, slot.value) != (want, 0):
+                        raise AssertionError(f"{label} {name}({a:#x}) = ({got:#x}, {slot.value}), expected ({want:#x}, 0)")
+            cases += 1
+
+    for name, bits in (("bswap32", 32), ("bswap64", 64)):
+        for a in values:
+            want = ref_bswap(a, bits)
+            for lib, label in ((native, "native"), (lifted, "lifted")):
+                got = getattr(lib, name)(a)
+                if got != want:
+                    raise AssertionError(f"{label} {name}({a:#x}) = {got:#x}, expected {want:#x}")
+            cases += 1
+
+    for name, fn, bits in (("popcnt32", ref_popcnt, 32), ("popcnt64", ref_popcnt, 64),
+                           ("lzcnt32", ref_lzcnt, 32), ("lzcnt64", ref_lzcnt, 64)):
+        for a in values:
+            want_v, want_f = fn(a, bits)
+            for lib, label in ((native, "native"), (lifted, "lifted")):
+                slot.value = 0xdeadbeef
+                got = getattr(lib, name)(a, ctypes.byref(slot))

P2 Badge Feature-gate the native POPCNT and LZCNT checks

On 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_ops to 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 in tests/cpu/heap_layout.py.

AGENTS.md reference: AGENTS.md:L37-L39

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4655275348 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/289#discussion_r4655275348). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T22:16:41Z. **Code review location:** `tests/cpu/bit_ops.py`; line 132 ~~~~diff @@ -0,0 +1,188 @@ +"""Compare native and translated x64 integer bit-scan, bit-count, byte-swap, and bit-test instructions.""" +import ctypes +from pathlib import Path +import sys + +import pefile +from iced_x86 import Decoder + +sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "tools")) +from cpu_leaf_aot import export_rva +from cpu_ranges import function_ranges +from ffx_version_query import INTEGER_HEADER, lower, region + +U64 = ctypes.c_uint64 + +UNARY_OUT_EXPORTS = ("bsf32", "bsf64", "bsr32", "bsr64", "popcnt32", "popcnt64", "lzcnt32", "lzcnt64", "btc64_imm") +UNARY_PLAIN_EXPORTS = ("bswap32", "bswap64") +BINARY_OUT_EXPORTS = ("bt32", "bt64", "bts32", "bts64", "btr32", "btr64", "btc32", "btc64") + + +def emit(image, output): + parts = [INTEGER_HEADER] + with pefile.PE(str(image), fast_load=True) as pe: + for name in UNARY_OUT_EXPORTS: + (bounds,) = function_ranges(pe, export_rva(pe, name)) + body = region(pe, *bounds) + code = lower(body, ["rcx = a; rdx = out;"], {}, {}, {}) + parts.append(f'extern "C" __declspec(dllexport) word {name}(word a, word out) {{\n{code}\n}}\n') + for name in UNARY_PLAIN_EXPORTS: + (bounds,) = function_ranges(pe, export_rva(pe, name)) + body = region(pe, *bounds) + code = lower(body, ["rcx = a;"], {}, {}, {}) + parts.append(f'extern "C" __declspec(dllexport) word {name}(word a) {{\n{code}\n}}\n') + for name in BINARY_OUT_EXPORTS: + (bounds,) = function_ranges(pe, export_rva(pe, name)) + body = region(pe, *bounds) + code = lower(body, ["rcx = a; rdx = bit; r8 = out;"], {}, {}, {}) + parts.append(f'extern "C" __declspec(dllexport) word {name}(word a, word bit, word out) {{\n{code}\n}}\n') + output.write_text("".join(parts), encoding="ascii") + + +def load_lib(path): + lib = ctypes.CDLL(str(Path(path).resolve())) + for name in UNARY_OUT_EXPORTS: + fn = getattr(lib, name) + fn.argtypes, fn.restype = [U64, ctypes.POINTER(U64)], U64 + for name in UNARY_PLAIN_EXPORTS: + fn = getattr(lib, name) + fn.argtypes, fn.restype = [U64], U64 + for name in BINARY_OUT_EXPORTS: + fn = getattr(lib, name) + fn.argtypes, fn.restype = [U64, U64, ctypes.POINTER(U64)], U64 + return lib + + +def ref_bswap(a, bits): + size = bits // 8 + return int.from_bytes((a & ((1 << bits) - 1)).to_bytes(size, "little"), "big") + + +def ref_popcnt(a, bits): + v = (a & ((1 << bits) - 1)).bit_count() + return v, (1 if v == 0 else 0) + + +def ref_lzcnt(a, bits): + a &= (1 << bits) - 1 + if a == 0: + return bits, 2 + v = bits - a.bit_length() + return v, (1 if v == 0 else 0) + + +def ref_bt_op(op, a, bit, bits): + mask = (1 << bits) - 1 + b = bit & (bits - 1) + cf = (a >> b) & 1 + if op == "bt": + return a, cf # bt does not write destination (rax keeps all 64 bits) + v = a & mask + if op == "bts": + v |= 1 << b + elif op == "btr": + v &= ~(1 << b) + elif op == "btc": + v ^= 1 << b + return v & mask, cf + + +def check(native_path, lifted_path): + native, lifted = load_lib(native_path), load_lib(lifted_path) + slot = U64(0) + values = ( + 0, 1, 2, 0x80, 0x01020304, 0x55aa55aa, 0x7fffffff, 0x80000000, 0xffffffff, + 0xdeadbeef00000000, 0xdeadbeef00000001, 0x0123456789abcdef, + 0x8000000000000000, 0x7fffffffffffffff, 0xffffffffffffffff, + ) + bits_list = (0, 1, 7, 15, 31, 32, 33, 47, 63, 64, 65, 0xffffffff) + + cases = 0 + for name, is_bsr, bits in (("bsf32", False, 32), ("bsf64", False, 64), ("bsr32", True, 32), ("bsr64", True, 64)): + mask = (1 << bits) - 1 + for a in values: + masked = a & mask + for lib, label in ((native, "native"), (lifted, "lifted")): + slot.value = 0xdeadbeef + got = getattr(lib, name)(a, ctypes.byref(slot)) + if masked == 0: + if slot.value != 1: + raise AssertionError(f"{label} {name}({a:#x}) ZF = {slot.value}, expected 1") + else: + want = (masked.bit_length() - 1) if is_bsr else ((masked & -masked).bit_length() - 1) + if (got, slot.value) != (want, 0): + raise AssertionError(f"{label} {name}({a:#x}) = ({got:#x}, {slot.value}), expected ({want:#x}, 0)") + cases += 1 + + for name, bits in (("bswap32", 32), ("bswap64", 64)): + for a in values: + want = ref_bswap(a, bits) + for lib, label in ((native, "native"), (lifted, "lifted")): + got = getattr(lib, name)(a) + if got != want: + raise AssertionError(f"{label} {name}({a:#x}) = {got:#x}, expected {want:#x}") + cases += 1 + + for name, fn, bits in (("popcnt32", ref_popcnt, 32), ("popcnt64", ref_popcnt, 64), + ("lzcnt32", ref_lzcnt, 32), ("lzcnt64", ref_lzcnt, 64)): + for a in values: + want_v, want_f = fn(a, bits) + for lib, label in ((native, "native"), (lifted, "lifted")): + slot.value = 0xdeadbeef + got = getattr(lib, name)(a, ctypes.byref(slot)) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Feature-gate the native POPCNT and LZCNT checks** On 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_ops` to 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 in `tests/cpu/heap_layout.py`. AGENTS.md reference: [AGENTS.md:L37-L39](https://github.com/R0Y00/Xbox2Windows/blob/93468fa209b441d24d6bf3b9d481a3d29d7e4f6b/AGENTS.md#L37-L39) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!285
No description provided.