startup: prove uniform shifts of masked and extracted thread IDs #2761

Merged
RavenCurseBurg merged 1 commit from upstream-pr/2769 into main 2026-11-26 07:12:18 +00:00
RavenCurseBurg commented 2026-11-26 06:57:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T06:57:58Z.


Refs #2644 (T6).

For an untouched local X thread ID, the group's X extent bounds which bits can vary. This extends the compute entry-block proof for a literal logical right shift through two gfx1013 operations:

  • v_and_or_b32 dst, v0, mask, scalar produces scalar >> n after the shift when no possible thread-ID bit survives the mask and the shift. The scalar must be uniform and its value available at the point of recomputation.
  • v_bfe_u32 dst, v0, offset, width produces zero after the shift when extraction and shifting remove all possible thread-ID bits. The offset and width are literals.

This also works for masks that remove most of the bits in a group larger than one wave. The source-built masked test uses 128 threads. The approach uses the existing one-lane proof and requires no wave read or resource binding.

Verification

Tested eab5b3a7 against 6a6eecfe on Windows 11:

python -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py
python -B tests/startup_gfx2hlsl_compute_check.py
python -B tests/startup_gfx2hlsl_compute_check.py binary <llvm-mc>
python -B tests/startup_gfx2hlsl_compute_check.py dispatch <dxc> <offscreen_check> <warp|hardware>

All host checks passed. The original translator refused all ten new positive text cases. The negative controls cover surviving bits, an unknown group, modified operands, register offsets and widths, and signed extraction. The machine-code controls keep a masked bit or increase the group width enough for an extracted bit to survive. The checked-in assembly and bytes matched LLVM 15.0.7 (clang -cc1as -show-encoding).

The complete dispatch suite passed 28 baselines and detected five mutants on each of WARP, Intel UHD 770 and RTX 4060 with DXC 1.9.2609.5. The two new repo-authored fixtures read after a branch and compare all 320 words against per-thread CPU expressions and untouched sentinels. Dropping the mask case's shift fails at word=0 expected=0048d159 actual=01234567. Keeping the extracted field without the final shift fails at word=4 expected=00000000 actual=00000001 on all three backends. These are synthetic fixtures. General lane-varying reads in small groups are tracked separately in #2745.

AI-assisted with Codex (GPT-6.2 Astra, xhigh).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6621301568 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2769). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T06:57:58Z. --- Refs #2644 (T6). For an untouched local X thread ID, the group's X extent bounds which bits can vary. This extends the compute entry-block proof for a literal logical right shift through two gfx1013 operations: - `v_and_or_b32 dst, v0, mask, scalar` produces `scalar >> n` after the shift when no possible thread-ID bit survives the mask and the shift. The scalar must be uniform and its value available at the point of recomputation. - `v_bfe_u32 dst, v0, offset, width` produces zero after the shift when extraction and shifting remove all possible thread-ID bits. The offset and width are literals. This also works for masks that remove most of the bits in a group larger than one wave. The source-built masked test uses 128 threads. The approach uses the existing one-lane proof and requires no wave read or resource binding. ### Verification Tested `eab5b3a7` against `6a6eecfe` on Windows 11: ```text python -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py python -B tests/startup_gfx2hlsl_compute_check.py python -B tests/startup_gfx2hlsl_compute_check.py binary <llvm-mc> python -B tests/startup_gfx2hlsl_compute_check.py dispatch <dxc> <offscreen_check> <warp|hardware> ``` All host checks passed. The original translator refused all ten new positive text cases. The negative controls cover surviving bits, an unknown group, modified operands, register offsets and widths, and signed extraction. The machine-code controls keep a masked bit or increase the group width enough for an extracted bit to survive. The checked-in assembly and bytes matched LLVM 15.0.7 (clang `-cc1as -show-encoding`). The complete dispatch suite passed 28 baselines and detected five mutants on each of WARP, Intel UHD 770 and RTX 4060 with DXC 1.9.2609.5. The two new repo-authored fixtures read after a branch and compare all 320 words against per-thread CPU expressions and untouched sentinels. Dropping the mask case's shift fails at `word=0 expected=0048d159 actual=01234567`. Keeping the extracted field without the final shift fails at `word=4 expected=00000000 actual=00000001` on all three backends. These are synthetic fixtures. General lane-varying reads in small groups are tracked separately in #2745. AI-assisted with Codex (GPT-6.2 Astra, xhigh).
upstream-sync closed this pull request 2026-11-26 08:01:50 +00:00
tedin7 commented 2026-11-26 08:01:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:12:12Z.

