compute: lower s_or_saveexec_b32 in the direct wave32 path #3193

Merged
Leyukaka merged 1 commit from upstream-pr/3193 into main 2026-11-28 02:09:01 +00:00
Leyukaka commented 2026-11-27 21:12:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T21:12:51Z.


Fixes #3158. Part of #2935. Target branch main.

Change (src/gfx1013_compute_native.cpp, src/gfx1013_direct_compute.inl): direct wave32 compute lowers s_or_saveexec_b32 like s_and_saveexec_b32, with OR.

  • D = old EXEC.
  • EXEC = old EXEC | S0.
  • SCC = (EXEC != 0).
  • As with s_mov_b32 exec_lo and s_or_saveexec_b64, EXEC is stored as computed, including bits past the group. A lane runs only if its own bit is set.
  • transfer now marks EXEC numeric after s_and_saveexec_b32 as well; before, that op went through the generic SOP1 branch, which cleared only its destination.
  • An EXEC destination is refused.

Tests. The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on main 80668b97 plus this commit.

  • native_or_saveexec_hardware (new) runs in 8- and 32-thread groups, against a CPU reference. It covers these sources:

    • -1;
    • an SGPR that aliases the destination;
    • a literal;
    • vcc_lo;
    • an empty mask;
    • bit 31, which is past the 8-thread group.

    It checks the saved EXEC, the new EXEC, SCC (primed to the opposite value) and a restore through s_mov_b32 exec_lo.

  • native_direct_container checks the EXEC-destination refusal and a descriptor-SCC case.

  • native_wave_request_hardware, native_lane_access_hardware, native_permlane* and native_dpp* pass.

  • Mutation checks, run by hand:

    • AND instead of OR fails native_or_saveexec_hardware;
    • clamping EXEC to the group fails it too;
    • accepting an EXEC destination fails native_direct_container.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main 80668b97.

  • 4 of 2,689 requests stopped first at "direct DXIL lowering for s_or_saveexec_b32". All 4 now pass it and stop at v_permlanex16_b32, which #3022 handles. The compiled count does not change, and no request that compiled before stops compiling.
  • With #3161 (descriptor spills), 37 requests reach this op: 33 more.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5533165105 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3193). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T21:12:51Z. --- Fixes #3158. Part of #2935. Target branch `main`. **Change** (`src/gfx1013_compute_native.cpp`, `src/gfx1013_direct_compute.inl`): direct wave32 compute lowers `s_or_saveexec_b32` like `s_and_saveexec_b32`, with OR. - D = old EXEC. - EXEC = old EXEC | S0. - SCC = (EXEC != 0). - As with `s_mov_b32 exec_lo` and `s_or_saveexec_b64`, EXEC is stored as computed, including bits past the group. A lane runs only if its own bit is set. - `transfer` now marks EXEC numeric after `s_and_saveexec_b32` as well; before, that op went through the generic SOP1 branch, which cleared only its destination. - An EXEC destination is refused. **Tests.** The setup was Windows 11 build 26300.9974 with an NVIDIA GeForce RTX 5080 (driver 32.0.16.2101) and DXC from the Windows SDK 10.0.26100, on `main` `80668b97` plus this commit. - `native_or_saveexec_hardware` (new) runs in 8- and 32-thread groups, against a CPU reference. It covers these sources: - `-1`; - an SGPR that aliases the destination; - a literal; - `vcc_lo`; - an empty mask; - bit 31, which is past the 8-thread group. It checks the saved EXEC, the new EXEC, SCC (primed to the opposite value) and a restore through `s_mov_b32 exec_lo`. - `native_direct_container` checks the EXEC-destination refusal and a descriptor-SCC case. - `native_wave_request_hardware`, `native_lane_access_hardware`, `native_permlane*` and `native_dpp*` pass. - Mutation checks, run by hand: - AND instead of OR fails `native_or_saveexec_hardware`; - clamping EXEC to the group fails it too; - accepting an EXEC destination fails `native_direct_container`. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `80668b97`. - 4 of 2,689 requests stopped first at "direct DXIL lowering for s_or_saveexec_b32". All 4 now pass it and stop at `v_permlanex16_b32`, which #3022 handles. The compiled count does not change, and no request that compiled before stops compiling. - With #3161 (descriptor spills), 37 requests reach this op: 33 more. AI-assisted.
