Skip to content

test(semantic): add translator tests for v_add_f64 - #5469

Open
slopgobblercobbler wants to merge 2 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-add-f64-suite
Open

slopgobblercobbler wants to merge 2 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-add-f64-suite

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Adds support and regression tests for v_add_f64 (double-precision floating-point add) in tools/rdna2spirv.py and tests/semantic/test_valu_add_f64_hw.py.

  • tests/semantic/spirv_mini_interp.py: Support OpFAdd on %double (binary64).
  • tools/rdna2spirv.py: Validate destination register pair count for v_add_f64.
  • tests/semantic/test_valu_add_f64_hw.py: Exercises tools/rdna2spirv.py via support.translate_lines(...) and validates execution results with support.mrt0_words(...).
  • Passes tests/test_semantic_translator_use.py.

Tested

  • python -m compileall -q tests tools
  • python -I tests/semantic/test_valu_add_f64_hw.py (10/10 passed)
  • python -I tests/test_semantic_translator_use.py (Passed)
  • Standard library Python only (unittest, struct, math)
  • Zero game data, keys, or decryption

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested 1c004138 (it already contains main 3faac557) on an Apple M4 (arm64, macOS). Everything here ran on the CPU. The M4's Vulkan driver, MoltenVK 1.4.2, reports shaderFloat64 = false, so f64 modules cannot run on this GPU. Verdict: pass, with notes on scope.

What passes

  • test_valu_add_f64_hw.py passes, 10/10, on Python 3.12.16, 3.14.10 and 3.15.2.
  • Negative control 1: with main's tools/rdna2spirv.py, only test_rejection_invalid_operands fails (the single-register destination check).
  • Negative control 2: with main's spirv_mini_interp.py, the file fails with 6 errors (binary64 OpFAdd is refused).
  • Whole semantic suite: 6,255 tests (6,245 on main). There are 32 failures and 2 errors, the same 34 test IDs that fail on main on this machine: the vop3 test_rows and the divergent-loop/ballot cases on arm64. Nothing new fails.
  • Corpus: 5 of the 25,734 listings in my work folder use v_add_f64, always with a v[n:n+1] destination. I translated a 205-listing slice: those 5 plus 200 spread across the corpus. The output is byte-identical to main, and 205/205 translate and pass validation on both. The new destination check rejects nothing real.

Scope

  • The v_add_f64 lowering is already on main, including MODE rounding and the output modifiers.
  • Main's tests/semantic/test_valu_add_f64.py already covers most of the new file: basic sums, signed zeros, inf/NaN, neg/abs, clamp/omod, SGPR pairs and inline floats, and FP_ROUND toward zero.
  • What this PR adds is binary64 OpFAdd/OpFSub/OpFDiv in spirv_mini_interp, the destination-pair check, and the same cases run through the mini interpreter.
  • The title and body say it adds support for the op; "adds mini-interpreter coverage" would describe it more accurately.

One gap in the mini-interpreter change

  • A binary64 OpFDiv by zero raises UnsupportedConstruct. IEEE gives ±inf there, and NaN for 0/0.
  • v_rcp_f64 emits exactly that division (OpFDiv %double 1.0 x). Through support.mrt0_words on this branch, v_rcp_f64 of +0 and of −0 both raise OpFDiv by zero, instead of returning 0x7ff0000000000000 and 0xfff0000000000000. Non-zero inputs work: rcp(2.0) gives 0x3fe0000000000000.
  • This is not a regression, since main refuses every binary64 OpFDiv. But math.copysign(math.inf, x) * math.copysign(1.0, y), with NaN for 0/0 and NaN operands, would finish it.

Smaller points

No game data: counts only. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants