cpu_ref: reject multi-dword VGPR sources, validate operands under EXEC=0, and report failing PC (CPU-REF-OPERAND-VALIDATION-AND-PC) #1457
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1457
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/cpu-ref-operand-validation-and-pc"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: CPU-REF-OPERAND-VALIDATION-AND-PC
Summary
Fixes five operand-validation and state-reporting bugs in
tools/cpu_ref.py(which is also the baseMachineclass fortools/cf_ref.py):_int_srcand_float_srcrejected multi-dword SGPR sources (n != 1) and_write_vgprrejected multi-dword VGPR destinations, but multi-dword VGPR sources (v[1:2]) were silently narrowed tov1. Both helpers now raiseUnsupported.EXEC == 0: every vector instruction looped overself._active_lanes()without checking operands when no lanes were active, so unsupported destinations (v_mov_b32 s0, v1), sources (v_mov_b32 v0, m0,v_add_f32 v0, v[1:2], v3), or conditions (v_cndmask_b32_e64 v0, v1, v2, m0) silently passed underexec=0. Added_vector_lanes()/_validate_vector_operands()so operands are checked even when all lanes are masked off (zero extra work when lanes are active).Unsupportedexceptions:Machine.run()updatedself.pconly afterself.step(ins), so operand errors raised by_int_src/_float_src/_write_vgpr/_write_scalar_dst/_mask_bitreportedpc 0x0(or the prior instruction'snext_pc) instead ofins["pc"]. Bothrun()andstep()now setself.pc = ins["pc"]before executing.sccclobbered on invalid destination:s_add_u32,s_lshl_b32, ands_lshr_b32mutatedself.sccbefore_write_scalar_dst()validated the destination; now_check_scalar_dst()runs first.--lane Npassed together with--lanes 64was silently ignored on the CLI (despiteMachine.__init__rejecting it), and negative/boolean register indices (--sgpr -1=0,{"sgpr": {-1: 0}},{"lanes": True}) were accepted.Testing
arm64), Python 3.14 (CPU-only, hand-written.sfixtures only, no game data)python3 -m compileall -q make_game.py tools tests-> cleanpython3 -I scripts/check_no_game_data.py tools/cpu_ref.py tests/test_cpu_ref.py-> cleanpython3 -I tests/test_cpu_ref.py -v-> 39/39 OK (5 new tests)python3 -I tests/test_cf_ref.py-> 26/26 OKpython3 -I tests/test_cf_ref_edge_fixes.py-> 5/5 OKpython3 -I tests/test_wave_diff.py-> 12/12 OKpython3 -m unittest discover -s tests -p "test_*diff.py"-> 362/362 OKpython3 -I tests/test_missing_input_exit_codes.py-> 2/2 OKpython3 -I tests/test_text_write_line_endings.py-> 3/3 OKpython3 -I tests/test_ci_registration.py-> 16/16 OKtests/test_cpu_ref.pyon unpatchedupstream/mainb4b7756e8):FAILED (failures=25)across all 5 new tests and their subtests.Independent verification (CPU/tools-only, native Windows, Python 3.11.9 — stdlib-only tools so representative): diff reviewed line-by-line, all claimed fixes present and covered by the new tests; neighboring suites green. Details in the verification batch log. AI-assisted verification.
Red/green: the PR's tests fail on main 4938673 and pass on head 2c484d64abbf (Linux, Python 3.13.18).
Targeted batch of 11 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)