pigalot commented 2026-11-27 22:00:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:00:39Z.

Review: COMMENTED


I reviewed c9e32e20 over current main c45bf9ab. The trial merge conflicts in tests/native_direct_container_check.py: #3189 (995c1327) added its descriptor-sop1-* checks at the same spot as this PR's two new checks. The conflict is purely additive, so I resolved it locally by keeping both blocks (tree 7cf7bb3b, git diff --cached --check clean) and tested that. The branch still needs a rebase or a merge of main before it can land.

What I traced.

  • Semantics: for s_or_saveexec_b32 the lowering saves the old EXEC to D before writing, sets EXEC to old | S0, and sets SCC to EXEC != 0. That matches the RDNA SOP1 definition. a is read before write(i.dst), so a source that aliases the destination sees the old value (the sgpr case).
  • SCC liveness after #3189: the PR adds s_or_saveexec_b32 to the overwrites list, next to s_and_saveexec_b32. That is right, because the op always writes SCC. #3189's preserves_sop1 list does not contain it, so the merged tree classifies it consistently.
  • Destination guard: i.dst > 107 refuses exec_lo and the other special registers, while SGPRs and vcc are accepted.
  • Wave64 and graphics: these keep their existing paths, because or_saveexec requires compute && !wave64.

What I ran on the resolved merge:

  • dev: full build, then

    ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_direct_container|native_.*saveexec.*|native_wave_request.*|native_lane_access.*|native_permlane.*|native_dpp.*|native_scalar.*)$' -E '_hardware$'
    ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(native_or_saveexec|native_wave_request|native_lane_access|native_permlane.*|native_dpp.*)_hardware$'
    

    3/3 CPU and 6/6 hardware tests pass (native_or_saveexec, native_wave_request, native_dpp_mirror, native_dpp_quad, native_dpp_row, native_lane_access), with no skips.

  • release /O2: built compile_dxil and native_store_replay, then ran native_or_saveexec_hardware and native_direct_container. 2/2 pass.

Mutants, each rebuilt in dev and run against native_or_saveexec_hardware and native_direct_container (the unmutated baseline passes first):

