cpp-migration: lower the non-packed 16-bit integer VOP3 ops in the direct C++ compute path #3017

Closed
opened 2026-11-27 05:28:24 +00:00 by archielcqp-a11y · 0 comments
archielcqp-a11y commented 2026-11-27 05:28:24 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-27T05:28:24Z.


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_i16 and v_sub_nc_i16;
  • v_mul_lo_u16;
  • v_lshlrev_b16, v_lshrrev_b16 and v_ashrrev_i16;
  • v_min_u16, v_max_u16, v_min_i16 and v_max_i16.

A compute request that uses any of them falls back to gfx2hlsl.py. A local per-opcode VOP3 probe on 999e17cd found 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's GCNSubtarget::zeroesHigh16BitsOfDest ("On gfx10, all 16-bit instructions preserve the high bits").

The shifts take S1 shifted by S0[3:0], and the _i16 minimum and maximum compare signed halves. op_sel, source modifiers and clamp stay refused. The three-source 16-bit forms (v_mad_u16, v_mad_i16, min3, max3 and med3) are left for a follow-up.

Separate observation, not changed here: the direct path's binary16 v_add_f16, v_sub_f16, v_subrev_f16 and v_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):

  • each destination is preset to 0xcafebabe;
  • the twelve operations run on 64 lanes whose sources have nonzero high halves and every shift count;
  • the results are compared with a CPU reference.

The controls check the op_sel refusal, 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 logical v_ashrrev_i16. Mutated lowerings must fail the readback.

AI-assisted.

Checklist

  • I checked for an existing issue or pull request for this change.
  • I did not include game files, dumps, distribution links or credentials.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6640595607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3017). Originally posted by [archielcqp-a11y](https://github.com/archielcqp-a11y) on 2026-11-27T05:28:24Z. --- ### 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_i16` and `v_sub_nc_i16`; - `v_mul_lo_u16`; - `v_lshlrev_b16`, `v_lshrrev_b16` and `v_ashrrev_i16`; - `v_min_u16`, `v_max_u16`, `v_min_i16` and `v_max_i16`. A compute request that uses any of them falls back to `gfx2hlsl.py`. A local per-opcode VOP3 probe on `999e17cd` found 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's `GCNSubtarget::zeroesHigh16BitsOfDest` ("On gfx10, all 16-bit instructions preserve the high bits"). The shifts take S1 shifted by S0[3:0], and the `_i16` minimum and maximum compare signed halves. `op_sel`, source modifiers and `clamp` stay refused. The three-source 16-bit forms (`v_mad_u16`, `v_mad_i16`, `min3`, `max3` and `med3`) are left for a follow-up. Separate observation, not changed here: the direct path's binary16 `v_add_f16`, `v_sub_f16`, `v_subrev_f16` and `v_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`): - each destination is preset to 0xcafebabe; - the twelve operations run on 64 lanes whose sources have nonzero high halves and every shift count; - the results are compared with a CPU reference. The controls check the `op_sel` refusal, 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 logical `v_ashrrev_i16`. Mutated lowerings must fail the readback. AI-assisted. ### Checklist - [x] I checked for an existing issue or pull request for this change. - [x] I did not include game files, dumps, distribution links or credentials.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#3017
No description provided.