help wanted: GPU translation, part 6 (cross-lane operations) #2117

Open
opened 2026-11-25 00:55:06 +00:00 by denn0x · 10 comments
denn0x commented 2026-11-25 00:55:06 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:55:06Z.


The startup translator models one lane, so every instruction that reads another lane is refused. In a private executable's pixel programs (decode only, aggregate counts), 695 programs use DPP (19,902 instructions), and none of those reads the lane itself. Hundreds more use v_readlane / v_writelane / v_permlanex16.

Each item below is one PR. Each needs the ISA or LLVM 15 semantics cited, a source-built fixture, and a negative control that fails when the lane is wrong.

item form count (instructions) suggested lowering
A quad broadcasts quad_perm:[0,0,0,0], [1,1,1,1], [2,2,2,2] (with bound_ctrl) 6,342 the coarse-derivative idiom (see #1996 item B): ddx_coarse/ddy_coarse, or QuadReadLaneAt in SM 6.0+ pixel stages
B quad swaps quad_perm:[1,0,3,2], [2,3,0,1], [3,2,1,0] 8,971 QuadReadAcrossX / QuadReadAcrossY / QuadReadAcrossDiagonal (SM 6.0)
C pair broadcasts [1,1,3,3], [0,0,2,2], [2,3,2,3], [0,1,0,1] 2,419 fine derivatives or QuadReadLaneAt
D wave reductions: row_mirror, row_half_mirror, v_permlanex16_b32 ..., 0, 0, v_readlane_b32 ..., 31 2,170 DPP + 1,085 permlane + 852 readlane recognise the whole reduction and lower it to WaveActiveMin/Max/Sum; refuse partial shapes
E SGPR spill to VGPR lanes: v_writelane_b32 vN, sM, k ... v_readlane_b32 sM, vN, k with constant k hundreds per lane index an exact lowering with no cross-lane model: one scalar slot per (VGPR, k)

Notes:

  • B and C need helper lanes to be active, as the quad intrinsics do in pixel shaders. Say so in the fixture.
  • In vertex stages these forms appear only rarely (1 program here). Pixel stages come first.
  • v_readlane reads a lane whatever EXEC says. Any proof that a value is uniform must cover lanes outside the entry mask, or the lane select must be shown to be active. See the question on #2032.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594613234 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:55:06Z. --- The startup translator models one lane, so every instruction that reads another lane is refused. In a private executable's pixel programs (decode only, aggregate counts), 695 programs use DPP (19,902 instructions), and none of those reads the lane itself. Hundreds more use `v_readlane` / `v_writelane` / `v_permlanex16`. Each item below is one PR. Each needs the ISA or LLVM 15 semantics cited, a source-built fixture, and a negative control that fails when the lane is wrong. | item | form | count (instructions) | suggested lowering | |---|---|---|---| | A | quad broadcasts `quad_perm:[0,0,0,0]`, `[1,1,1,1]`, `[2,2,2,2]` (with `bound_ctrl`) | 6,342 | the coarse-derivative idiom (see #1996 item B): `ddx_coarse`/`ddy_coarse`, or `QuadReadLaneAt` in SM 6.0+ pixel stages | | B | quad swaps `quad_perm:[1,0,3,2]`, `[2,3,0,1]`, `[3,2,1,0]` | 8,971 | `QuadReadAcrossX` / `QuadReadAcrossY` / `QuadReadAcrossDiagonal` (SM 6.0) | | C | pair broadcasts `[1,1,3,3]`, `[0,0,2,2]`, `[2,3,2,3]`, `[0,1,0,1]` | 2,419 | fine derivatives or `QuadReadLaneAt` | | D | wave reductions: `row_mirror`, `row_half_mirror`, `v_permlanex16_b32 ..., 0, 0`, `v_readlane_b32 ..., 31` | 2,170 DPP + 1,085 permlane + 852 readlane | recognise the whole reduction and lower it to `WaveActiveMin/Max/Sum`; refuse partial shapes | | E | SGPR spill to VGPR lanes: `v_writelane_b32 vN, sM, k` ... `v_readlane_b32 sM, vN, k` with constant k | hundreds per lane index | an exact lowering with no cross-lane model: one scalar slot per (VGPR, k) | **Notes:** - B and C need helper lanes to be active, as the quad intrinsics do in pixel shaders. Say so in the fixture. - In vertex stages these forms appear only rarely (1 program here). Pixel stages come first. - `v_readlane` reads a lane whatever EXEC says. Any proof that a value is uniform must cover lanes outside the entry mask, or the lane select must be shown to be active. See the question on #2032.
tedin7 commented 2026-11-25 02:02:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:23:23Z.


Picking up Items A (quad broadcast DPP), B (quad swap DPP), and C (pair broadcast DPP) as separate small PRs with WARP readback tests.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149494414 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7149494414). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:23:23Z. --- Picking up Items A (quad broadcast DPP), B (quad swap DPP), and C (pair broadcast DPP) as separate small PRs with WARP readback tests.
tedin7 commented 2026-11-25 03:01:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:36:42Z.


