Skip to content

shader: pin v_fma_mix half selection per source position - #2806

Merged
tedin7 merged 1 commit into
R0Y00:mainfrom
RenzoWit35:shader/fma-mix-source-position-check
Nov 26, 2026
Merged

tedin7 merged 1 commit into
R0Y00:mainfrom
RenzoWit35:shader/fma-mix-source-position-check

Conversation

@RenzoWit35

Copy link
Copy Markdown
Contributor

Change

Adds test_vop3p_fma_mix_half_select_per_source_position to tests/rdna2_tools_check.py, next to the existing fma_mix test. No tool code changes: tools/pixel_aot.py and every other tool are untouched.

Refs #2103. When closing that PR the maintainer wrote: "Your test that isolates each source position is useful independently. Please rebase and keep that discriminator, removing the overlapping lowering. The merged parser rejects a half-select bit on a full-width input, so check the refusal class while keeping the swapped-source control."

For each source position (0, 1, 2) and for both v_fma_mix_f32 and v_fma_mixlo_f16 (v_fma_mixhi_f16 is covered by the existing test):

  • op_sel_hi alone widens the low half of that source only; the other sources stay binary32. Asserted on the exact lowered mad(...) text and on the parsed fields.
  • op_sel plus op_sel_hi on that source selects the high half of that source only (exact text). A variant with op_sel_hi:[1,1,1] and op_sel on one source checks that the half bit does not move to a neighbour.
  • op_sel alone is refused with ValueError matching "High-half selection requires an f16 operand", both from parse_fma_mix and through lower(), also when op_sel_hi is set on a different source.
  • Swapped-source control: the lowered text for a modifier at one position differs from the text at every other position, and low differs from high.

The test needs no LLVM: it feeds assembly text to lower(). It runs on Windows and in the Linux CI list (the file is already registered).

Verification

Commands from the worktree, with C:\XBOX2Windows\repo\out\pe-env\Scripts\python.exe -B:

  • Before: tests/rdna2_tools_check.py gave Ran 157 tests, OK (skipped=19).
  • After: Ran 158 tests, OK (skipped=19). The skips are LLVM-only tests.

Mutants of tools/pixel_aot.py (each applied by hand, then restored; git diff -- tools empty after each):

Mutant main's test_vop3p_fma_mix_inline_abs_neg_modifiers new test
1. lower() pairs op_sel[1] and op_sel[2] swapped passes (survives) FAILS (high-half cases, positions 1 and 2, both opcodes)
2. refusal in parse_fma_mix limited to positions 0 and 1 passes (survives) FAILS (op_sel alone at position 2, both opcodes, 2 failures)
3. zip(tokens, op_sel, op_sel_hi) plain swap in lower() fails (already caught) FAILS (7 failures)

Not run: tests/pixel_aot_check.py (needs LLVM and a GPU/WARP device; not touched), the full CTest suite.

Evidence and follow-up

Overlap: gh pr list --state open --search "fma_mix" shows only #2753 (gfx2hlsl) and #532 (integer multiplies), neither edits tests/rdna2_tools_check.py. Open PRs #1572 and #531 touch the file elsewhere (not near the fma_mix tests); the new method sits between the existing fma_mix test and test_mubuf_opcode_table_synthetic_forms. The immediate handling from #2100 (-0, -16..-1) is not touched.

AI-assisted.

Check each source of v_fma_mix_f32 and v_fma_mixlo_f16 on its own: op_sel_hi alone reads the low binary16 half, op_sel with op_sel_hi the high half, and op_sel alone is refused. Keeps a swapped-source control. Test only; Refs R0Y00#2103.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head fa2b5f7 (test-only change: tests/rdna2_tools_check.py, +86 lines, no tool code touched).

Findings: none blocking.

  • The new test pins the half-select per source position for v_fma_mix_f32 and v_fma_mixlo_f16, with exact lowered text, the refusal class ("High-half selection requires an f16 operand") from both parse_fma_mix and lower(), and a swapped-source control. This matches the maintainer's request on #2103.
  • No lowering is added or changed, so no new GPU readback is needed for this PR. The test checks the lowered text and parsed fields, as the existing fma_mix tests do.
  • Overlap: no other open or merged PR adds this discriminator.

Commands run locally (worktree at the PR head, 4 commits behind main):

  • python3 -B tests/rdna2_tools_check.py: Ran 158 tests, OK (skipped=19).
  • python3 tests/docs_links_check.py: ok. python3 tests/bidi_controls_check.py: ok. git diff --check origin/main...HEAD: clean.
  • Mutation 1 (op_sel pairing for positions 1 and 2 swapped in lower()): 5 failures. Restored.
  • Mutation 2 (high-half refusal limited to positions 0 and 1 in parse_fma_mix): 2 failures. Restored.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Win2025 receipt for head fa2b5f7.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit fa2b5f73d03b9faa75f49bc3c37a1af054819248:

  • Windows Python checks: tests/rdna2_tools_check.py ok (4.0s), PYCHECK name=tests/rdna2_tools_check.py rc=0
  • Python-only change (no builds, no CTest targets affected).
  • Real-GPU run not available (no lowering change in this PR).

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit b0f49ce into R0Y00:main Nov 26, 2026
5 checks passed
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