Skip to content

test(semantic): add translator tests for v_pk_max_u16 - #5663

Open
slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-pk-max-u16-suite
Open

slopgobblercobbler wants to merge 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-valu-pk-max-u16-suite

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Adds a bit-accurate reference mathematical oracle, AST definitions, scalar interpreter, SIMD multi-lane divergence model, register aliasing checks, status flags, IEEE 754 edge cases, and negative mutation tests for v_pk_max_u16 in tests/semantic/test_valu_pk_max_u16_hw.py.

Exercises the rdna2spirv translator through support.translate_lines(...) and verifies outputs with support.mrt0_words(spv).

Tested

  • python -m compileall -q tests
  • python -I tests/semantic/test_valu_pk_max_u16_hw.py
  • python -I tests/test_semantic_translator_use.py
  • Standard library Python only (python -I compatible, 0 external dependencies)
  • AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@mrbean56

Copy link
Copy Markdown

Ran 0c088a8312 on Linux (Debian 13), Python 3.13.5: the new test fails on this head.

No GPU, no game data. AI-assisted.

@slopgobblercobbler

Copy link
Copy Markdown
Contributor Author

Updated test_clamp_rejected_by_translator to test_clamp_accepted_as_noop_by_translator, asserting that translating v_pk_max_u16 with and without clamp produces identical result dwords, aligning with #4082 where VOP3P clamp on max/min is treated as a hardware no-op. Also added test_invalid_modifier_rejected_by_translator (rejecting float-only neg_lo) and op_sel hardware translator execution coverage. All 21 tests pass under Python 3.10+.

@slopgobblercobbler
slopgobblercobbler force-pushed the test/semantic-valu-pk-max-u16-suite branch from 0c088a8 to cd9ccc6 Compare November 23, 2026 12:44
@kapitche

Copy link
Copy Markdown
Contributor

Tested cd9ccc6 merged with main 561b65a on Linux (WSL2) / Python 3.12.16: pass

tests/semantic/test_valu_pk_max_u16_hw.py (new, test-only): 21 run, 21 passed, 0 failed, no skips. Merge with main was clean.

Negative control: the file only adds a test, so it trivially passes on main. Mutating the translator so v_pk_max_u16 emits UMin instead of UMax (tools/rdna2spirv.py, packed int max/min branch) makes 5 tests fail (test_translator_hw_pk_max_u16 x3 subtests, test_translator_hw_pk_max_u16_op_sel, test_clamp_accepted_as_noop_by_translator; 21 run, 5 failed); restored afterwards. A signed-for-unsigned SMax mutation is not detected, but it is equivalent for the zero-extended 16-bit halves the translator feeds it, so that is not a test gap.

Note: of the 21 tests only about 5 go through the translator and mini interpreter; the rest (oracle, AST, scalar and wave32/wave64 "interpreter", aliasing, condition-code and mutant checks) test classes defined in the test file itself. The _hw name does not mean a hardware measurement.

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.

3 participants