Picking up Item E (constant-lane SGPR spill/reload v_writelane_b32/v_readlane_b32 in pixel stages) with unit + D3D12 WARP readback tests.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150948055 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7150948055). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:36:42Z. --- Picking up Item E (constant-lane SGPR spill/reload `v_writelane_b32`/`v_readlane_b32` in pixel stages) with unit + D3D12 WARP readback tests.
tedin7 commented 2026-11-25 03:01:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:47:18Z.


Picking up Item D DPP slice (row_mirror / row_half_mirror wave reductions) on top of the merged DPP base; v_permlanex16/v_readlane remain in #2032.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151187795 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7151187795). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:47:18Z. --- Picking up Item D DPP slice (row_mirror / row_half_mirror wave reductions) on top of the merged DPP base; v_permlanex16/v_readlane remain in #2032.
tedin7 commented 2026-11-25 03:01:24 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:48:13Z.


Releasing the Item D row_mirror / row_half_mirror claim: these read lanes outside the 2x2 quad, and the translator can only prove whole-quad EXEC, so a sound lowering needs a whole-wave EXEC proof (or the whole-reduction recognition) first. Free for anyone with a plan for that.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151207579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7151207579). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:48:13Z. --- Releasing the Item D row_mirror / row_half_mirror claim: these read lanes outside the 2x2 quad, and the translator can only prove whole-quad EXEC, so a sound lowering needs a whole-wave EXEC proof (or the whole-reduction recognition) first. Free for anyone with a plan for that.
roansystemlabs commented 2026-11-25 06:01:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T05:06:51Z.


I'd like to take item D, the wave reductions, with a plan for the whole-wave EXEC problem raised when it was released. If someone already has it in progress, I'll step back and review.

Plan: recognise the complete reduction rather than lowering its instructions one by one.

First slice (one PR):

  • wave32 only, in the pixel stage of tools/startup/gfx2hlsl.py.
  • Accepted: the whole-wave form, i.e. EXEC saved and all lanes enabled (s_or_saveexec_b32 ..., -1), inactive lanes filled with the operation's identity, the row_half_mirror / row_mirror DPP steps, v_permlanex16_b32 ..., 0, 0 to combine the two rows, v_readlane_b32 ..., 31, and EXEC restored. Operations: v_min_u32, v_max_u32, v_min_i32, v_max_i32 and v_add_nc_u32. The chain becomes one WaveActiveMin / WaveActiveMax / WaveActiveSum of the input, with a uniform scalar result.
  • Refused by name: partial chains, missing or reordered steps, mixed operations, a readlane lane other than 31, a wrong identity, EXEC not restored, a branch target inside the chain, wave64 and float operations.
  • Contract: the console packs pixels into waves in its own way, so a correct program cannot depend on which pixels share a wave; the lowering reduces over the active lanes of the desktop wave. Because inactive lanes hold the identity, helper lanes do not change the result. The PR will state this and test it.

