perf(shader): run wave64 compute at one lane where no lane can tell #12324

Open
Meh7an wants to merge 2 commits from upstream-pr/12324 into main
Meh7an commented 2026-10-28 09:27:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Meh7an on 2026-10-28T09:27:57Z.


What

Draft. With the sound proof below, no program on the measured S3K page that takes more than 1 ms qualifies, so the change shows no gain there. It stays a draft until a heavy compute program in some title qualifies.

On a 32-lane host, main runs a wave64 compute program at two guest lanes per invocation (laneCount 2), so each invocation does every ALU operation, load and sample twice. This PR proves, on the IR, which wave64 compute programs give every lane the same results at one guest lane per invocation, where each host subgroup holds half a wave, and emits those programs that way. The emitter already supports this layout: APS5_SINGLE_LANE=<addresses> forces it by hand. Two commits:

  1. perf(shader): fold bitwise self and complement identities (ConstantFolder). It folds And32/Or32/Xor32 of a value with itself, with its complement in either order, and with an absorbing constant (x & 0, x | ~0). It also folds bit 0 of all ones shifted right by an amount masked to 0-31 to one, and 0 >> y to zero. s_orn2_saveexec_b64 of exec gives exec | ~exec, so its lane bits and the exec selects they guard fold away. The half-wave scan matcher (24894376ab) proved "every lane" only from the exec | ~exec structure on hosts as wide as the wave, which no longer survives the fold. A constant-true lane bit now counts as every lane on every host, the same proof, so EveryLaneBit and its narrow-only flag go. On its own this gave no measurable gain; it simplifies the lane masks the second commit reads.

  2. perf(shader): run wave64 compute at one lane where no lane can tell. SingleLaneAnalysis decides before emission. A program qualifies when:

    • no lane reads another lane's value by index: readlane and readfirstlane read only uniform values, and there are no permutes, DPP, swizzles or GPU-selected buffer descriptors;
    • lane masks are combined bit by bit and read only as each lane's own bit, with the same expression over both 32-bit halves;
    • LDS is lane-private: every access is one affine function of the local invocation id and no two lanes' footprints share a byte, and a one-wave workgroup does not write it;
    • each term of a VCC branch's predicate is uniform or implied by the exec mask at the branch;
    • nothing leaves a region that one half of the wave can skip unless it is the same whether that half ran the region or not;
    • no barrier shares the program with a branch one half can decide alone.

    Skipped regions. At one lane, EmitWaveMaskBranchCondition decides execz, execnz, vccz and vccnz per host subgroup, so a half with no active lane skips what the whole wave runs. For each exec branch, and each VCC branch on lane-varying terms, the region is what the taken side reaches before the branch's immediate post-dominator and the other side does not. A value leaving it qualifies when it is a VGPR written under the branch's exec, a lane-mask word that keeps its bits outside that exec, or a vector-window store that keeps the old value outside it. Scalars, VCC and goto flags written in the region keep two lanes. A value no instruction reads, such as a phi cycle that only feeds itself, leaves nothing to compare. A memory write in the region needs a lane predicate inside the branch's exec. A loop left through such a branch must carry values that stay the same per lane and an exec that only narrows. Workgroups of at most 32 lanes get every check, since whole-wave mode still decides branches per half. The check runs in the first simplify pass, before VectorWindowStoreEliminator and MaskedSelectEliminator drop the exec selects whose inactive lanes nothing reads, and IrProgramMetadata keeps its verdict for the layout.

    Relatively addressed VGPRs live in a function-scope window per lane (LoadVectorWindow/StoreVectorWindow, f8ed012e3e), so window accesses are lane-local; a window load counts as lane-varying, so readfirstlane of one still keeps two lanes. Only hosts whose wave64 compute target is 32 lanes wide are candidates. A qualifying program is emitted with a 64-lane hostSubgroupSize, as APS5_SINGLE_LANE does, and the artifact records it; computeSubgroupSize then still requires 32-lane subgroups where the device can.

    • BlockInfo::exec records the exec mask at each VCC and exec branch. ReclaimUnusedValues, ResolveControlFlowIdentities and RedundantValueEliminator keep it current, as they do condition.
    • The disk cache key marks the requests the rule lays out, so a run with APS5_NO_SINGLE_LANE_RULE=1, which keeps every program at two lanes, does not load their results. APS5_TRACE_SINGLE_LANE=1 prints each program's verdict and the reason a program keeps two lanes. Both are in docs/dev/ENVIRONMENT.md.
    • agc_shader_memory checks the two-lane SPIR-V of 64-thread programs, so it sets APS5_NO_SINGLE_LANE_RULE.

