pixel_aot: read v_fma_mix op_sel_hi as the binary16 flag and op_sel as the high half #2093
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2100"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-25T00:14:12Z.
pixel_aotread the two VOP3P selector fields ofv_fma_mix_f32,v_fma_mixlo_f16andv_fma_mixhi_f16the wrong way round:op_sel[i]as "source i is binary16" andop_sel_hi[i]as "high half". LLVM, whose syntaxdisasm_rdna2.pyprints, defines the opposite inSelectVOP3PMadMixModsImpl(llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp):LLVM's tests print
v_fma_mix_f32 v0, v0, v1, v2 op_sel_hi:[1,1,1]for three low binary16 halves. For three high halves they printop_sel:[1,1,1] op_sel_hi:[1,1,1](llvm/test/CodeGen/AMDGPU/mad-mix.ll, GFX1100 checks). The old parser refused the first form.The selector roles already match LLVM in two other places.
tools/ffx_dispatch_aot.pyrequiresop_sel_hi:[0,1,0]for its binary16 source and usesop_sel:[0,1,0]for the high half.tools/startup/gfx2hlsl.pyusesop_sel_hias the binary16 flag formixlo/mixhiand refusesop_sel.Changes
parse_fma_mixand thev_fma_mix*handler useop_sel_hias the binary16 flag andop_selas the half select.op_sel[i] = 1on a binary32 source (op_sel_hi[i] = 0) is refused.SelectVOP3PMadMixModsImplnever sets it, and I found no description of its hardware effect.fma_mix_operand:-0(NEG on inline 0) lowers toasfloat(0x80000000u); it used to lower to +0.0.-1..-16are refused. The disassembler prints the same text for the inline negative integer and for NEG on inline1..16. This also refuses genuine inline-1..-16, which used to lower to their integer words, and|-N|.pixel_aot_check.py: the draw program and itsop_selmutation.rdna2_tools_check.py: the combined-modifier encodings, the end-to-end shader, thebad_tailandbad_shader_asmnegative cases, and one line of thellvm-mccomparison fixture. That fixture is skipped withoutLLVM_LIBand was skipped in the run below.pso_readiness_check.py: the readiness example, which only checks opcode support.op_sel:[1,0,0] op_sel_hi:[1,0,0]mean the same in both readings and are unchanged.-0, and the ambiguous-N.0c1920cc2c26524cfrom #745 still decodes to the same text. The bytes were built in #745 to reproduce the existing fixture text, which used the old reading. That text setsop_selon binary32 source 1, so it is now refused; the test asserts the refusal.docs/experiments.mdstates the field roles and cites LLVM.scan_unsupported_shaders.pynotes that its pattern matches opcode and destination only, whilelower()validates the selectors.Tests
Windows 11, MSVC,
cmake --preset dev, WARP:Negative control: I ran the updated tests against the previous
tools/pixel_aot.py.pixel_aot_core_vector_warpfails incheck_fma_mix_draw, becauseparse_fma_mixraises onop_sel_hi:[1,1,0].rdna2_tools_check.pyfailstest_vop3p_fma_mix_inline_abs_neg_modifiers.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:20:19Z.
Review: COMMENTED
Review of head
5cdecfe8786d53449c8d78aebf41f72a18ac5d31.Semantics:
op_sel_hi[i]now means binary16 andop_sel[i]picks the high half, which matches LLVM's printed form. The parser check, the lowerer zip, the-0handling and the ambiguous negative inline constants are all consistent with that. Tests and docs follow. Only Python, docs and test files changed, with no CMake changes. The change is clean-room, with LLVM cited only as a reference.Commands executed:
git merge-tree --write-tree --name-only origin/main HEAD: no conflictspython3 tests/pixel_aot_check.py,tests/pso_readiness_check.py,tests/rdna2_tools_check.py(154 tests, OK),tests/docs_links_check.py,tests/bidi_controls_check.py: all PASSgit diff --check origin/main...HEAD: cleanctest -R '^(pixel_aot_core_vector_|rdna2_tools_check|pso_readiness_check)': 4/4 passed in each config. The Windows Python checks for the three touched tests also passed.Mutations killed (both reported by
tests/rdna2_tools_check.py, then reverted):parse_fma_mixvalidation zip swapped back to(op_sel, op_sel_hi): 1 failure.loweroperand zip swapped back to(op_sel, op_sel_hi): 1 failure.P1: 0. P2: 0.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T00:20:16Z.
Ran the pure-Python half here, mutated the swap both ways — caught by
rdna2_tools_check.pyI cannot run the draw half (no
llvm-mcon this machine), so this is the part I could execute:Two mutations, each reverted:
zip(tokens, op_sel, op_sel_hi)(the old reading)for f16, hi in zip(op_sel, op_sel_hi)The second one matters more than it looks:
if any(hi and not f16 ...)reads the same under either unpacking, so a reviewer skimming the diff sees nochange — the swap is only visible in the tuple order. It is caught, which means one of the fixtures actually distinguishes the two.
The guard's new naming is right — I checked it against LLVM's rule rather than by reading the diff
zipyields(op_sel_i, op_sel_hi_i), unpacked as(hi, f16), sohiis the high-half selector andf16is the conversion flag — the assignmentLLVM uses and the one this PR is adopting. Under the old reading that guard would have refused a different set of forms, which is exactly the kind of
thing that silently changes meaning in a swap commit.
Two things I would ask before this merges
1. The PR carries a second behaviour that the title does not mention. Besides the swap, it adds a refusal and a special case:
That is defensible on its own — a negative inline constant is ambiguous with the neg-modifier syntax, and
-0needs its sign kept — but it is adifferent change from "read
op_sel_hias the binary16 flag", and it is the part a reviewer of this PR is least likely to be looking at. Either say soin the description, or split it; both are cheaper than discovering it later.
2. One assertion was replaced rather than moved. In
rdna2_tools_check.pythis block used to assert the lowered operand strings for thereproduction form:
and is now
The new expectation is correct under the new reading — that encoding now has
op_selset on a non-f16 source — but the mixed-operand lowering lost itsonly direct string assertion. If another fixture covers
fma_mix_operandfor an f16 source, ignore this; I could not find one inrdna2_tools_check.py(fma_mix_operandis imported at line 21 and used at the old site only).What is still not established here, and cannot be by this PR
Which assignment the gfx1013 encoding actually has. This PR makes
pixel_aotfollow LLVM, which is the stronger position —gfx2hlslalreadyreads it that way and refuses
op_seloutright — but it is a consistency argument, not hardware evidence. I said the same on #2054: settled only onRDNA 2 hardware, or by a second LLVM version printing the same fields.
AI-assisted; the three commands and both mutations above were executed locally on Windows 11 build 26300.9974.