Later slices, each its own PR: float min/max with the NaN rules already used in the translator, then wave64 if the census shows it.

Evidence: source-built chains assembled with LLVM 15 llvm-mc for gfx1013 (encodings checked on the bytes), translated and compiled with DXC ps_6_0, drawn on WARP and an RTX 3070 with fenced readback against a CPU reference per desktop wave (the lane count is read and reported per adapter, not assumed). Partly covered quads exercise helper lanes. Negative controls: every partial chain refused with its reason, and mutations (Sum for Max, wrong identity, readlane 30, one mirror step removed, guard removed) must fail. Not tested: AMD hardware and console wave64.

@denn0x, if the census can share the aggregate shape of these chains (step order, operations, whether EXEC is saved first), I'll match the first slice to it; otherwise it follows the documented Mesa and LLVM form and says so.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153462376 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7153462376). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T05:06:51Z. --- I'd like to take item D, the wave reductions, with a plan for the whole-wave EXEC problem raised when it was released. If someone already has it in progress, I'll step back and review. Plan: recognise the complete reduction rather than lowering its instructions one by one. First slice (one PR): - wave32 only, in the pixel stage of tools/startup/gfx2hlsl.py. - Accepted: the whole-wave form, i.e. EXEC saved and all lanes enabled (s_or_saveexec_b32 ..., -1), inactive lanes filled with the operation's identity, the row_half_mirror / row_mirror DPP steps, v_permlanex16_b32 ..., 0, 0 to combine the two rows, v_readlane_b32 ..., 31, and EXEC restored. Operations: v_min_u32, v_max_u32, v_min_i32, v_max_i32 and v_add_nc_u32. The chain becomes one WaveActiveMin / WaveActiveMax / WaveActiveSum of the input, with a uniform scalar result. - Refused by name: partial chains, missing or reordered steps, mixed operations, a readlane lane other than 31, a wrong identity, EXEC not restored, a branch target inside the chain, wave64 and float operations. - Contract: the console packs pixels into waves in its own way, so a correct program cannot depend on which pixels share a wave; the lowering reduces over the active lanes of the desktop wave. Because inactive lanes hold the identity, helper lanes do not change the result. The PR will state this and test it. Later slices, each its own PR: float min/max with the NaN rules already used in the translator, then wave64 if the census shows it. Evidence: source-built chains assembled with LLVM 15 llvm-mc for gfx1013 (encodings checked on the bytes), translated and compiled with DXC ps_6_0, drawn on WARP and an RTX 3070 with fenced readback against a CPU reference per desktop wave (the lane count is read and reported per adapter, not assumed). Partly covered quads exercise helper lanes. Negative controls: every partial chain refused with its reason, and mutations (Sum for Max, wrong identity, readlane 30, one mirror step removed, guard removed) must fail. Not tested: AMD hardware and console wave64. @denn0x, if the census can share the aggregate shape of these chains (step order, operations, whether EXEC is saved first), I'll match the first slice to it; otherwise it follows the documented Mesa and LLVM form and says so. AI-assisted.
denn0x commented 2026-11-25 06:01:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T05:26:20Z.


Thanks for taking item D. Here is the aggregate shape from our census of a private executable's pixel programs: decode only, distinct pixel programs counted once, numbers only.

  • How many:

    • 384 distinct pixel programs contain the chain, 725 chains in all.
    • Locally, about 380 distinct vertex/pixel pairs are refused at the mirror steps and at v_permlanex16_b32. Most of those pairs have other blockers as well.
  • EXEC: every chain starts with s_or_saveexec ..., -1, so all lanes are enabled. All 725 do; none runs at the entry EXEC.

  • Step order: the steps run in the same order in every chain:

    1. quad_perm:[1,0,3,2]
    2. quad_perm:[2,3,0,1]
    3. row_half_mirror
    4. row_mirror
    5. v_permlanex16_b32 ..., 0, 0
    6. the readlane

    The first two steps are DPP16 quad swaps on the same operation. Your plan starts at the mirrors, so it would need to accept those two steps as part of the chain.

  • Operations: only three appear.