Mutant Result
no OR lowering (negative control: main's behaviour) killed (both tests)
OR → AND killed (hardware)
EXEC-destination refusal removed killed (container)
D gets the new mask instead of the old EXEC killed (hardware)
SCC from the old EXEC killed (hardware)
EXEC clamped to the 8-thread group killed (hardware)
transfer branch removed survives
transfer keeps the old EXEC symbol (set(126, {}) dropped) survives
transfer branch only for s_or_saveexec_b32 (main's s_and_saveexec_b32 handling) survives

Restored and rebuilt afterwards; git diff --quiet is clean.

Findings.

  1. Rebase needed (above). Keeping both check blocks is the resolution I tested.
  2. The transfer change is not pinned (non-blocking). No test fails without it, for either op. That includes the s_and_saveexec_b32 part, which changes behaviour beyond this PR's title: EXEC becomes numeric after it. I believe the change is correct, because the generic SOP1 branch left EXEC with its pre-op symbol. A case where the stale symbol is observable would pin it, or it could move to its own PR. One possible case, which I have not run: a constant s_mov_b32 exec_lo, then s_or_saveexec_b32, then a consumer of EXEC's symbol.

Verdict: comment. GitHub reports c9e32e20 as conflicting, so I'm not approving it. Apart from the rebase I found nothing blocking, and I'll retest and approve the rebased head.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on c9e32e20 against its own base.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093757967 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3193#pullrequestreview-6093757967). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T22:00:39Z. **Review:** COMMENTED --- I reviewed `c9e32e20` over current `main` `c45bf9ab`. The trial merge conflicts in `tests/native_direct_container_check.py`: #3189 (`995c1327`) added its `descriptor-sop1-*` checks at the same spot as this PR's two new checks. The conflict is purely additive, so I resolved it locally by keeping both blocks (tree `7cf7bb3b`, `git diff --cached --check` clean) and tested that. The branch still needs a rebase or a merge of `main` before it can land. **What I traced.** - **Semantics:** for `s_or_saveexec_b32` the lowering saves the old EXEC to `D` before writing, sets EXEC to `old | S0`, and sets SCC to `EXEC != 0`. That matches the RDNA SOP1 definition. `a` is read before `write(i.dst)`, so a source that aliases the destination sees the old value (the `sgpr` case). - **SCC liveness after #3189:** the PR adds `s_or_saveexec_b32` to the `overwrites` list, next to `s_and_saveexec_b32`. That is right, because the op always writes SCC. #3189's `preserves_sop1` list does not contain it, so the merged tree classifies it consistently. - **Destination guard:** `i.dst > 107` refuses `exec_lo` and the other special registers, while SGPRs and `vcc` are accepted. - **Wave64 and graphics:** these keep their existing paths, because `or_saveexec` requires `compute && !wave64`. **What I ran** on the resolved merge: - **`dev`:** full build, then ```powershell ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_direct_container|native_.*saveexec.*|native_wave_request.*|native_lane_access.*|native_permlane.*|native_dpp.*|native_scalar.*)$' -E '_hardware$' ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(native_or_saveexec|native_wave_request|native_lane_access|native_permlane.*|native_dpp.*)_hardware$' ``` 3/3 CPU and 6/6 hardware tests pass (`native_or_saveexec`, `native_wave_request`, `native_dpp_mirror`, `native_dpp_quad`, `native_dpp_row`, `native_lane_access`), with no skips. - **`release` `/O2`:** built `compile_dxil` and `native_store_replay`, then ran `native_or_saveexec_hardware` and `native_direct_container`. 2/2 pass. **Mutants**, each rebuilt in `dev` and run against `native_or_saveexec_hardware` and `native_direct_container` (the unmutated baseline passes first): | Mutant | Result | |---|---| | no OR lowering (negative control: main's behaviour) | killed (both tests) | | OR → AND | killed (hardware) | | EXEC-destination refusal removed | killed (container) | | `D` gets the new mask instead of the old EXEC | killed (hardware) | | SCC from the old EXEC | killed (hardware) | | EXEC clamped to the 8-thread group | killed (hardware) | | `transfer` branch removed | **survives** | | `transfer` keeps the old EXEC symbol (`set(126, {})` dropped) | **survives** | | `transfer` branch only for `s_or_saveexec_b32` (main's `s_and_saveexec_b32` handling) | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Findings.** 1. **Rebase needed** (above). Keeping both check blocks is the resolution I tested. 2. **The `transfer` change is not pinned (non-blocking).** No test fails without it, for either op. That includes the `s_and_saveexec_b32` part, which changes behaviour beyond this PR's title: EXEC becomes numeric after it. I believe the change is correct, because the generic SOP1 branch left EXEC with its pre-op symbol. A case where the stale symbol is observable would pin it, or it could move to its own PR. One possible case, which I have not run: a constant `s_mov_b32 exec_lo`, then `s_or_saveexec_b32`, then a consumer of EXEC's symbol. **Verdict:** comment. GitHub reports `c9e32e20` as conflicting, so I'm not approving it. Apart from the rebase I found nothing blocking, and I'll retest and approve the rebased head. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `c9e32e20` against its own base. This reply was AI-assisted.
KelboLive commented 2026-11-27 23:53:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:53:28Z.


Review of c9e32e20 (integrated over main):

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7230485711 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3193#issuecomment-7230485711). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-27T23:53:28Z. --- Review of `c9e32e20` (integrated over main):
R0Y00 commented 2026-11-28 02:08:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:08:55Z.

Review: APPROVED


Reviewed c8bf4dcd30 over main 2d6dad19 (integrated tree 974293e72a). The merge retains both sets of descriptor/SCC controls. The wave32 Compute path reads the source and old EXEC before writing the destination, preserves bits outside a short group, and derives SCC from the new mask. The EXEC-destination refusal remains covered, and the unchanged wave-size and lane-access cases passed.

ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^native_(direct_container|(or_saveexec|wave_request|lane_access|dpp8|packed_dot2_f16_compute)_hardware)$"

Debug 6/6 and Release /O2 6/6, zero skips. RTX 4060 Laptop GPU 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Hosted required Windows CI passed. The capture-census evidence tracks first refusals only; the fixture independently checks the result bits and side effects.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095125448 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3193#pullrequestreview-6095125448). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T02:08:55Z. **Review:** APPROVED --- Reviewed c8bf4dcd3006 over main 2d6dad19 (integrated tree 974293e72afa1e48fa420ca8a37ed5610595e826). The merge retains both sets of descriptor/SCC controls. The wave32 Compute path reads the source and old EXEC before writing the destination, preserves bits outside a short group, and derives SCC from the new mask. The EXEC-destination refusal remains covered, and the unchanged wave-size and lane-access cases passed. ``` ctest --test-dir <build> --no-tests=error --output-on-failure -j 1 -R "^native_(direct_container|(or_saveexec|wave_request|lane_access|dpp8|packed_dot2_f16_compute)_hardware)$" ``` Debug 6/6 and Release /O2 6/6, zero skips. RTX 4060 Laptop GPU 32.0.16.1656, Windows 11 26200.9974, standalone replay without the debug layer. Hosted required Windows CI passed. The capture-census evidence tracks first refusals only; the fixture independently checks the result bits and side effects.
pigalot commented 2026-11-28 02:39:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T02:39:23Z.

Review: APPROVED


Retested c8bf4dcd merged over current main 24eb18b9. The merge is clean (tree 65eb0165) and git diff --cached --check is clean.

My comment review on c9e32e20.

  • Rebase needed: addressed. The branch is rebased and the PR is mergeable. The PR's own diff, c8bf4dcd against its merge base, is byte-identical to c9e32e20 against its base. So the lowering, the overwrites entry, the EXEC-destination guard and the tests are what I traced before. The native_direct_container_check.py checks sit next to #3189's descriptor-sop1-* block, as in my local resolution.
  • The transfer change is still not pinned (non-blocking). No test fails without it, as before.

What I ran.

  • Builds: full dev and release /O2.

  • CPU, full suite: ctest --test-dir out/build/dev --no-tests=error -j 8 -E '(startup_audio|_hardware$)' gives 1985 tests: 1934 pass, 0 fail, 51 capability skips.

  • CPU, release: native_direct_container passes.

  • Hardware:

    ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_or_saveexec|native_and_saveexec|native_wave_request|native_lane_access|native_permlane.*|native_dpp.*)_hardware$'
    

    8/8 pass in each preset, with no skips: native_or_saveexec, native_wave_request, native_lane_access, native_permlane, native_dpp8, native_dpp_mirror, native_dpp_quad and native_dpp_row.

The mutants from my earlier review were run on the same code and still apply.

Verdict: approve on c8bf4dcd. This supersedes my comment review on c9e32e20.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on c8bf4dcd.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095228116 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3193#pullrequestreview-6095228116). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T02:39:23Z. **Review:** APPROVED --- Retested `c8bf4dcd` merged over current `main` `24eb18b9`. The merge is clean (tree `65eb0165`) and `git diff --cached --check` is clean. **My comment review on `c9e32e20`.** - **Rebase needed: addressed.** The branch is rebased and the PR is mergeable. The PR's own diff, `c8bf4dcd` against its merge base, is byte-identical to `c9e32e20` against its base. So the lowering, the `overwrites` entry, the EXEC-destination guard and the tests are what I traced before. The `native_direct_container_check.py` checks sit next to #3189's `descriptor-sop1-*` block, as in my local resolution. - **The `transfer` change is still not pinned (non-blocking).** No test fails without it, as before. **What I ran.** - **Builds:** full `dev` and `release` `/O2`. - **CPU, full suite:** `ctest --test-dir out/build/dev --no-tests=error -j 8 -E '(startup_audio|_hardware$)'` gives 1985 tests: 1934 pass, 0 fail, 51 capability skips. - **CPU, `release`:** `native_direct_container` passes. - **Hardware:** ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_or_saveexec|native_and_saveexec|native_wave_request|native_lane_access|native_permlane.*|native_dpp.*)_hardware$' ``` 8/8 pass in each preset, with no skips: `native_or_saveexec`, `native_wave_request`, `native_lane_access`, `native_permlane`, `native_dpp8`, `native_dpp_mirror`, `native_dpp_quad` and `native_dpp_row`. The mutants from my earlier review were run on the same code and still apply. **Verdict:** approve on `c8bf4dcd`. This supersedes my comment review on `c9e32e20`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `c8bf4dcd`. This reply was AI-assisted.
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
R0Y00/Xbox2Windows!3193
No description provided.