Correction to the first version. The first push admitted S3K's heaviest compute program and measured it at 4.87 to 2.82 ms per present. That admission was wrong. The program's loop at guest 0x2bfc is a per-lane state machine in v32. Its exit test runs on alive & state == 0, but the body then restores exec to every live lane and runs the state-2 handler (buffer loads, lane kills) for lanes still in state 2. A half with no state-0 lane would leave the loop at one lane while the whole wave keeps running that half's state-2 lanes. The program depends on the other half and keeps two lanes now.

Relation to #5405, #7922 and #8004. Spanned waves (APS5_SPANNED_WAVE) cover exactly-64-thread workgroups whose lanes exchange values, through workgroup barriers. This proof needs no exchange and covers any workgroup size, including multi-wave groups, which never span. A proven 64-thread program takes one lane without spanning; a program the proof rejects still spans when spanning is on, with or without #7922's default. Neither approach covers the other.

Tested

Windows 11 (10.0.26300), NVIDIA GeForce RTX 2080 Ti, driver 617.14, i9-9900K, GCC 15.2 (WinLibs), Release. Base: main f8f5b24b77; this PR's head is 7a8da113db, with no other PR applied.

  • agc_single_lane (35 cases), run twice by ctest: agc_single_lane and agc_single_lane_off, the second with APS5_NO_SINGLE_LANE_RULE=1, where its end-to-end Recompile case expects a 32-lane layout instead of 64.
    • accepted: lane-private LDS in one and two dimensions, a lane's own ballot bit, readfirstlane of user data, a vector window indexed by user data, a VCC branch on a uniform compare under the branch's exec, an exec-masked VGPR and a kept-value window store under s_cbranch_execz, an execz loop carrying an exec-masked VGPR out, an exec-masked VGPR carried through a loop inside a skippable region, and a scalar written in a skippable region that nothing reads;
    • rejected: LDS shared between lanes or read past a lane's footprint, LDS at a loaded address, LDS writes in a one-wave group, a counted ballot, a mask whose halves differ, the lane id read as data (also in a group of at most 32 lanes, which now gets every check), readfirstlane of a local id or of a window load, a VCC branch on a lane compare or on bits from a narrower exec, a VCC branch without its exec, DPP, lane 63 read in whole-wave mode, a barrier beside exec branches (also in a 32-thread group and beside a VCC branch on exec-implied bits), a scalar, a VCC word, a whole-wave VGPR write and an unmasked window store leaving a skippable region, a scalar loop counter used after an execz loop, and a loop whose exit test reads fewer lanes than its body runs;
    • plus one fold case: a select on a lane's bit of ~exec | exec folds to its true arm;
    • with the two last proof fixes reverted (values no instruction reads, and phi cycles in the skipped-value walk), exactly the two cases written for them fail.
  • agc_bitwise_identities (8 cases) covers the first commit.
  • agc_shader_memory: a wave64 compute UMin scan under s_or_saveexec_b64 -1 on a 32-lane target stays at two lanes and emits no OpGroupNonUniformUMin, since the scan matchers run only for non-compute stages at one lane (SpirvAluEmitterMath.cpp:1151). Next to it, the pixel version on 64 lanes still reads lanes 31 and 63 as two half-wave reductions.
  • Full ctest on this PR: 2840 of 2840 pass. guest_kernel_sys_threads_main, guest_kernel_sys_threads_main_patched and net_ipv6only_patched were left out: on main they stop with Windows' "Entry Point Not Found" dialog, which #12426 fixes.
  • Validation layer. 110 focused tests ran with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation through ctest --test-dir build -R <pattern> -V: the lane, exec and scalar-mask tests, the folder tests, the three new targets, and the 85 driver tests that took one-lane programs under the first version. All 110 pass on the change, and the 107 of them that exist on main f8f5b24b77 pass there. Neither log has a VUID- error or a was not found but was requested by env var VK_INSTANCE_LAYERS line.
  • Sonic Origins (PPSA05324), the S3K main-menu page, 3840x2160. The page's 9 compute programs were dumped with APS5_DUMP_SHADERS=1 and replayed through agc_shader_replay with APS5_TRACE_SINGLE_LANE=1. Five run at one lane; of these only 0x20092a600 runs on every page frame, and it is small. Four keep two lanes: the 16-thread writer (a lane mask whose halves differ), a 512-thread program with a VCC branch on lane-varying bits, one with FPInterpolateF16, and the heaviest one (16x16 threads), whose state-machine loop the correction above describes.
  • APS5_PROFILE_GPU=1: one boot per arm, warm caches, 12 page readings, [gputime] blocks 4 onward (9 on main, 8 on this PR):
