shader: keep D[31:16] in the direct path's binary16 add, sub, subrev and mul #3020
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3020"
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 archielcqp-a11y on 2026-11-27T05:37:54Z.
Fixes #3019 on
cpp-migration(part of #2935). Refs #2964, #669.Summary
In the direct compute path, the non-SDWA forms of
v_add_f16,v_sub_f16,v_subrev_f16andv_mul_f16wrote the rounded binary16 result to D[15:0] and zeroed D[31:16]. They now keep D[31:16]. The change is onevector_writeinsrc/gfx1013_direct_compute.inl.Why:
GCNSubtarget::zeroesHigh16BitsOfDestlists exactly these four ops,V_ADD/SUB/SUBREV/MUL_F16in_e32and_e64, under "On gfx10, all 16-bit instructions preserve the high bits", and returns false from GFX10 on.v_cvt_f16_f32already keeps the high half.No silicon measurement of these four f16 ops is known to me. #2964 states the zeroing "matches RDNA 2" without a source. I asked its author on #3019 and will adjust if a measurement says otherwise.
Unchanged: SDWA forms still place the result through
dst_sel/dst_unused, and the refusals.Test change
tests/native_f16_alu_check.pyalready put0xabcdin the high half of every destination before the operation. Its comparator and model now require each stored word to be0xabcdin the high half and the binary16 result in the low half.The mutant it rejects changes from "a kept high half" to "a zeroed high half". The test isn't weaker: it pins the opposite contract with the same coverage (82 cases, 16 refusals), and the old lowering now fails it.
New page:
docs/experiments/native-direct-f16-high-half.md.Results
cpp-migration999e17cdplus this change, Windows 10 build 19045, NVIDIA GeForce RTX 3080, driver 32.0.15.9174.native_f16_alu_check.py modelnative_f16_alu_irnative_f16_alu_hardware(local Agility replay, see below)docs_links_check,bidi_controls_checkCapability skip. The registered
native_store_replayuses the inbox D3D12 runtime, which doesn't report shader model 6.6 on Windows 10, sonative_f16_alu_hardwarereports a skip (77) here. The readback rows used a local copy of the replay linked with the app-local Agility SDK exports (D3D12SDKVersion620). That copy isn't part of this change.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:42:34Z.
Review: COMMENTED
What works
gfx1013_direct_compute.inl switches
and rounded, 65535toor and(old_dst, 0xFFFF0000), and(rounded, 65535). This keepsD[31:16] exactly matching the LLVM zeroesHigh16BitsOfDest behavior
for these four f16 VOP3 ops.
v_cvt_f16_f32above thisblock already keeps the high half, and #669 established the same
rule for non-packed 16-bit integer ops from silicon measurements.
native_f16_alu_check.pyswaps themutant from reject_zeroed_high to reject_zeroed_lo (now that the
high half is kept instead of zeroed). The
HI_Areference valuemust be present in every stored destination.
Issues
dst_sel/dst_unusedwhich already handle the layout. The commentacknowledges this -- good.
packed_half_rne(bits)path is only taken when!i.subword. For the subword variant,place_subwordhandles thelayout and the diff doesn't change it. Verify this is consistent with
RDNA 2 where subword forms also keep D[31:16].
Recommendations
4294901760(0xFFFF0000) and65535couldbe commented as hex for readability.
Overall
Tiny, correct change matching LLVM and existing code in the
same function. The model/IR/gpu readback tests confirm the fix.
Approvable.
function. The model/IR/gpu readback tests confirm the fix.
Approvable.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T06:04:24Z.
Review: COMMENTED
Independent Release
/O2retest atb4128920163840ef75d7b903049a1b8c9c2a2833. I rebuiltnative_compute_ir_dump,native_store_replay, andcompile_dxil, then ranctest --preset release --no-tests=error -V -R '^native_f16_alu_(ir|hardware)$'as separate per-test invocations. The IR check matched 82 results and all 16 rejection diagnostics. The registered inbox D3D12 hardware check matched all 164 words, including the high-half sentinels, on Windows 11 build 26200.9974 with RTX 4060 Laptop and driver 32.0.16.1656. The replay does not enable the D3D12 debug layer. Neither test skipped.LLVM 20.1.8 lists all four e32/e64 opcode pairs and returns false from GFX10 onward. The desktop readback verifies the lowering. Direct RDNA 2 measurement for these four floating-point opcodes is still open.