shader: pixel_aot forward branches on a scalar compare (s_cbranch_scc0/scc1) — scope question #1406

Open
opened 2026-11-24 10:59:16 +00:00 by MasterDomino · 10 comments
MasterDomino commented 2026-11-24 10:59:16 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T10:59:16Z.


With masked regions now accepting the s_mov close and one else arm (#1328, #1371), I measured which control flow still separates the local pixel programs from pixel_aot. Scalar-condition branches turn out to be much more common than deeper region nesting. This is a proposal and a scope question only; no code yet.

Setup

  • upstream/main at 04e307cf, LLVM 15.0.7 LLVM-C.dll (pixel_aot.disassemble with offsets).
  • One local input (12,101 PS records, the same population as #711; 12,000 disassemble). Aggregates only.
  • Structural scans in linear order, without control-flow analysis.

What remains after #1371

  • Regions: 7,175 records contain masked regions. In only 770 of them is every region structured (643 at depth 1, 106 at depth 2, 21 deeper). In the other 6,404 records, at least one region contains a branch other than its skip, a crossed close or an unclosed save. So nesting alone would add about 106 records.
  • Branches: 9,473 records have branches outside any region. Records with each forward branch kind:
branch (forward) records
s_cbranch_execz 8,024
s_cbranch_vccnz 7,960
s_cbranch_scc0 7,841
s_cbranch_scc1 7,053
s_branch 6,846
s_cbranch_vccz 5,110
  • 5,122 records have only forward branches; 5,049 have at least one backward branch (a loop).

Forward SCC branches

SCC is written by scalar instructions, so a branch on it is taken or not taken by the whole wave. In this input it is almost always a scalar compare. Last SCC writer before the branch:

writer branches
s_cmp_eq_* 44,501
s_cmp_lg_* 19,170
s_andn2_* 11,821
s_cmp_lt_* 8,123
s_cmp_gt_* 1,421
s_cmp_eq_u64 1,184
s_cmpk_eq_* 1,092
s_cmp_ge_* 1,002

pixel_aot already tracks a compare's SCC as an HLSL bool (scc{i}, read by s_cselect/s_cmov).

Shapes of the forward s_cbranch_scc0/s_cbranch_scc1 branches:

shape branches records with at least one
skip: the target is forward and the skipped block contains no branch 27,361 (scc1 24,724, scc0 2,637) 8,423
diamond: the block ends in a forward s_branch over a branch-free second block 9,004 (scc0 7,451, scc1 1,553) 3,201
other (nested branches or regions inside) 52,646 7,277
backward or not on an instruction boundary 13,259 n/a

Of the 36,365 skip and diamond blocks, 11,348 contain only ALU and scalar work. 25,017 contain an image, buffer, scalar load or export, and 3,159 write EXEC.

Proposal

Stage 1: one forward s_cbranch_scc0/s_cbranch_scc1 over a branch-free block.

  • SCC source: a tracked s_cmp_*/s_cmpk_* result on tracked scalar operands. Any other or untracked SCC is refused.
  • Target: must be a later instruction boundary, checked against real offsets as for the region skips.
  • Block: the per-lane vector ALU and scalar ALU that masked regions already admit (#976, #1064). No memory, sampling, export, EXEC writes, waits on pending work, nested branches or regions.
  • Lowering: the condition is uniform, so each register the block writes merges with a select on the branch condition (taken → outer value; not taken → block value), the same select form regions emit. Unlike in a masked region, SGPRs the block writes would merge the same way, because every lane sees the same path. A register first defined in the block stays undefined afterwards unless both paths define it.
  • Tests:
    • Draws (WARP + RX 9070 XT) with the branch taken, not taken, and data-dependent per draw through a constant.
    • Mutants that must mismatch: inverted scc0/scc1, and the branch dropped.
    • Refusals: wrong targets, an untracked SCC, and memory in the block.
    • An LLVM 15 round trip with labels.

Later stages, each a separate review:

  • the diamond with s_branch;
  • loads and samples inside a uniform block, which would need a real HLSL if instead of selects;
  • s_cbranch_vccz/vccnz, whose "any lane" meaning needs a uniformity argument first.

Questions

  1. Is a uniform select-merge acceptable for stage 1, or would you rather go straight to HLSL if blocks, so that later stages with samples share one lowering?
  2. Should scalar writes in the skipped block be in stage 1, or start with vector-only blocks?

If this direction works, I'd take stage 1.

Limits

  • One local input. Linear scans: "skip" and "diamond" describe the instruction layout, not proven reachability.
  • These counts are shapes only. The scan's translator verdict still stops at unbound entry operands under the scanned inputs (#1314), so the number of records each stage unblocks is not measurable yet.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6580260900 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T10:59:16Z. --- With masked regions now accepting the s_mov close and one else arm (#1328, #1371), I measured which control flow still separates the local pixel programs from `pixel_aot`. Scalar-condition branches turn out to be much more common than deeper region nesting. This is a proposal and a scope question only; no code yet. ## Setup - `upstream/main` at `04e307cf`, LLVM 15.0.7 `LLVM-C.dll` (`pixel_aot.disassemble` with offsets). - One local input (12,101 PS records, the same population as #711; 12,000 disassemble). Aggregates only. - Structural scans in linear order, without control-flow analysis. ## What remains after #1371 - **Regions:** 7,175 records contain masked regions. In only 770 of them is every region structured (643 at depth 1, 106 at depth 2, 21 deeper). In the other 6,404 records, at least one region contains a branch other than its skip, a crossed close or an unclosed save. So nesting alone would add about 106 records. - **Branches:** 9,473 records have branches outside any region. Records with each forward branch kind: | branch (forward) | records | |---|---:| | `s_cbranch_execz` | 8,024 | | `s_cbranch_vccnz` | 7,960 | | `s_cbranch_scc0` | 7,841 | | `s_cbranch_scc1` | 7,053 | | `s_branch` | 6,846 | | `s_cbranch_vccz` | 5,110 | - 5,122 records have only forward branches; 5,049 have at least one backward branch (a loop). ## Forward SCC branches SCC is written by scalar instructions, so a branch on it is taken or not taken by the whole wave. In this input it is almost always a scalar compare. Last SCC writer before the branch: | writer | branches | |---|---:| | `s_cmp_eq_*` | 44,501 | | `s_cmp_lg_*` | 19,170 | | `s_andn2_*` | 11,821 | | `s_cmp_lt_*` | 8,123 | | `s_cmp_gt_*` | 1,421 | | `s_cmp_eq_u64` | 1,184 | | `s_cmpk_eq_*` | 1,092 | | `s_cmp_ge_*` | 1,002 | `pixel_aot` already tracks a compare's SCC as an HLSL bool (`scc{i}`, read by `s_cselect`/`s_cmov`). Shapes of the forward `s_cbranch_scc0`/`s_cbranch_scc1` branches: | shape | branches | records with at least one | |---|---:|---:| | skip: the target is forward and the skipped block contains no branch | 27,361 (scc1 24,724, scc0 2,637) | 8,423 | | diamond: the block ends in a forward `s_branch` over a branch-free second block | 9,004 (scc0 7,451, scc1 1,553) | 3,201 | | other (nested branches or regions inside) | 52,646 | 7,277 | | backward or not on an instruction boundary | 13,259 | n/a | Of the 36,365 skip and diamond blocks, 11,348 contain only ALU and scalar work. 25,017 contain an image, buffer, scalar load or export, and 3,159 write EXEC. ## Proposal **Stage 1:** one forward `s_cbranch_scc0`/`s_cbranch_scc1` over a branch-free block. - **SCC source:** a tracked `s_cmp_*`/`s_cmpk_*` result on tracked scalar operands. Any other or untracked SCC is refused. - **Target:** must be a later instruction boundary, checked against real offsets as for the region skips. - **Block:** the per-lane vector ALU and scalar ALU that masked regions already admit (#976, #1064). No memory, sampling, export, EXEC writes, waits on pending work, nested branches or regions. - **Lowering:** the condition is uniform, so each register the block writes merges with a select on the branch condition (taken → outer value; not taken → block value), the same select form regions emit. Unlike in a masked region, SGPRs the block writes would merge the same way, because every lane sees the same path. A register first defined in the block stays undefined afterwards unless both paths define it. - **Tests:** - Draws (WARP + RX 9070 XT) with the branch taken, not taken, and data-dependent per draw through a constant. - Mutants that must mismatch: inverted `scc0`/`scc1`, and the branch dropped. - Refusals: wrong targets, an untracked SCC, and memory in the block. - An LLVM 15 round trip with labels. **Later stages, each a separate review:** - the diamond with `s_branch`; - loads and samples inside a uniform block, which would need a real HLSL `if` instead of selects; - `s_cbranch_vccz`/`vccnz`, whose "any lane" meaning needs a uniformity argument first. ## Questions 1. Is a uniform select-merge acceptable for stage 1, or would you rather go straight to HLSL `if` blocks, so that later stages with samples share one lowering? 2. Should scalar writes in the skipped block be in stage 1, or start with vector-only blocks? If this direction works, I'd take stage 1. ## Limits - One local input. Linear scans: "skip" and "diamond" describe the instruction layout, not proven reachability. - These counts are shapes only. The scan's translator verdict still stops at unbound entry operands under the scanned inputs (#1314), so the number of records each stage unblocks is not measurable yet. AI-assisted.
R0Y00 commented 2026-11-24 12:03:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T11:22:58Z.


A single forward SCC-led skip is a good first PR. A select merge is fine for side-effect-free ALU that is safe to evaluate on either path. Start with vector writes so the first change can reuse the existing masked-region definedness checks. Require a tracked uniform scalar compare, the real forward target boundary, and an incoming definition for any VGPR later read after a conditional write. Keep memory, EXEC writes, observable scalar/wave updates and nesting out of this slice. The proposed polarity and dropped-branch controls, both directions with a runtime constant, and LLVM 15 round trip cover the key cases.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130024193 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7130024193). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T11:22:58Z. --- A single forward SCC-led skip is a good first PR. A select merge is fine for side-effect-free ALU that is safe to evaluate on either path. Start with vector writes so the first change can reuse the existing masked-region definedness checks. Require a tracked uniform scalar compare, the real forward target boundary, and an incoming definition for any VGPR later read after a conditional write. Keep memory, EXEC writes, observable scalar/wave updates and nesting out of this slice. The proposed polarity and dropped-branch controls, both directions with a runtime constant, and LLVM 15 round trip cover the key cases.
MasterDomino commented 2026-11-24 12:03:15 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T11:23:52Z.


Claiming stage 1 as scoped: one forward s_cbranch_scc0/scc1 skip over a vector-only block, a tracked uniform s_cmp SCC, the real forward target boundary, select merges with the existing masked-region definedness (an incoming definition required for any VGPR read after a conditional write), and memory, EXEC writes, scalar/wave updates and nesting kept out. Tests: both polarities and the dropped branch as mismatching controls, taken/not-taken through a runtime constant, LLVM 15 round trip. I'll link the PR here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130043835 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7130043835). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T11:23:52Z. --- Claiming stage 1 as scoped: one forward `s_cbranch_scc0`/`scc1` skip over a vector-only block, a tracked uniform `s_cmp` SCC, the real forward target boundary, select merges with the existing masked-region definedness (an incoming definition required for any VGPR read after a conditional write), and memory, EXEC writes, scalar/wave updates and nesting kept out. Tests: both polarities and the dropped branch as mismatching controls, taken/not-taken through a runtime constant, LLVM 15 round trip. I'll link the PR here. AI-assisted.
MasterDomino commented 2026-11-24 12:03:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T11:33:26Z.


Stage 1 PR: https://github.com/R0Y00/Xbox2Windows/pull/1440. Tracked s_cmp/s_bitcmp SCC only, real forward target, vector-only block merged with selects on SCC/!SCC using the masked-region definedness (also checked at the target), SCC/VCC preserved. WARP and RX 9070 XT: 6/6 cases (flag 0/1/7 for both forms) match, 6/6 polarity and dropped-branch mutant cases mismatch; 14/14 region and skip CTests pass.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130249702 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7130249702). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T11:33:26Z. --- Stage 1 PR: https://github.com/R0Y00/Xbox2Windows/pull/1440. Tracked `s_cmp`/`s_bitcmp` SCC only, real forward target, vector-only block merged with selects on SCC/!SCC using the masked-region definedness (also checked at the target), SCC/VCC preserved. WARP and RX 9070 XT: 6/6 cases (flag 0/1/7 for both forms) match, 6/6 polarity and dropped-branch mutant cases mismatch; 14/14 region and skip CTests pass. AI-assisted.
R0Y00 commented 2026-11-24 12:03:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T11:42:56Z.


The single forward SCC skip landed in #1440 at ea475f35. The Windows Release SCC-skip and existing EXEC-region fixtures passed on RTX 4060 Laptop and WARP (4/4, no skips). This covers one forward skip over vector ALU using a tracked uniform comparison, including the polarity and dropped-branch controls. The diamond and blocks with observable side effects remain outside this implementation.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130452900 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7130452900). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T11:42:56Z. --- The single forward SCC skip landed in #1440 at ea475f35. The Windows Release SCC-skip and existing EXEC-region fixtures passed on RTX 4060 Laptop and WARP (4/4, no skips). This covers one forward skip over vector ALU using a tracked uniform comparison, including the polarity and dropped-branch controls. The diamond and blocks with observable side effects remain outside this implementation.
MasterDomino commented 2026-11-24 12:03:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T11:44:41Z.


With stage 1 on main (#1440), here is a plan for stage 2, the diamond. On the local input that shape is 9,004 branches in 3,201 records. I'd like your go-ahead before coding.

Shape

s_cmp_* …                  ; tracked scalar compare
s_cbranch_scc0/scc1 ELSE   ; lands on the first instruction of the second block
  <block A>                ; runs when the branch is not taken
  s_branch JOIN            ; lands after block B
ELSE:
  <block B>                ; runs when the branch is taken
JOIN:

Scope

  • Condition: the same as stage 1: a tracked s_cmp/s_bitcmp SCC.
  • Targets: both must be real later boundaries. The conditional branch must land exactly on the instruction after the s_branch. The s_branch must be the last instruction of block A and land after block B. A diamond whose conditional branch lands anywhere else stays a stage-1 skip or is refused.
  • Blocks: both branch-free, with the same vector-only gate as stage 1.
  • Merge: this reuses the else-arm machinery from #1371. Block B starts from the pre-branch vector state; a register first defined in block A is undefined there until block B writes it. At JOIN each register merges as cond_A ? A : B, with the pre-branch value standing in for a block that did not write it. A register undefined before the branch and not written in both blocks stays undefined after JOIN.
  • SCC and VCC: preserved, since neither block writes scalar state.
  • Unchanged: memory, EXEC, scalar or wave updates, waits, nesting, backward branches and a second s_branch stay out.

Tests

  • Draws (WARP + RX 9070 XT), both polarities, runtime flag 0 / 1 / 7:
    • a register written in both blocks;
    • one in block A only;
    • one in block B only;
    • a block-B read of a register block A wrote, which must see the pre-branch value.
  • Mutants that must mismatch:
    • the s_branch dropped (A falls through into B);
    • the polarity flipped;
    • a stale-A expectation.
  • Refused:
    • the conditional branch landing on the s_branch or on JOIN;
    • the s_branch not last in block A, landing inside block B, or going backward;
    • a nested branch in either block.
  • LLVM 15 round trip with both labels.

Does this match what you want for stage 2? If so I'll take it.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7130490775 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7130490775). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T11:44:41Z. --- With stage 1 on main (#1440), here is a plan for stage 2, the diamond. On the local input that shape is 9,004 branches in 3,201 records. I'd like your go-ahead before coding. ## Shape ``` s_cmp_* … ; tracked scalar compare s_cbranch_scc0/scc1 ELSE ; lands on the first instruction of the second block <block A> ; runs when the branch is not taken s_branch JOIN ; lands after block B ELSE: <block B> ; runs when the branch is taken JOIN: ``` ## Scope - **Condition:** the same as stage 1: a tracked `s_cmp`/`s_bitcmp` SCC. - **Targets:** both must be real later boundaries. The conditional branch must land exactly on the instruction after the `s_branch`. The `s_branch` must be the last instruction of block A and land after block B. A diamond whose conditional branch lands anywhere else stays a stage-1 skip or is refused. - **Blocks:** both branch-free, with the same vector-only gate as stage 1. - **Merge:** this reuses the else-arm machinery from #1371. Block B starts from the pre-branch vector state; a register first defined in block A is undefined there until block B writes it. At JOIN each register merges as `cond_A ? A : B`, with the pre-branch value standing in for a block that did not write it. A register undefined before the branch and not written in both blocks stays undefined after JOIN. - **SCC and VCC:** preserved, since neither block writes scalar state. - **Unchanged:** memory, EXEC, scalar or wave updates, waits, nesting, backward branches and a second `s_branch` stay out. ## Tests - **Draws** (WARP + RX 9070 XT), both polarities, runtime flag 0 / 1 / 7: - a register written in both blocks; - one in block A only; - one in block B only; - a block-B read of a register block A wrote, which must see the pre-branch value. - **Mutants that must mismatch:** - the `s_branch` dropped (A falls through into B); - the polarity flipped; - a stale-A expectation. - **Refused:** - the conditional branch landing on the `s_branch` or on JOIN; - the `s_branch` not last in block A, landing inside block B, or going backward; - a nested branch in either block. - **LLVM 15 round trip** with both labels. Does this match what you want for stage 2? If so I'll take it. AI-assisted.
R0Y00 commented 2026-11-24 15:02:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T14:04:27Z.


Go ahead with stage 2 as a single structured forward SCC if/else diamond on top of #1440. Reuse the tracked uniform s_cmp/s_bitcmp condition and the existing branch-target decoding. Both targets must be real instruction boundaries. The conditional edge must enter B immediately after A’s terminal s_branch, and that s_branch must land exactly at JOIN, after B. Keep both arms within the existing vector-only gate and preserve SCC, VCC, and EXEC. Leave nesting, backward branches, memory, waits, and other observable side effects out of this slice.

Start both arms from the incoming VGPR state. Preserve an incoming value on any arm that leaves it alone. A value that was undefined on entry must be defined by both arms before a post-join read. Please keep both SCC polarities and runtime flags 0/1/7, the B-read-of-an-A-written register, the dropped-branch and flipped-polarity mutants, and the malformed-target rejection cases. Run the LLVM 15 round trip with both labels and report WARP and RX 9070 XT results separately.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7133797310 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7133797310). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T14:04:27Z. --- Go ahead with stage 2 as a single structured forward SCC if/else diamond on top of #1440. Reuse the tracked uniform `s_cmp`/`s_bitcmp` condition and the existing branch-target decoding. Both targets must be real instruction boundaries. The conditional edge must enter B immediately after A’s terminal `s_branch`, and that `s_branch` must land exactly at JOIN, after B. Keep both arms within the existing vector-only gate and preserve SCC, VCC, and EXEC. Leave nesting, backward branches, memory, waits, and other observable side effects out of this slice. Start both arms from the incoming VGPR state. Preserve an incoming value on any arm that leaves it alone. A value that was undefined on entry must be defined by both arms before a post-join read. Please keep both SCC polarities and runtime flags 0/1/7, the B-read-of-an-A-written register, the dropped-branch and flipped-polarity mutants, and the malformed-target rejection cases. Run the LLVM 15 round trip with both labels and report WARP and RX 9070 XT results separately.
MasterDomino commented 2026-11-24 15:02:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T14:59:35Z.


Claiming stage 2 as scoped (single forward SCC if/else diamond on top of #1440). PR link to follow.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135281760 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7135281760). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T14:59:35Z. --- Claiming stage 2 as scoped (single forward SCC if/else diamond on top of #1440). PR link to follow. AI-assisted.
MasterDomino commented 2026-11-24 16:03:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T15:14:43Z.


Stage 2 PR: https://github.com/R0Y00/Xbox2Windows/pull/1625. WARP: 6/6 diamond cases match, 8/8 mutant cases (stale-A, flipped polarity, dropped s_branch) mismatch. RX 9070 XT (32.0.31044.16): same, 6/6 and 8/8. LLVM 15 round trip with both labels passes; malformed targets, nesting and definedness controls in check_scc_diamond_controls.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135697708 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7135697708). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T15:14:43Z. --- Stage 2 PR: https://github.com/R0Y00/Xbox2Windows/pull/1625. WARP: 6/6 diamond cases match, 8/8 mutant cases (stale-A, flipped polarity, dropped s_branch) mismatch. RX 9070 XT (`32.0.31044.16`): same, 6/6 and 8/8. LLVM 15 round trip with both labels passes; malformed targets, nesting and definedness controls in `check_scc_diamond_controls`. AI-assisted.
MasterDomino commented 2026-11-24 16:03:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T16:03:21Z.


Stage 2 is on main (#1625). Before coding anything further, here are the measurements for the next step, and a question about order.

Source: one local input (12,101 PS records, the same population as #711; 12,000 disassemble), on stages 1+2 (117ebb8b), LLVM 15.0.7. Aggregates only.

What the remaining uniform SCC blocks contain

34,180 forward SCC blocks in 6,877 records: 25,176 skips (6,682 records) and 9,004 diamonds (3,201 records). Blocks that contain s_endpgm are not counted.

Contents (blocks / records) Count
s_waitcnt 24,148 / 5,858
s_load_* 19,345 / 5,147
s_buffer_load_* 16,135 / 5,784
scalar ALU write 15,556 / 5,092
image_sample* 10,857 / 4,249
vector ALU only 9,168 / 4,816
buffer_load_* 2,885 / 1,397
EXEC write 1,114 / 376
image_store 2 / 2
exp, buffer_store 0
  • Samples. 9,097 sample blocks also contain scalar loads, waits and SALU. In 8,993 of them the block loads the T# it samples with. Only 2 blocks contain nothing but a sample and a wait.
  • Reads after the join. 33,251 blocks write a VGPR that is read after the join. A sample is still outstanding at the join in 6,891 blocks.
  • Conditions. All conditions are s_cmp/s_cmpk, except 12 blocks (6 records) on s_bcnt1_i32_b64.

EXEC at the branch (linear estimate)

EXEC at the branch Blocks / records
entry mask 1,004 / 729
inside a WQM span 8,388 / 2,651
partial EXEC (masked region or after a discard) 24,788 / 5,215

Two possible next slices

A. Scalar state inside a uniform skip or diamond, at entry mask.

  • Allowed in the arms: the scalar loads the translator already lowers, waits, and the REGION_SALU subset.
  • SGPRs: one written in an arm is conditional after the join.
  • Loads: every load issued in an arm must be waited for in that arm. The pre-branch outstanding set is restored at the join, as for a skipped region.
  • Checks: the #987 stage-3 checks and the select merge are reused.
  • Reach: small, +170 blocks / +45 records.
  • Not in A: 130 entry-mask sample blocks, all _lz. 125 of them also need v_madak_f32, which the translator lowers but REGION_ALU does not admit.

B. Uniform branches inside a WQM span or under partial EXEC.

  • Why: about 97% of the blocks are here.
  • Reach: with slice A's scalar-load rules added, 990 records get at least one block admitted.
  • Needs: the branch is uniform in SCC, so the arm's lanes are the enclosing region's. The arm then has to compose with the masked-region merge instead of the entry mask.

Sampling inside an arm would be a later stage. It would be either a select over a speculative sample (static binding, defined derivatives) or an HLSL if with the merged values declared before it.

Would you prefer A first as the small, low-risk slice, or B directly? I'll wait for your answer before claiming.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137046444 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7137046444). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-24T16:03:21Z. --- Stage 2 is on main (#1625). Before coding anything further, here are the measurements for the next step, and a question about order. Source: one local input (12,101 PS records, the same population as #711; 12,000 disassemble), on stages 1+2 (`117ebb8b`), LLVM 15.0.7. Aggregates only. ## What the remaining uniform SCC blocks contain 34,180 forward SCC blocks in 6,877 records: 25,176 skips (6,682 records) and 9,004 diamonds (3,201 records). Blocks that contain `s_endpgm` are not counted. | Contents (blocks / records) | Count | |---|---| | `s_waitcnt` | 24,148 / 5,858 | | `s_load_*` | 19,345 / 5,147 | | `s_buffer_load_*` | 16,135 / 5,784 | | scalar ALU write | 15,556 / 5,092 | | `image_sample*` | 10,857 / 4,249 | | vector ALU only | 9,168 / 4,816 | | `buffer_load_*` | 2,885 / 1,397 | | EXEC write | 1,114 / 376 | | `image_store` | 2 / 2 | | `exp`, `buffer_store` | 0 | - **Samples.** 9,097 sample blocks also contain scalar loads, waits and SALU. In 8,993 of them the block loads the T# it samples with. Only 2 blocks contain nothing but a sample and a wait. - **Reads after the join.** 33,251 blocks write a VGPR that is read after the join. A sample is still outstanding at the join in 6,891 blocks. - **Conditions.** All conditions are `s_cmp`/`s_cmpk`, except 12 blocks (6 records) on `s_bcnt1_i32_b64`. ## EXEC at the branch (linear estimate) | EXEC at the branch | Blocks / records | |---|---| | entry mask | 1,004 / 729 | | inside a WQM span | 8,388 / 2,651 | | partial EXEC (masked region or after a discard) | 24,788 / 5,215 | ## Two possible next slices **A. Scalar state inside a uniform skip or diamond, at entry mask.** - **Allowed in the arms:** the scalar loads the translator already lowers, waits, and the `REGION_SALU` subset. - **SGPRs:** one written in an arm is conditional after the join. - **Loads:** every load issued in an arm must be waited for in that arm. The pre-branch outstanding set is restored at the join, as for a skipped region. - **Checks:** the #987 stage-3 checks and the select merge are reused. - **Reach:** small, +170 blocks / +45 records. - **Not in A:** 130 entry-mask sample blocks, all `_lz`. 125 of them also need `v_madak_f32`, which the translator lowers but `REGION_ALU` does not admit. **B. Uniform branches inside a WQM span or under partial EXEC.** - **Why:** about 97% of the blocks are here. - **Reach:** with slice A's scalar-load rules added, 990 records get at least one block admitted. - **Needs:** the branch is uniform in SCC, so the arm's lanes are the enclosing region's. The arm then has to compose with the masked-region merge instead of the entry mask. Sampling inside an arm would be a later stage. It would be either a select over a speculative sample (static binding, defined derivatives) or an HLSL `if` with the merged values declared before it. Would you prefer A first as the small, low-risk slice, or B directly? I'll wait for your answer before claiming. AI-assisted.
R0Y00 commented 2026-11-24 17:02:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:05:51Z.


Stage 2 landed in #1625 at 874cc3fa. The SCC diamond controls are included in both serial and parallel form coverage, and the final head passed both Linux jobs and Windows. Independent RTX and WARP Release draws passed after resolving the test registration conflict. This covers the approved forward diamond. Further branch shapes still need separate evidence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137112108 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1413#issuecomment-7137112108). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:05:51Z. --- Stage 2 landed in #1625 at 874cc3fa. The SCC diamond controls are included in both serial and parallel form coverage, and the final head passed both Linux jobs and Windows. Independent RTX and WARP Release draws passed after resolving the test registration conflict. This covers the approved forward diamond. Further branch shapes still need separate evidence.
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#1406
No description provided.