per present main this PR
heaviest compute (two lanes in both) 5.37 ms 5.43 ms
16-thread writer (two lanes in both) 4.23 ms 4.10 ms
0x20092a600, 5 dispatches (one lane in this PR) 0.91 ms 0.89 ms
all compute 10.51 ms 10.42 ms
all GPU ranges 68.22 ms 66.71 ms
draw class 31.29 ms 30.69 ms
FPS (median, profiled) 13.59 13.25

No change beyond block-to-block noise; main's first block (74.0 ms) is its own outlier. With no speed claim, I took one pair and no traces. The traces attached to the first version measured the wrong admission and no longer apply.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 2080 Ti, driver 617.14, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5048183622 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12324). Originally posted by [Meh7an](https://github.com/Meh7an) on 2026-10-28T09:27:57Z. --- ### What **Draft.** With the sound proof below, no program on the measured S3K page that takes more than 1 ms qualifies, so the change shows no gain there. It stays a draft until a heavy compute program in some title qualifies. On a 32-lane host, `main` runs a wave64 compute program at two guest lanes per invocation (`laneCount` 2), so each invocation does every ALU operation, load and sample twice. This PR proves, on the IR, which wave64 compute programs give every lane the same results at one guest lane per invocation, where each host subgroup holds half a wave, and emits those programs that way. The emitter already supports this layout: `APS5_SINGLE_LANE=<addresses>` forces it by hand. Two commits: 1. **`perf(shader): fold bitwise self and complement identities`** (`ConstantFolder`). It folds `And32`/`Or32`/`Xor32` of a value with itself, with its complement in either order, and with an absorbing constant (`x & 0`, `x | ~0`). It also folds bit 0 of all ones shifted right by an amount masked to 0-31 to one, and `0 >> y` to zero. `s_orn2_saveexec_b64` of exec gives `exec | ~exec`, so its lane bits and the exec selects they guard fold away. The half-wave scan matcher (24894376ab) proved "every lane" only from the `exec | ~exec` structure on hosts as wide as the wave, which no longer survives the fold. A constant-true lane bit now counts as every lane on every host, the same proof, so `EveryLaneBit` and its narrow-only flag go. On its own this gave no measurable gain; it simplifies the lane masks the second commit reads. 2. **`perf(shader): run wave64 compute at one lane where no lane can tell`**. `SingleLaneAnalysis` decides before emission. A program qualifies when: - no lane reads another lane's value by index: `readlane` and `readfirstlane` read only uniform values, and there are no permutes, DPP, swizzles or GPU-selected buffer descriptors; - lane masks are combined bit by bit and read only as each lane's own bit, with the same expression over both 32-bit halves; - LDS is lane-private: every access is one affine function of the local invocation id and no two lanes' footprints share a byte, and a one-wave workgroup does not write it; - each term of a VCC branch's predicate is uniform or implied by the exec mask at the branch; - nothing leaves a region that one half of the wave can skip unless it is the same whether that half ran the region or not; - no barrier shares the program with a branch one half can decide alone. **Skipped regions.** At one lane, `EmitWaveMaskBranchCondition` decides `execz`, `execnz`, `vccz` and `vccnz` per host subgroup, so a half with no active lane skips what the whole wave runs. For each exec branch, and each VCC branch on lane-varying terms, the region is what the taken side reaches before the branch's immediate post-dominator and the other side does not. A value leaving it qualifies when it is a VGPR written under the branch's exec, a lane-mask word that keeps its bits outside that exec, or a vector-window store that keeps the old value outside it. Scalars, VCC and goto flags written in the region keep two lanes. A value no instruction reads, such as a phi cycle that only feeds itself, leaves nothing to compare. A memory write in the region needs a lane predicate inside the branch's exec. A loop left through such a branch must carry values that stay the same per lane and an exec that only narrows. Workgroups of at most 32 lanes get every check, since whole-wave mode still decides branches per half. The check runs in the first simplify pass, before `VectorWindowStoreEliminator` and `MaskedSelectEliminator` drop the exec selects whose inactive lanes nothing reads, and `IrProgramMetadata` keeps its verdict for the layout. Relatively addressed VGPRs live in a function-scope window per lane (`LoadVectorWindow`/`StoreVectorWindow`, f8ed012e3e), so window accesses are lane-local; a window load counts as lane-varying, so `readfirstlane` of one still keeps two lanes. Only hosts whose wave64 compute target is 32 lanes wide are candidates. A qualifying program is emitted with a 64-lane `hostSubgroupSize`, as `APS5_SINGLE_LANE` does, and the artifact records it; `computeSubgroupSize` then still requires 32-lane subgroups where the device can. - `BlockInfo::exec` records the exec mask at each VCC and exec branch. `ReclaimUnusedValues`, `ResolveControlFlowIdentities` and `RedundantValueEliminator` keep it current, as they do `condition`. - The disk cache key marks the requests the rule lays out, so a run with `APS5_NO_SINGLE_LANE_RULE=1`, which keeps every program at two lanes, does not load their results. `APS5_TRACE_SINGLE_LANE=1` prints each program's verdict and the reason a program keeps two lanes. Both are in `docs/dev/ENVIRONMENT.md`. - `agc_shader_memory` checks the two-lane SPIR-V of 64-thread programs, so it sets `APS5_NO_SINGLE_LANE_RULE`. **Correction to the first version.** The first push admitted S3K's heaviest compute program and measured it at 4.87 to 2.82 ms per present. That admission was wrong. The program's loop at guest `0x2bfc` is a per-lane state machine in `v32`. Its exit test runs on `alive & state == 0`, but the body then restores exec to every live lane and runs the state-2 handler (buffer loads, lane kills) for lanes still in state 2. A half with no state-0 lane would leave the loop at one lane while the whole wave keeps running that half's state-2 lanes. The program depends on the other half and keeps two lanes now. **Relation to #5405, #7922 and #8004.** Spanned waves (`APS5_SPANNED_WAVE`) cover exactly-64-thread workgroups whose lanes exchange values, through workgroup barriers. This proof needs no exchange and covers any workgroup size, including multi-wave groups, which never span. A proven 64-thread program takes one lane without spanning; a program the proof rejects still spans when spanning is on, with or without #7922's default. Neither approach covers the other. ### Tested Windows 11 (10.0.26300), NVIDIA GeForce RTX 2080 Ti, driver 617.14, i9-9900K, GCC 15.2 (WinLibs), Release. Base: `main` f8f5b24b77; this PR's head is 7a8da113db, with no other PR applied. - **`agc_single_lane`** (35 cases), run twice by ctest: `agc_single_lane` and `agc_single_lane_off`, the second with `APS5_NO_SINGLE_LANE_RULE=1`, where its end-to-end `Recompile` case expects a 32-lane layout instead of 64. - accepted: lane-private LDS in one and two dimensions, a lane's own ballot bit, `readfirstlane` of user data, a vector window indexed by user data, a VCC branch on a uniform compare under the branch's exec, an exec-masked VGPR and a kept-value window store under `s_cbranch_execz`, an `execz` loop carrying an exec-masked VGPR out, an exec-masked VGPR carried through a loop inside a skippable region, and a scalar written in a skippable region that nothing reads; - rejected: LDS shared between lanes or read past a lane's footprint, LDS at a loaded address, LDS writes in a one-wave group, a counted ballot, a mask whose halves differ, the lane id read as data (also in a group of at most 32 lanes, which now gets every check), `readfirstlane` of a local id or of a window load, a VCC branch on a lane compare or on bits from a narrower exec, a VCC branch without its exec, DPP, lane 63 read in whole-wave mode, a barrier beside exec branches (also in a 32-thread group and beside a VCC branch on exec-implied bits), a scalar, a VCC word, a whole-wave VGPR write and an unmasked window store leaving a skippable region, a scalar loop counter used after an `execz` loop, and a loop whose exit test reads fewer lanes than its body runs; - plus one fold case: a select on a lane's bit of `~exec | exec` folds to its true arm; - with the two last proof fixes reverted (values no instruction reads, and phi cycles in the skipped-value walk), exactly the two cases written for them fail. - **`agc_bitwise_identities`** (8 cases) covers the first commit. - **`agc_shader_memory`**: a wave64 compute UMin scan under `s_or_saveexec_b64 -1` on a 32-lane target stays at two lanes and emits no `OpGroupNonUniformUMin`, since the scan matchers run only for non-compute stages at one lane (`SpirvAluEmitterMath.cpp:1151`). Next to it, the pixel version on 64 lanes still reads lanes 31 and 63 as two half-wave reductions. - **Full `ctest`** on this PR: 2840 of 2840 pass. `guest_kernel_sys_threads_main`, `guest_kernel_sys_threads_main_patched` and `net_ipv6only_patched` were left out: on `main` they stop with Windows' "Entry Point Not Found" dialog, which #12426 fixes. - **Validation layer.** 110 focused tests ran with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` through `ctest --test-dir build -R <pattern> -V`: the lane, exec and scalar-mask tests, the folder tests, the three new targets, and the 85 driver tests that took one-lane programs under the first version. All 110 pass on the change, and the 107 of them that exist on `main` f8f5b24b77 pass there. Neither log has a `VUID-` error or a `was not found but was requested by env var VK_INSTANCE_LAYERS` line. - **Sonic Origins (PPSA05324), the S3K main-menu page, 3840x2160.** The page's 9 compute programs were dumped with `APS5_DUMP_SHADERS=1` and replayed through `agc_shader_replay` with `APS5_TRACE_SINGLE_LANE=1`. Five run at one lane; of these only `0x20092a600` runs on every page frame, and it is small. Four keep two lanes: the 16-thread writer (a lane mask whose halves differ), a 512-thread program with a VCC branch on lane-varying bits, one with `FPInterpolateF16`, and the heaviest one (16x16 threads), whose state-machine loop the correction above describes. - **`APS5_PROFILE_GPU=1`:** one boot per arm, warm caches, 12 page readings, `[gputime]` blocks 4 onward (9 on `main`, 8 on this PR): | per present | `main` | this PR | |---|---|---| | heaviest compute (two lanes in both) | 5.37 ms | 5.43 ms | | 16-thread writer (two lanes in both) | 4.23 ms | 4.10 ms | | `0x20092a600`, 5 dispatches (one lane in this PR) | 0.91 ms | 0.89 ms | | all compute | 10.51 ms | 10.42 ms | | all GPU ranges | 68.22 ms | 66.71 ms | | draw class | 31.29 ms | 30.69 ms | | FPS (median, profiled) | 13.59 | 13.25 | No change beyond block-to-block noise; `main`'s first block (74.0 ms) is its own outlier. With no speed claim, I took one pair and no traces. The traces attached to the first version measured the wrong admission and no longer apply. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 2080 Ti, driver 617.14, Windows 11 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-28 09:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T09:31:21Z.

