fix: the Rust RDNA 2 interpreter sign-extends a literal for signed 64-bit scalar sources #403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/403"
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 LooperSalty/AnyXboxX. Originally posted by Luke-Ervin on 2026-11-26T17:32:03Z.
Change
The Rust reference interpreter (
crates/anyxboxx-rdna2-ref/src/scalar.rs) now sign-extends a 32-bit literal read as S0 bys_ashr_i64,s_bfe_i64ands_flbit_i32_i64, as the Python model does.AMD's RDNA 2 ISA (November 2020), section 6.2.1, "Literal Expansion to 64 bits" (p. 43): "64-bit unsigned integer: zero extended to 64 bits; 64-bit signed integer: sign extended to 64 bits". The Python applies it through
signed_literal_s0(emu/rdna2_exec_bits.py); the Rust port had not carried it over and zero-extended every 64-bit literal. Before this change:s_flbit_i32_i64 s51, 0xFFFFFFF0s_ashr_i64 s[40:41], 0x80000000, 10x00000000400000000xFFFFFFFFC0000000s_bfe_i64of0x80000000(offset 4, width 40)0x00000000080000000xFFFFFFFFF8000000read_signed64_s0sign-extends only when S0 is the literal code; a register pair or an inline constant is read unchanged.binary_signed64is the two-operand helper fors_ashr_i64ands_bfe_i64; the genericbinary()is untouched, so no other instruction changes. The unsigned and bitwise 64-bit sources (s_bfe_u64,s_flbit_i32_b64,s_mov_b64…) keep zero-extending.docs/rust-full-status.mdanddocs/fr/rust-full-status.mdrecord the finding. No README row or test-count change.A second commit corrects the French docs line only: "bitwise" is "bit à bit", not "binaires" (which reads as "two-operand"). Its message also corrects a count in the first commit's message (three unsigned or bitwise controls, not four), which was left as it is rather than rewritten on an open pull request.
Linked issue: none.
Verification
Run on Linux (Ubuntu, Python 3.13, Rust 1.98.1), on top of
mainat47759e8(and again with the second commit, same results; and merged with the newestmain,74dfb48, with #402 and the third fix: 1458 passed, 449 skipped), withanyxboxx-rdna2-refandanyxboxx-pebuilt bycargo build --release -p anyxboxx-rdna2-ref -p anyxboxx-pe:Not run (the 449 skipped tests): everything that needs Windows, the C++ runtime,
dxcor a GPU, and the Rust crates that only build for Windows;cargo test --workspacefor the same reason. No Windows machine was available. The change is plain integer arithmetic. No game was run.Oracle and test data
test_signed_64_bit_sources_sign_extend_a_32_bit_literalintests/test_rdna2_exec_bits.pypins its values against the ISA), throughtests/test_rdna2_ref_parity.py.s_flbit_i32_i64on the literal0xFACE5766(Rust0x20, Python0x25). The 300 seeded programs never paired one of these three instructions with a literal whose bit 31 is set.test_signed_64_bit_sources_sign_extend_a_literal_in_both_modelsfails on the old release binary. It compares the two interpreters on the three signed instructions and three unsigned or bitwise controls (s_bfe_u64,s_flbit_i32_b64,s_mov_b64) with five literals, and checks two values outright. The Rust unit testa_literal_is_sign_extended_for_a_signed_64_bit_source_onlyrepeats the Python test's cases.Checklist
E_NOTIMPL), never a fake success.test_readme_sync.pychecks it). No README change needed.This change was made with AI assistance (Claude Code): the bug was found, fixed and tested by the AI as described above. It was not tested on Windows.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CVSn4bUDfLBFvceKVLPSX5
Imported from LooperSalty/AnyXboxX. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T17:32:15Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
3f7435aℹ️ 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.