Operation Chains
v_or_b32 385
v_min_u32, then v_max_u32 on the same input 334
v_min_u32 alone 2
v_min_u32 + v_max_u32 + v_or_b32 in one stretch 4

The min-then-max chains run back to back: the second saves EXEC again before its own reduction.
We see no v_add_nc_u32, no signed min/max and no float operations. So v_or_b32 (WaveActiveBitOr) is the most common case here, and it is not in the first slice as written.

  • Wave size:
Form Chains Ends with
wave32 (s_or_saveexec_b32) about 535 EXEC restored with s_mov_b32 exec_lo, ..., then v_readlane_b32 ..., 31
wave64 (s_or_saveexec_b64) about 190 v_readlane_b32 ..., 0, and ..., 63 in the min/max chains; EXEC restored with s_mov_b64 exec, ...

So wave64 is about a quarter of the chains.

  • Not measured: how the inactive lanes get the identity (we only matched the DPP, EXEC, permlane and readlane steps), and whether a branch target lands inside a chain.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7153771111 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7153771111). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T05:26:20Z. --- Thanks for taking item D. Here is the aggregate shape from our census of a private executable's pixel programs: decode only, distinct pixel programs counted once, numbers only. - **How many:** - 384 distinct pixel programs contain the chain, 725 chains in all. - Locally, about 380 distinct vertex/pixel pairs are refused at the mirror steps and at `v_permlanex16_b32`. Most of those pairs have other blockers as well. - **EXEC:** every chain starts with `s_or_saveexec ..., -1`, so all lanes are enabled. All 725 do; none runs at the entry EXEC. - **Step order:** the steps run in the same order in every chain: 1. `quad_perm:[1,0,3,2]` 2. `quad_perm:[2,3,0,1]` 3. `row_half_mirror` 4. `row_mirror` 5. `v_permlanex16_b32 ..., 0, 0` 6. the readlane The first two steps are DPP16 quad swaps on the same operation. Your plan starts at the mirrors, so it would need to accept those two steps as part of the chain. - **Operations:** only three appear. | Operation | Chains | |---|---:| | `v_or_b32` | 385 | | `v_min_u32`, then `v_max_u32` on the same input | 334 | | `v_min_u32` alone | 2 | | `v_min_u32` + `v_max_u32` + `v_or_b32` in one stretch | 4 | The min-then-max chains run back to back: the second saves EXEC again before its own reduction. We see no `v_add_nc_u32`, no signed min/max and no float operations. So `v_or_b32` (WaveActiveBitOr) is the most common case here, and it is not in the first slice as written. - **Wave size:** | Form | Chains | Ends with | |---|---:|---| | wave32 (`s_or_saveexec_b32`) | about 535 | EXEC restored with `s_mov_b32 exec_lo, ...`, then `v_readlane_b32 ..., 31` | | wave64 (`s_or_saveexec_b64`) | about 190 | `v_readlane_b32 ..., 0`, and `..., 63` in the min/max chains; EXEC restored with `s_mov_b64 exec, ...` | So wave64 is about a quarter of the chains. - **Not measured:** how the inactive lanes get the identity (we only matched the DPP, EXEC, permlane and readlane steps), and whether a branch target lands inside a chain. AI-assisted.
roansystemlabs commented 2026-11-25 06:01:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T05:42:26Z.


@denn0x thank you, this is exactly what the first slice needed. I'll change it to match the census before running the final checks:

  • The chain starts at s_or_saveexec_b32 ..., -1 and includes the two quad_perm swaps ([1,0,3,2], then [2,3,0,1]) before row_half_mirror, row_mirror, v_permlanex16_b32 ..., 0, 0 and v_readlane_b32 ..., 31, with EXEC restored by s_mov_b32 exec_lo, ....
  • First slice, wave32 only: v_or_b32 to WaveActiveBitOr, and v_min_u32 / v_max_u32 to WaveActiveMin / WaveActiveMax, including the min-then-max pair run back to back with its own saveexec. v_add_nc_u32 and the signed forms come out of this slice, since the census has none.
  • wave64 (readlane 0 / 63, s_mov_b64 exec) becomes the second slice.