Review: COMMENTED


Reviewed head eab5b3a7 against main: the new v_and_or_b32 and v_bfe_u32 folds only apply when no possible thread-ID bit survives mask/extract plus the shift, and the scalar stays uniform and unwritten up to the use. Checks run locally: both touched Python tests, docs_links_check, bidi_controls_check, git diff --check; two mutations of the proof each make startup_gfx2hlsl_readfirstlane_uniform_check.py fail. Win2025 receipt (dev and release 19/19) is in the comment above. No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069890171 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2769#pullrequestreview-6069890171). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:12:12Z. **Review:** COMMENTED --- Reviewed head eab5b3a7 against main: the new v_and_or_b32 and v_bfe_u32 folds only apply when no possible thread-ID bit survives mask/extract plus the shift, and the scalar stays uniform and unwritten up to the use. Checks run locally: both touched Python tests, docs_links_check, bidi_controls_check, git diff --check; two mutations of the proof each make startup_gfx2hlsl_readfirstlane_uniform_check.py fail. Win2025 receipt (dev and release 19/19) is in the comment above. No blocking findings. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 08:01:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:11:57Z.


Win2025 WARP receipt for head eab5b3a7.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit eab5b3a7307875ca99fbb2df65d7f687d240c286:

  • Debug (--preset dev): ctest --preset dev -R 'startup_gfx2hlsl_compute(_controls|_warp|_mbcnt_warp|_binary)?$|startup_gfx2hlsl_compute_.*warp' --parallel 3 --no-tests=error --output-on-failure: 19/19 passed
  • Release /O2 (--preset release): same regex: 19/19 passed
  • Windows Python checks: tests/startup_gfx2hlsl_readfirstlane_uniform_check.py rc=0, tests/startup_gfx2hlsl_compute_check.py rc=0

Review of the exact head (against main): the new v_and_or_b32 and v_bfe_u32 cases only fold to a value when no possible thread-ID bit survives mask/extract plus the shift, and the scalar is uniform and unmodified up to the use. The old v_lshl_add_u32 path keeps its conditions. Linux checks: both touched Python tests, docs_links_check.py, bidi_controls_check.py and git diff --check pass. Two mutations of the proof (dropping the surviving-bit mask test, dropping the bfe surviving-bit test) each make startup_gfx2hlsl_readfirstlane_uniform_check.py fail. The dispatch tests compare GPU readback with a per-thread CPU reference. No other open or merged PR covers this slice.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185199034 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2769#issuecomment-7185199034). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:11:57Z. --- Win2025 WARP receipt for head eab5b3a7. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `eab5b3a7307875ca99fbb2df65d7f687d240c286`: - **Debug (`--preset dev`)**: `ctest --preset dev -R 'startup_gfx2hlsl_compute(_controls|_warp|_mbcnt_warp|_binary)?$|startup_gfx2hlsl_compute_.*warp' --parallel 3 --no-tests=error --output-on-failure`: **19/19 passed** - **Release `/O2` (`--preset release`)**: same regex: **19/19 passed** - **Windows Python checks**: `tests/startup_gfx2hlsl_readfirstlane_uniform_check.py` rc=0, `tests/startup_gfx2hlsl_compute_check.py` rc=0 Review of the exact head (against main): the new `v_and_or_b32` and `v_bfe_u32` cases only fold to a value when no possible thread-ID bit survives mask/extract plus the shift, and the scalar is uniform and unmodified up to the use. The old `v_lshl_add_u32` path keeps its conditions. Linux checks: both touched Python tests, `docs_links_check.py`, `bidi_controls_check.py` and `git diff --check` pass. Two mutations of the proof (dropping the surviving-bit mask test, dropping the bfe surviving-bit test) each make `startup_gfx2hlsl_readfirstlane_uniform_check.py` fail. The dispatch tests compare GPU readback with a per-thread CPU reference. No other open or merged PR covers this slice. AI-assisted; commands listed were executed locally.
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!2761
No description provided.