cpp-migration: lower v_permlane16_b32 and v_permlanex16_b32 in the direct C++ compute path #3021

Closed
opened 2026-11-27 05:55:43 +00:00 by Leyukaka · 0 comments
Leyukaka commented 2026-11-27 05:55:43 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T05:55:43Z.


Target branch cpp-migration. Part of #2935 (instruction coverage). I would like to take this; please say if you already have it locally and I will drop it. #1543 covers these ops in tools/compute_store_aot.py; this is the direct C++ path.

Gap. Direct compute refuses v_permlane16_b32 and v_permlanex16_b32 with "direct DXIL lowering for v_permlane16_b32" (and x16).

Measured on a local capture of 2,689 compute requests (counts and instruction shape only), with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on cpp-migration 999e17cd plus #3010.

  • 47 requests stop first at one of the two ops: 32 at v_permlane16_b32, 15 at v_permlanex16_b32.
  • All 47 have bit 20 of .sa dword 4 clear. That makes them wave64 requests under #2999/#3006, which is not merged.
  • In every occurrence, src0 is a VGPR and there are no abs, neg, clamp or omod modifiers. When a literal appears, it is S1.
Op at the first refusal op_sel Selector sources (S1, S2) Requests
v_permlane16_b32 [0,1] (BOUND_CTRL) 32-bit literal, SGPR 26
v_permlane16_b32 [0,1] SGPR, SGPR 6
v_permlanex16_b32 none inline 0, inline 0 14
v_permlanex16_b32 [0,1] 32-bit literal, SGPR 1

Those 47 programs contain 244 occurrences:

Op op_sel Selector sources (S1, S2) Occurrences
v_permlanex16_b32 [0,1] 32-bit literal, SGPR 101
v_permlanex16_b32 [0,1] SGPR, SGPR 32
v_permlanex16_b32 none inline 0, inline 0 25
v_permlane16_b32 [0,1] 32-bit literal, SGPR 62
v_permlane16_b32 [0,1] SGPR, SGPR 24

disasm_rdna2.py prints the literal form as "unsupported VOP3A encoding". The encoding is the two VOP3A words followed by the 32-bit literal (12 bytes), which gfx10 VOP3 allows; the LLVM 15 gfx1013 assembler does not accept a literal in that operand.

Plan:

  • Lower both ops in the direct path, for wave32 and for the wave64 path.
  • v_permlane16_b32 D, S0, S1, S2: lane i in a 16-lane row reads S0 from lane sel of the same row, where sel = ({S2, S1} >> (4 * (i & 15))) & 15. S1 holds the selectors of row lanes 0..7, and S2 those of row lanes 8..15.
  • v_permlanex16_b32 reads lane sel of the other row in the same 32-lane half: 0-15 with 16-31, and 32-47 with 48-63.
  • S1 and S2 are uniform: an SGPR, a literal or an inline constant. Each lane picks its 4-bit field at run time, so the selectors need not be compile-time constants.
  • op_sel[0] is FI and op_sel[1] is BOUND_CTRL. For an inactive source lane, I assume the rule the DPP lowering uses:
    • the source is usable when FI is set or the source lane is active;
    • an unusable source gives 0 with BOUND_CTRL; otherwise the destination keeps its old value.
      A D3D12 readback checks the lowering against that model, not RDNA2 itself. The measured x16 0,0 form has FI and BOUND_CTRL clear, so it depends on this case.
  • Rows and their pairs stay inside one 32-lane half. I will check in the code that the wave64 path keeps each half in one physical wave32, so that no exchange is needed.
  • Refused: other op_sel bits, abs/neg/clamp/omod, and a VGPR selector.

Tests: a hardware readback against a CPU reference, in wave32 and wave64 requests.

  • The measured forms:
    • v_permlanex16_b32 with BOUND_CTRL and literal-plus-SGPR or SGPR selectors;
    • v_permlanex16_b32 with inline 0 selectors and no op_sel;
    • v_permlane16_b32 with BOUND_CTRL and literal-plus-SGPR or SGPR selectors.
  • Selectors that differ per row lane.
  • Inactive source lanes with FI and BOUND_CTRL set and clear.
  • Mutants:
    • reading the same row for x16;
    • swapping S1 and S2;
    • ignoring BOUND_CTRL.