Review: CHANGES_REQUESTED


I found a safety-check bypass in analyze(): the workgroup size <= 32 fast path returns eligible before scanning instructions or applying the later guards. In particular, it skips the explicit barrier && execBranches rejection (and the tests only cover that rejection with the default 16x16 workgroup). A wave64 compute program with 32 or fewer work items, a barrier, and an ExecZero/ExecNonZero branch is therefore emitted with laneCount = 1 despite the analysis explicitly rejecting barriers in programs with exec branches. That can put a workgroup barrier under non-uniform control flow and hang or invalidate the dispatch. Please retain the simple one-to-one lane mapping optimization for small groups, but still run the structural checks that apply to them; add a <=32-work-item regression containing an exec branch and barrier and require the analysis to reject it.

I have not approved this shader change. The current report has extensive tests and a same-scene performance pair, but that does not cover this early-return path.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5680477433 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12324#pullrequestreview-5680477433). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T09:31:21Z. **Review:** CHANGES_REQUESTED --- I found a safety-check bypass in `analyze()`: the `workgroup size <= 32` fast path returns eligible before scanning instructions or applying the later guards. In particular, it skips the explicit `barrier && execBranches` rejection (and the tests only cover that rejection with the default 16x16 workgroup). A wave64 compute program with 32 or fewer work items, a barrier, and an `ExecZero`/`ExecNonZero` branch is therefore emitted with `laneCount = 1` despite the analysis explicitly rejecting barriers in programs with exec branches. That can put a workgroup barrier under non-uniform control flow and hang or invalidate the dispatch. Please retain the simple one-to-one lane mapping optimization for small groups, but still run the structural checks that apply to them; add a <=32-work-item regression containing an exec branch and barrier and require the analysis to reject it. I have not approved this shader change. The current report has extensive tests and a same-scene performance pair, but that does not cover this early-return path.
adriadam10 commented 2026-10-28 11:47:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T11:47:37Z.

