shader: lower the non-packed 16-bit integer VOP3 ops in the direct C++ compute path #3018
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3018"
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:29:24Z.
Fixes #3017 on
main(part of #2935, instruction coverage: integer ALU). Refs #669.Summary
The direct compute frontend refused twelve VOP3-only 16-bit integer operations with
direct DXIL lowering for <name>:v_add_nc_u16,v_sub_nc_u16,v_add_nc_i16andv_sub_nc_i16;v_mul_lo_u16;v_lshlrev_b16,v_lshrrev_b16andv_ashrrev_i16;v_min_u16,v_max_u16,v_min_i16andv_max_i16.Semantics: each writes D[15:0] from S0[15:0] and S1[15:0], and D[31:16] keeps its value. #669 records two sources for that:
GCNSubtarget::zeroesHigh16BitsOfDest, which says "On gfx10, all 16-bit instructions preserve the high bits".The shifts take S1 shifted by S0[3:0]. Additions, subtractions and the multiply wrap modulo 2^16. The
_i16minimum and maximum compare signed halves, andv_ashrrev_i16sign-extends.Refused:
op_selselects other halves, so it stays refused (unsupported <name> op_sel). Source modifiers andclampstay refused by the path's existing rule.Not covered: the three-source 16-bit forms (
v_mad_u16,v_mad_i16,min3,max3andmed3).Separate observation, not changed: the direct path's binary16
v_add_f16,v_sub_f16,v_subrev_f16andv_mul_f16(#2964) zero D[31:16] in their non-SDWA form (and rounded, 65535). By the same gfx10 rule they should keep it. That belongs in a separate fix with its own readback.Fixture
tests/native_int16_check.py controls|hardware(tests/cmake/native_int16.cmake). The words were assembled with LLVM 15 (llvm-mc -mcpu=gfx1013).op_selonv_add_nc_u16is refused;v_ashrrev_i16.Results
cpp-migration999e17cdplus this change, Windows 10 build 19045, NVIDIA GeForce RTX 3080, driver 32.0.15.9174.native_int16_controlsnative_int16_hardware(local Agility replay, see below)0x0000e995against0xcafee995)native_align_bfm_hardware(neighbour, same local replay)docs_links_check,bidi_controls_checkCapability skip. The registered
native_store_replayuses the inbox D3D12 runtime. On Windows 10 that runtime doesn't report shader model 6.6, sonative_int16_hardwarereports a skip (77) here. The readback rows above used a local copy of the replay linked with the app-local Agility SDK exports (D3D12SDKVersion620, as inoffscreen_check). That copy isn't part of this change. A run on Windows 11 or with Agility would confirm the registered test.This PR is independent of #3016. Both add branches to the same function in
src/gfx1013_direct_compute.inl, at different places.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:37:19Z.
Review: COMMENTED
What works
direct compute frontend previously refused. Each correctly preserves
D[31:16] while writing D[15:0] from S0[15:0]+S1[15:0], matching RDNA
2 silicon measurements and LLVM's zeroesHigh... behavior.
low()mask helper (and x, 65535 ~16 bits), thesext()for signed operations, and the shift/comparelogic all follow the existing patterns in the direct compute lowering.
references; hardware mode validates all 384 words across 32 lanes.
Issues
highvariable and its use in the preceding block (line'z = ir.binary("and", read(i.dst), "4294901760") | low(r)').
The mask
4294901760=0xFFFF0000=~0xFFFF= the high half.)This is correct but the magic number could be a comment or a named
const for readability.
v_max3, v_med3) are explicitly acknowledged as not covered here.
Good forward reference.
Recommendations
4294901760(0xFFFFlow()helper could be a class method to makethe pattern reusable for future lowerings.
Overall
Solid instruction lowering with thorough testing and documentation.
The RDNA 2 ISA references are well-grounded. Approvable.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T11:54:43Z.
Review: APPROVED
Reviewed
fb760133after retargeting tomain, with #3051 and #3048 before it in the tested integration treed1a0367c. I rebuiltcompile_dxilandnative_store_replay, then ranctest --preset <dev|release> --no-tests=error -V -R '^(native_int16_(ternary_)?(controls|hardware)|native_bitscan_(controls|hardware))$'. Debug and Release /O2 each passed 6/6. The RTX readback matched 768 words and guards across the two groups, with destination high halves preserved. The compile fixture refusedop_sel; the zeroed-high, shift-width, reversed-order and logical-shift controls differ as expected. The separate ternary and bit-scan fixtures still pass. Windows 11 26200.9974, SDK 10.0.26100, RTX 4060 Laptop driver 32.0.16.1656, native replay debug layer off. Hosted Windows, Linux Python and gfx1013 checks passed for this head.