startup: prove uniform shifts of masked and extracted thread IDs #2761
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2769"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, scalarproducesscalar >> nafter 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, widthproduces 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
eab5b3a7against6a6eecfeon Windows 11: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 atword=4 expected=00000000 actual=00000001on 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).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:12:12Z.
Review: COMMENTED
Reviewed head
eab5b3a7against 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.
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:--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/O2(--preset release): same regex: 19/19 passedtests/startup_gfx2hlsl_readfirstlane_uniform_check.pyrc=0,tests/startup_gfx2hlsl_compute_check.pyrc=0Review of the exact head (against main): the new
v_and_or_b32andv_bfe_u32cases 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 oldv_lshl_add_u32path keeps its conditions. Linux checks: both touched Python tests,docs_links_check.py,bidi_controls_check.pyandgit diff --checkpass. Two mutations of the proof (dropping the surviving-bit mask test, dropping the bfe surviving-bit test) each makestartup_gfx2hlsl_readfirstlane_uniform_check.pyfail. 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.