Measurement: the census and the run's requests, before and after, with the next refusal of the requests that move.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6640900452 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3021). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T05:55:43Z. --- Target branch `cpp-migration`. Part of #2935 (instruction coverage). I would like to take this; please say if you already have it locally and I will drop it. #1543 covers these ops in `tools/compute_store_aot.py`; this is the direct C++ path. **Gap.** Direct compute refuses `v_permlane16_b32` and `v_permlanex16_b32` with "direct DXIL lowering for v_permlane16_b32" (and `x16`). **Measured** on a local capture of 2,689 compute requests (counts and instruction shape only), with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `cpp-migration` `999e17cd` plus #3010. - 47 requests stop first at one of the two ops: 32 at `v_permlane16_b32`, 15 at `v_permlanex16_b32`. - All 47 have bit 20 of `.sa` dword 4 clear. That makes them wave64 requests under #2999/#3006, which is not merged. - In every occurrence, src0 is a VGPR and there are no abs, neg, clamp or omod modifiers. When a literal appears, it is S1. | Op at the first refusal | `op_sel` | Selector sources (S1, S2) | Requests | |---|---|---|---| | `v_permlane16_b32` | `[0,1]` (BOUND_CTRL) | 32-bit literal, SGPR | 26 | | `v_permlane16_b32` | `[0,1]` | SGPR, SGPR | 6 | | `v_permlanex16_b32` | none | inline 0, inline 0 | 14 | | `v_permlanex16_b32` | `[0,1]` | 32-bit literal, SGPR | 1 | Those 47 programs contain 244 occurrences: | Op | `op_sel` | Selector sources (S1, S2) | Occurrences | |---|---|---|---| | `v_permlanex16_b32` | `[0,1]` | 32-bit literal, SGPR | 101 | | `v_permlanex16_b32` | `[0,1]` | SGPR, SGPR | 32 | | `v_permlanex16_b32` | none | inline 0, inline 0 | 25 | | `v_permlane16_b32` | `[0,1]` | 32-bit literal, SGPR | 62 | | `v_permlane16_b32` | `[0,1]` | SGPR, SGPR | 24 | `disasm_rdna2.py` prints the literal form as "unsupported VOP3A encoding". The encoding is the two VOP3A words followed by the 32-bit literal (12 bytes), which gfx10 VOP3 allows; the LLVM 15 gfx1013 assembler does not accept a literal in that operand. **Plan:** - Lower both ops in the direct path, for wave32 and for the wave64 path. - `v_permlane16_b32 D, S0, S1, S2`: lane `i` in a 16-lane row reads `S0` from lane `sel` of the same row, where `sel = ({S2, S1} >> (4 * (i & 15))) & 15`. S1 holds the selectors of row lanes 0..7, and S2 those of row lanes 8..15. - `v_permlanex16_b32` reads lane `sel` of the other row in the same 32-lane half: 0-15 with 16-31, and 32-47 with 48-63. - S1 and S2 are uniform: an SGPR, a literal or an inline constant. Each lane picks its 4-bit field at run time, so the selectors need not be compile-time constants. - `op_sel[0]` is FI and `op_sel[1]` is BOUND_CTRL. For an inactive source lane, I assume the rule the DPP lowering uses: - the source is usable when FI is set or the source lane is active; - an unusable source gives 0 with BOUND_CTRL; otherwise the destination keeps its old value. A D3D12 readback checks the lowering against that model, not RDNA2 itself. The measured `x16` `0,0` form has FI and BOUND_CTRL clear, so it depends on this case. - Rows and their pairs stay inside one 32-lane half. I will check in the code that the wave64 path keeps each half in one physical wave32, so that no exchange is needed. - Refused: other `op_sel` bits, `abs`/`neg`/`clamp`/`omod`, and a VGPR selector. **Tests:** a hardware readback against a CPU reference, in wave32 and wave64 requests. - The measured forms: - `v_permlanex16_b32` with BOUND_CTRL and literal-plus-SGPR or SGPR selectors; - `v_permlanex16_b32` with inline 0 selectors and no `op_sel`; - `v_permlane16_b32` with BOUND_CTRL and literal-plus-SGPR or SGPR selectors. - Selectors that differ per row lane. - Inactive source lanes with FI and BOUND_CTRL set and clear. - Mutants: - reading the same row for `x16`; - swapping S1 and S2; - ignoring BOUND_CTRL. **Measurement:** the census and the run's requests, before and after, with the next refusal of the requests that move. AI-assisted.
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#3021
No description provided.