Review: CHANGES_REQUESTED


Thanks for the careful proof and the negative cases. The head is still 5d770a5ff0, and the three gaps raised in this thread (which you confirmed) are open, so this can't merge yet:

  • SingleLaneAnalysis.cpp:925: the <= 32 early return skips every check, including barrier && execBranches (line 984). Please run the structural checks for small groups too, and add a <=32-thread regression with an exec branch and a barrier that must be rejected (@MarcZX10's request).
  • Same early return: whole-wave mode (s_or_saveexec_b64 -1) wakes lanes 32-63, which exist only in the second slot at two lanes. Drop the shortcut and add the 32-thread group reading lane 63 in whole-wave mode, as you proposed.
  • Scalar/VCC/goto-flag/window-store values defined in a region that one half can skip via execz/execnz/exec-implied VCC reach the merge phi (or loop exit) with different values per half. Uniformity treats those phis as uniform. Please add the live-out rule you described, with the negatives (@oneandonlydean's snippet, an execz-exited loop with a scalar counter, a VCC written in the region and read after it, a whole-wave write in the region) and the exec-masked VGPR positives.
  • The first commit makes a constant-true lane bit count as every lane in MatchHalfWaveScan/MatchRowScan for two-lane programs too. Please add the wave64 compute GFX10 reduction under s_or_saveexec_b64 -1 on a 32-lane target that you described.

Please also refresh the S3K numbers after the push, since the live-out rule may change which programs qualify.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682089883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12324#pullrequestreview-5682089883). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-28T11:47:37Z. **Review:** CHANGES_REQUESTED --- Thanks for the careful proof and the negative cases. The head is still `5d770a5ff0`, and the three gaps raised in this thread (which you confirmed) are open, so this can't merge yet: - `SingleLaneAnalysis.cpp:925`: the `<= 32` early return skips every check, including `barrier && execBranches` (line 984). Please run the structural checks for small groups too, and add a <=32-thread regression with an exec branch and a barrier that must be rejected (@MarcZX10's request). - Same early return: whole-wave mode (`s_or_saveexec_b64 -1`) wakes lanes 32-63, which exist only in the second slot at two lanes. Drop the shortcut and add the 32-thread group reading lane 63 in whole-wave mode, as you proposed. - Scalar/VCC/goto-flag/window-store values defined in a region that one half can skip via `execz`/`execnz`/exec-implied VCC reach the merge phi (or loop exit) with different values per half. `Uniformity` treats those phis as uniform. Please add the live-out rule you described, with the negatives (@oneandonlydean's snippet, an `execz`-exited loop with a scalar counter, a VCC written in the region and read after it, a whole-wave write in the region) and the exec-masked VGPR positives. - The first commit makes a constant-true lane bit count as every lane in `MatchHalfWaveScan`/`MatchRowScan` for two-lane programs too. Please add the wave64 compute GFX10 reduction under `s_or_saveexec_b64 -1` on a 32-lane target that you described. Please also refresh the S3K numbers after the push, since the live-out rule may change which programs qualify.
MarcZX10 commented 2026-10-29 06:23:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:23:13Z.

Review: COMMENTED


Re-checked — prior finding resolved

I inspected the current head 7a8da113db96ef882b362d52af10e10ee08a9773. AnalyzeSingleLane no longer has the small-workgroup early return; it runs the branch/uniformity checks and rejects barrier && execBranches before returning eligibility. The added 32-thread barrier/exec-branch case directly covers the scenario from my earlier review, so I withdraw that blocker.

The author also reports adding live-out checks and regressions for the scalar/VCC/goto/window/loop cases raised by the other reviewer. I have not independently audited that new analysis or run its shader tests in this pass, so this comment is not an approval of the whole compiler change. The author has kept the PR in draft because the revised S3K comparison is flat and the large workload remains on two lanes; the description makes no current speedup claim. That seems appropriate while there is no measured benefit to support a performance PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693672518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12324#pullrequestreview-5693672518). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T06:23:13Z. **Review:** COMMENTED --- ## Re-checked — prior finding resolved I inspected the current head `7a8da113db96ef882b362d52af10e10ee08a9773`. `AnalyzeSingleLane` no longer has the small-workgroup early return; it runs the branch/uniformity checks and rejects `barrier && execBranches` before returning eligibility. The added 32-thread barrier/exec-branch case directly covers the scenario from my earlier review, so I withdraw that blocker. The author also reports adding live-out checks and regressions for the scalar/VCC/goto/window/loop cases raised by the other reviewer. I have not independently audited that new analysis or run its shader tests in this pass, so this comment is not an approval of the whole compiler change. The author has kept the PR in draft because the revised S3K comparison is flat and the large workload remains on two lanes; the description makes no current speedup claim. That seems appropriate while there is no measured benefit to support a performance PR.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/12324:upstream-pr/12324'
git switch 'upstream-pr/12324'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/12324'
git switch 'upstream-pr/12324'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/12324'
git switch 'upstream-pr/12324'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/12324'
git switch 'main'
git merge --squash 'upstream-pr/12324'
git switch 'main'
git merge --ff-only 'upstream-pr/12324'
git switch 'main'
git merge 'upstream-pr/12324'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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
boykopovar/AnyPS5!12324
No description provided.