cpp-migration: lower the non-packed 16-bit integer VOP3 ops in the direct C++ compute path #3017
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#3017
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@archielcqp-a11y on GitHub · 2026-11-27 05:28 UTC · original
Problem
Target branch
cpp-migration. Part of #2935 (instruction coverage: integer ALU). I'm taking this; the pull request follows.The direct compute path refuses 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.A compute request that uses any of them falls back to
gfx2hlsl.py. A local per-opcode VOP3 probe on999e17cdfound them, and no issue or PR covers them for the direct path. #669 settles the semantic question these ops had.Proposal
Lower them in
src/gfx1013_direct_compute.inl. Each writes D[15:0] from S0[15:0] and S1[15:0], and keeps D[31:16]. That is the rule #669 records from an RDNA 2 silicon measurement and from LLVM'sGCNSubtarget::zeroesHigh16BitsOfDest("On gfx10, all 16-bit instructions preserve the high bits").The shifts take S1 shifted by S0[3:0], and the
_i16minimum and maximum compare signed halves.op_sel, source modifiers andclampstay refused. The three-source 16-bit forms (v_mad_u16,v_mad_i16,min3,max3andmed3) are left for a follow-up.Separate observation, not changed here: 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 would be a separate fix with its own readback.Alternatives
Zeroing the high half is simpler, but RDNA 2 silicon keeps it, so code that relies on the other half surviving would read wrong values. Keeping the refusal leaves these requests on the Python path, which the migration is meant to replace.
Verification
A source-built dispatch (
tests/native_int16_check.py controls|hardware):The controls check the
op_selrefusal, and that these references differ from the expected words: a zeroed high half, a five-bit shift count, signed and unsigned order exchanged, and a logicalv_ashrrev_i16. Mutated lowerings must fail the readback.AI-assisted.
Checklist