One open point decides whether the lowering is sound: the instructions between s_or_saveexec ..., -1 and the first quad_perm. With every lane enabled, the lanes that were inactive on entry must hold the operation's identity (0 for OR, UINT_MAX for min, 0 for max), or the reduction picks up stale values. If the census can show the aggregate shape of that stretch (for example a v_cndmask on the saved mask, a v_mov under the entry EXEC, or nothing), I'll accept exactly that form and refuse the rest by name. Until then the translator keeps refusing these chains.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154060839 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7154060839). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T05:42:26Z. --- @denn0x thank you, this is exactly what the first slice needed. I'll change it to match the census before running the final checks: - The chain starts at `s_or_saveexec_b32 ..., -1` and includes the two `quad_perm` swaps (`[1,0,3,2]`, then `[2,3,0,1]`) before `row_half_mirror`, `row_mirror`, `v_permlanex16_b32 ..., 0, 0` and `v_readlane_b32 ..., 31`, with EXEC restored by `s_mov_b32 exec_lo, ...`. - First slice, wave32 only: `v_or_b32` to `WaveActiveBitOr`, and `v_min_u32` / `v_max_u32` to `WaveActiveMin` / `WaveActiveMax`, including the min-then-max pair run back to back with its own saveexec. `v_add_nc_u32` and the signed forms come out of this slice, since the census has none. - wave64 (`readlane 0` / `63`, `s_mov_b64 exec`) becomes the second slice. One open point decides whether the lowering is sound: the instructions between `s_or_saveexec ..., -1` and the first `quad_perm`. With every lane enabled, the lanes that were inactive on entry must hold the operation's identity (0 for OR, UINT_MAX for min, 0 for max), or the reduction picks up stale values. If the census can show the aggregate shape of that stretch (for example a `v_cndmask` on the saved mask, a `v_mov` under the entry EXEC, or nothing), I'll accept exactly that form and refuse the rest by name. Until then the translator keeps refusing these chains. AI-assisted.
Miffedrandir commented 2026-11-26 11:02:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Miffedrandir on 2026-11-26T10:25:36Z.


@roansystemlabs answering your open point on item D, from a local capture of graphics pipeline requests (decode only, aggregate counts, distinct pixel programs counted once; 578 programs, 225 with chains, 614 chains: 574 wave32, 40 wave64).

The stretch between s_or_saveexec_b32 ..., -1 and the first quad_perm is always exactly one v_cndmask_b32_e64 vT, <identity>, vSrc, sSaved, where sSaved is the saveexec destination and the identity is 0 for v_or_b32 (214 chains), -1 for v_min_u32 (180) and 0 for v_max_u32 (180). All 574 wave32 chains match one of three exact shapes:

  1. OR (214): s_or_saveexec_b32 s, -1 → v_cndmask_b32_e64 vT, 0, vX, s → v_or_b32_dpp vT, vT, vT with quad_perm:[1,0,3,2], quad_perm:[2,3,0,1], row_half_mirror, row_mirror (all row_mask:0xf bank_mask:0xf fi:1) → v_permlanex16_b32 vU, vT, 0, 0 → v_or_b32_e32 vT, vU, vT → s_mov_b32 exec_lo, s → v_readlane_b32 sR, vT, 31 immediately.
  2. MIN (180): the same with identity -1. Its readlane is not immediate: after s_mov_b32 exec_lo, s comes a v_cndmask_b32_sdwa, then the next chain's s_or_saveexec_b32 ..., -1, and only then v_readlane_b32 sR, vT, 31.
  3. MAX (180), always right after a MIN: s_or_saveexec_b32 s', -1 → (the MIN's v_readlane_b32 ..., 31) → v_cndmask_b32_e64 vT, 0, vX, s' → the same four DPP steps → v_permlanex16_b32 → v_max_u32_e32 → s_mov_b32 exec_lo, s' → v_readlane_b32 ..., 31 immediately.

