pixel_aot: read v_fma_mix op_sel_hi as the binary16 flag and op_sel as the half #2103
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2103
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2103/head"
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?
@RenzoWit35 on GitHub · 2026-11-25 00:22 UTC · original
RenzoWit35:pixel_aot/fma-mix-op-sel→main· +76 −21 · 4 files · 1 commits · closed without mergingChange
tools/pixel_aot.pyread the twov_fma_mix*select fields the wrong way round. It treatedop_selas "this source is binary16" andop_sel_hias "use the high half". LLVM 15 uses the opposite assignment (AMDGPUDAGToDAGISel::SelectVOP3PMadMixModsImplandAMDGPUInstPrinter::printOpSelHi).tools/ffx_dispatch_aot.py,tools/startup/gfx2hlsl.pyand theop_sel/op_sel_hibit positions intools/disasm_rdna2.pyalready follow LLVM. The draw fixture's reference encoded the same swapped reading, so the fixture passed.Refs #2054
Lowering: each source is lowered with
is_f16 = op_sel_hiandis_hi = op_sel.parse_fma_mixstill returns the printed fields unchanged; the swap happens where they are consumed.op_selon a binary32 source (noop_sel_hi) is now refused withop_sel selects a half only for a binary16 (op_sel_hi) source, rather than given a meaning. Before this change the opposite case was refused.Fixture: the two
FMA_MIX_BODYlines that used the old reading are respelled in LLVM's assignment:op_sel:[1,1,0] op_sel_hi:[1,0,0]becomesop_sel:[1,0,0] op_sel_hi:[1,1,0];op_sel:[1,1,0]becomesop_sel_hi:[1,1,0].The generated HLSL is byte-identical to
main(compared withcmp), sofma_mix_referenceand the expected pixels are unchanged. The other three lines set both fields alike, so they read the same either way.New controls:
op_sel_hi binary16 source, which drops src1'sop_sel_hiso the packed word is read as binary32;check_fma_mix_operand_selection, run fromcheck_controls. For every source position ofv_fma_mix_f32andv_fma_mixlo_f16it checks three things:op_sel_hialone giveswiden16(word);op_selwithop_sel_higiveswiden16(word >> 16);op_selalone is refused with the message above.tests/rdna2_tools_check.py: its fma_mix cases used the old reading in several places, and it is in the pure-Python list, so it is updated with the fix:0c1920cc2c26524cstill decodes the same, and is now a refusal check;0c0920cc2c26525clowers to the same operands as before;op_sel_hi-only negative control is replaced by twoop_sel-without-op_sel_hicontrols.docs/experiments.md: the fma_mix paragraph states the corrected assignment and the new controls.Verification
Branch commit
eed1450e, based onmainat65c11640. Windows 11 build 26300.9974, DXC from Windows SDK 10.0.26100.0, debug layer as configured by thedevpreset.pixel_aot_core_vector_*runscheck_fma_mix_draw, including all six mutations, each of which reported a mismatch.Fail-first runs, with the new tests in place:
tools/pixel_aot.pyfrommain(the old reading)pixel_aot_check.pycontrols exit 1 (ValueError: High-half selection requires an f16 operand);rdna2_tools_checkFAILtest_vop3p_fma_mix_inline_abs_neg_modifiers; the fixture is refusedziporder swapped backcheck_fma_mix_operand_selectionfails at('_f32', 0, 'alu20, alu21, alu22);')Not run:
pixel_aot_check.py binary: LLVM 15 (llvm-mc,llvm-objcopy,libLLVM) is not installed on this host. The Ubuntu job assembles the respelled fixture lines with LLVM 15.hardwaretest.Evidence and follow-up
ffx_dispatch_aotandgfx2hlsl. It does not include the native hardware readback that #2054's first "done when" item asks for: oneop_sel-only and oneop_sel_hi-only form on RDNA. D3D12 cannot run native gfx10 code, so that needs a native path such as HIP. HenceRefs, notFixes.op_selon a binary32 source: this is a conservative choice. LLVM never selects that form, and no reference here defines what hardware does with it.Checklist
AI-assisted (Claude Code).
🤖 Generated with Claude Code
@ChazY11 on GitHub · 2026-11-25 00:32 UTC · original
#2100 already landed this swap — what is left here is the docstring and two test edits, and a rebase has to be careful not to undo #2100
mainat72e26e7falready carries the field swap from #2100:Same two changes this PR makes. So the review effort here should go to what is not in main yet, which is still worth having:
parse_fma_mixdocstring, which states the LLVM 15 provenance (SelectVOP3PMadMixModsImpl,printOpSelHi) and, better than #2100's one-liner, says whyop_selon a binary32 source is refused rather than given a meaning;"op_sel selects a half only for a binary16 (op_sel_hi) source", which names the field that was wrong instead of restating the invariant;tests/pixel_aot_check.pyandtests/rdna2_tools_check.pyupdates and thedocs/experiments.mdline.The rebase hazard, measured
git merge-tree --write-tree origin/main pr-2103conflicts indocs/experiments.md, andtools/pixel_aot.pywould apply — but note what the naiveapplication does. Diffing against today's
main:Those three lines are #2100's, added after this branch was cut. Merged as-is this PR removes them: a negative inline constant would go back to being
ambiguous without the refusal, and
-0would lose its sign. The merge is textually clean at that site, which is exactly the dangerous case — nothingflags it.
So when you rebase, the resolution is "keep both": the
-16..-1refusal and the-0branch from #2100, plus your docstring and message. If you wouldrather not carry the duplicate half, the smaller PR is: docstring + message + the two test files, on top of today's
main.What I would keep regardless of who lands it
The docstring is the part that will still matter in a year. It is the only place in the tree that records why the assignment is what it is, with the
LLVM symbol names, and it is the thing I would have wanted when I was reading this code cold earlier today — I had to reconstruct the same conclusion
from
gfx2hlsl.mix()refusingop_seloutright.One addition worth making while you are there: the assignment is still not settled by hardware.
#2054asks for a native readback on RDNA 2, and nothingin the tree establishes it; the docstring could say "LLVM 15's reading, unverified against hardware" in as many words, so a later reader does not treat
it as measured.
AI-assisted; the
maincontents and the merge-tree conflict above were checked locally at72e26e7f.@R0Y00 on GitHub · 2026-11-25 00:49 UTC · original
The selector correction is on main via #2100. 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.
@tedin7 on GitHub · 2026-11-25 12:44 UTC · original
@RenzoWit35 could you rebase this branch onto current
mainand force-push?GitHub reports head
eed1450eas conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(b1a644ae):docs/experiments.mdtests/pixel_aot_check.pytests/rdna2_tools_check.pytools/pixel_aot.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 16:58 UTC · original
@RenzoWit35 thanks for this fix. Update: the same change is already on
mainthrough #2100 (merge commit72e26e7f06, same change).tools/pixel_aot.pyon currentmain(lines 2661-2685) already pairsop_selwithop_sel_hithe way this branch does, so a rebase would leave no net diff here.Unless you see a case this branch covers that #2100 does not, this PR can be closed as a duplicate. Please point to the case if there is one.
AI-assisted; commands listed were executed locally.
@R0Y00 on GitHub · 2026-11-26 04:47 UTC · original
The pixel AOT selector fix is already on main through #2100 (
72e26e7f), which uses op_sel_hi for binary16 and op_sel for the half. Thanks for tracing the mismatch to both the translator and the old reference. Closing this as superseded by #2100. The RDNA 1 signed-zero report concerns a separate behavior under #2729.@tedin7 on GitHub · 2026-11-25 00:27 UTC · original · reviewed
Review of head
eed1450e1b(comment only, no merge).Result: SKIPPED. The PR is CONFLICTING and its change is already on main.
Findings:
git merge-tree --write-tree --name-only origin/main HEADreports content conflicts indocs/experiments.md,tests/pixel_aot_check.py,tests/rdna2_tools_check.pyandtools/pixel_aot.py.origin/mainalready containsc1e83dd6("pixel_aot: read v_fma_mix op_sel_hi as the binary16 flag and op_sel as the high half").lower()there already zipsop_sel_hias the binary16 flag andop_selas the half. This PR's logic change duplicates it.dc9ba9ed, mixed-precision source refusal rules), so a rebase would need a fresh look at the remaining delta. The device-free per-source control and the extraop_selmutation may still be worth a small rebased PR.Commands executed locally:
git fetchof the PR head, then worktree HEAD check (matcheseed1450e)git merge-tree --write-tree --name-only origin/main HEAD(conflicts)git diff --statand a targeted diff read oftools/pixel_aot.pyanddocs/experiments.mdgit diff --check origin/main...HEAD(clean)gh pr checks 2103(no checks)rg -n -C3 'zip\(tokens, op_sel'onorigin/main:tools/pixel_aot.pyMutations: not run, because the code path is already on main and the PR cannot be merged as is.
AI-assisted; commands listed were executed locally.
Pull request closed