So a matcher that requires the readlane right after the restore would miss the 180 MIN chains, and one that requires the v_cndmask right after the saveexec would miss the 180 MAX chains. Other points:

  • No branch target lands inside any chain (0 of 614).
  • The wave64 chains (40) have scalar instructions between the fill and the first step (s_lshr_b32 / s_lshl_b32, s_sub_i32) and use readlane ..., 63. I didn't break them down further.
  • Use of the results: in the programs I read, MIN/MAX/OR feed a scalar loop over the OR's set bits (s_ff1_i32_b32), and each lane gates its work on its own bit (v_bfe_u32 v, vMask, sBit, 1 → v_cmpx_ne_i32). That supports your contract that per-pixel results don't depend on which pixels share a wave.
  • Impact here: these chains are the first refusal for 115 of the 311 graphics pipelines my capture still fails to translate (3 distinct pixel programs, each with one OR + MIN + MAX set).

Happy to run your branch against this capture and report the refusal counts before and after. AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189349802 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7189349802). Originally posted by [Miffedrandir](https://github.com/Miffedrandir) on 2026-11-26T10:25:36Z. --- @roansystemlabs answering your open point on item D, from a local capture of graphics pipeline requests (decode only, aggregate counts, distinct pixel programs counted once; 578 programs, 225 with chains, 614 chains: 574 wave32, 40 wave64). **The stretch between `s_or_saveexec_b32 ..., -1` and the first `quad_perm` is always exactly one `v_cndmask_b32_e64 vT, <identity>, vSrc, sSaved`**, where `sSaved` is the saveexec destination and the identity is `0` for `v_or_b32` (214 chains), `-1` for `v_min_u32` (180) and `0` for `v_max_u32` (180). All 574 wave32 chains match one of three exact shapes: 1. **OR (214):** `s_or_saveexec_b32 s, -1` → `v_cndmask_b32_e64 vT, 0, vX, s` → `v_or_b32_dpp vT, vT, vT` with `quad_perm:[1,0,3,2]`, `quad_perm:[2,3,0,1]`, `row_half_mirror`, `row_mirror` (all `row_mask:0xf bank_mask:0xf fi:1`) → `v_permlanex16_b32 vU, vT, 0, 0` → `v_or_b32_e32 vT, vU, vT` → `s_mov_b32 exec_lo, s` → `v_readlane_b32 sR, vT, 31` immediately. 2. **MIN (180):** the same with identity `-1`. Its readlane is *not* immediate: after `s_mov_b32 exec_lo, s` comes a `v_cndmask_b32_sdwa`, then the next chain's `s_or_saveexec_b32 ..., -1`, and only then `v_readlane_b32 sR, vT, 31`. 3. **MAX (180), always right after a MIN:** `s_or_saveexec_b32 s', -1` → (the MIN's `v_readlane_b32 ..., 31`) → `v_cndmask_b32_e64 vT, 0, vX, s'` → the same four DPP steps → `v_permlanex16_b32` → `v_max_u32_e32` → `s_mov_b32 exec_lo, s'` → `v_readlane_b32 ..., 31` immediately. So a matcher that requires the readlane right after the restore would miss the 180 MIN chains, and one that requires the `v_cndmask` right after the saveexec would miss the 180 MAX chains. Other points: - No branch target lands inside any chain (0 of 614). - The wave64 chains (40) have scalar instructions between the fill and the first step (`s_lshr_b32` / `s_lshl_b32`, `s_sub_i32`) and use `readlane ..., 63`. I didn't break them down further. - **Use of the results:** in the programs I read, MIN/MAX/OR feed a scalar loop over the OR's set bits (`s_ff1_i32_b32`), and each lane gates its work on its own bit (`v_bfe_u32 v, vMask, sBit, 1` → `v_cmpx_ne_i32`). That supports your contract that per-pixel results don't depend on which pixels share a wave. - **Impact here:** these chains are the first refusal for 115 of the 311 graphics pipelines my capture still fails to translate (3 distinct pixel programs, each with one OR + MIN + MAX set). Happy to run your branch against this capture and report the refusal counts before and after. AI-assisted.
roansystemlabs commented 2026-11-26 13:03:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-26T12:43:49Z.


@Miffedrandir thank you, this was the missing piece. Your three shapes match what the branch now recognises:

  • the fill is exactly v_cndmask_b32_e64 vT, <identity>, vX, sS with 0 / -1 / 0, under the saveexec's own SGPR; any other fill, constant or mask is refused by name;
  • OR and MAX read lane 31 right after the restore;
  • MIN reads it later: restore, one v_cndmask_b32_sdwa (lowered as usual), the MAX chain's s_or_saveexec_b32 ..., -1, then the readlane, which the MAX chain carries before its fill. It is refused if anything in between rewrites the MIN's vT, if that readlane overwrites the MAX's saved EXEC, or if no MAX chain carries it.

The DPP steps accept fi:1 (every lane is on, so it decides nothing), and the combine takes vT, vU, vT as in your shape 1. Wave64 stays out for the next slice.

The PR is https://github.com/R0Y00/Xbox2Windows/pull/2835. We'd gladly take your offer: running the branch against your capture and posting the refusal counts before and after (graphics pipelines failing, and how many of them still stop first at a reduction chain) would be the best check of the shapes that we can't run ourselves.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7192383360 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7192383360). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-26T12:43:49Z. --- @Miffedrandir thank you, this was the missing piece. Your three shapes match what the branch now recognises: - the fill is exactly `v_cndmask_b32_e64 vT, <identity>, vX, sS` with `0` / `-1` / `0`, under the saveexec's own SGPR; any other fill, constant or mask is refused by name; - OR and MAX read lane 31 right after the restore; - MIN reads it later: restore, one `v_cndmask_b32_sdwa` (lowered as usual), the MAX chain's `s_or_saveexec_b32 ..., -1`, then the readlane, which the MAX chain carries before its fill. It is refused if anything in between rewrites the MIN's `vT`, if that readlane overwrites the MAX's saved EXEC, or if no MAX chain carries it. The DPP steps accept `fi:1` (every lane is on, so it decides nothing), and the combine takes `vT, vU, vT` as in your shape 1. Wave64 stays out for the next slice. The PR is https://github.com/R0Y00/Xbox2Windows/pull/2835. We'd gladly take your offer: running the branch against your capture and posting the refusal counts before and after (graphics pipelines failing, and how many of them still stop first at a reduction chain) would be the best check of the shapes that we can't run ourselves. AI-assisted.
SimSalabimse commented 2026-11-27 20:11:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-27T20:11:08Z.


Claiming the #2125 item D follow-up: wave32 reduction chains in pixel programs that also have branches. #2835 already accepts the straight-line OR, MIN and MAX shapes. This slice keeps that matcher and allows the same chain when the rest of the program has branches, provided the chain itself stays straight, has no branch target inside it, and EXEC is saved and restored as in the accepted shapes. Wave64 stays out of this PR. Tests will be source-built pixel fixtures with a uniform branch before and after the chain, a control that a branch into the chain stays refused, and WARP plus hardware readback against a CPU reduction.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7227257012 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2125#issuecomment-7227257012). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-27T20:11:08Z. --- Claiming the #2125 item D follow-up: wave32 reduction chains in pixel programs that also have branches. #2835 already accepts the straight-line OR, MIN and MAX shapes. This slice keeps that matcher and allows the same chain when the rest of the program has branches, provided the chain itself stays straight, has no branch target inside it, and EXEC is saved and restored as in the accepted shapes. Wave64 stays out of this PR. Tests will be source-built pixel fixtures with a uniform branch before and after the chain, a control that a branch into the chain stays refused, and WARP plus hardware readback against a CPU reduction. 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#2117
No description provided.