shader: lower s_bcnt1_i32_b32 of a scalar word, v_mbcnt over exec_lo and wave32 vcc_hi in compute_store_aot #2158
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2158
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2158/head"
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?
@tedin7 on GitHub · 2026-11-25 01:50 UTC · original
tedin7:x2w-2022g-compute-alu-gaps→main· +317 −10 · 8 files · 4 commits · merged 2026-11-25 10:22 UTCPart of #2022
What this unblocks: item G of #2022 in the compute store profile.
s_bcnt1_i32_b32of a general scalar word,v_mbcnt_lo/hi_u32_b32withexec_loas the mask, and wave32vcc_hias a known-word operand no longer stop a program at the instruction.What changes (
tools/compute_store_aot.py)s_bcnt1_i32_b32 sD, Swith a known scalar wordS(loaded constant, move or ALU result, inline constant, literal, wave32vcc_hi):D = CountOneBits(S)(RDNA2 ISA SOP1; LLVMS_BCNT1_I32_B32=ctpop). Known words fold; run-time words emitcountbits(...).exec_lokeeps its wave and group-size rules.exec,exec_hi,vcc_loand unknown registers stay refused.v_mbcnt_lo_u32_b32 vD, exec_lo, baseoutside a guarded region: every lane below the current one is active in a full wave, so the mask is all ones. Inside a guard the form is refused (Active lane mask inside guarded region).vcc_hi(needs--wave-size 32):s_mov_b32 vcc_hi, K, then known-word reads. Every lowered VCC write touchesvcc_loonly in wave32. Other writes and reads before the move stay refused; without the wave32 statement the name is unrecognised.v_cmp_ne_i32operand forms beyond what #2110 already merged, ands_bcnt1_i32_b64(merged in #2109).Tests
tests/compute_alu_lane_gaps_check.py: exact translations, refusal controls, and a real D3D12 compute readback against an independent CPU reference (two programs: a guarded read-compute one with a run-time word, avcc_himask andv_mbcntover scalar masks, and an unguarded 64-thread one withexec_lo). Wrong references (mask including the lane, mask ignoring the lane, droppedvcc_himask, zero-bit count, rank over 64 lanes, off-by-one count) and mutated HLSL must fail.compute_alu_lane_gaps_controls,compute_store_aot_alu_lane_gaps_{warp,hardware}.compute_alu_bcnt_check.py: the control that refuseds_bcnt1_i32_b32 s9, s0now refusesexec_hi, since a known scalar word is accepted.docs/experiments.md,AGENTS.mdlist, workflow Python list.Verification:
Linux (local):
python3 -B tests/compute_alu_lane_gaps_check.py controlsPASSpython3 -B tests/compute_alu_bcnt_check.py controlsPASSpython3 -B tests/compute_alu_bcnt64_check.pyPASSpython3 -B tests/compute_alu_cmp_ne_check.pyPASSpython3 -B tests/compute_lane_mask_check.py controlsPASS; med3, xor3, cvt_pk_u8, mad_i24, minmax3, salu_absdiff controls PASScompute_store_check.controls()PASSpython3 -B tests/docs_links_check.pyPASSWin2025 WARP (Windows Server 2025 build 26100, MSVC 14.44, D3D12 WARP) at 65765569, via the pipeline
win2025 2158:ctest --preset devon the compute set, includingcompute_alu_lane_gaps_controlsandcompute_store_aot_alu_lane_gaps_warp: 63/63 passed, no skips.ctest --preset release(/O2) on the same set: 63/63 passed, no skips.Linux CI fix: the check list passed
controlsas a script name, socompute_alu_lane_gaps_check.pynow defaults tocontrolsand the workflow and AGENTS.md list it without the argument. GitHub Linux, fixtures and Windows checks pass on this head.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 02:03 UTC · original
[PASS] Win2025 WARP proof at bf5a5611
Command:
x2w_pipe.py win2025 2158 --targets offscreen_check --regex '^(compute_alu_lane_gaps_controls|compute_store_aot_alu_lane_gaps_warp)$'compute_alu_lane_gaps_controlsPassedcompute_store_aot_alu_lane_gaps_warpPassed (D3D12 WARP readback vs CPU reference, wrong references and mutated HLSL rejected)An earlier run at a00286fa failed on one mutation that changed nothing (a shift by 63 wraps to the same value). It now uses a mask of 15, which changes the result.
AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 02:48 UTC · original · edited 2026-11-25 02:54 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
6576556ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 02:54 UTC · original
When
v_mbcnt_* ..., exec_lo, ...occurs after a supporteds_or_b32 exec_lo, exec_lo, sNrestore,guardis cleared butguard_spanremains to delimit the earlier guarded stores. This condition therefore rejects the instruction withActive lane mask inside guarded regioneven though EXEC is full again. This is reproducible by replacing the post-restore move intests/compute_store_check.py'sGUARD_JOINfixture withv_mbcnt_lo_u32_b32 v1, exec_lo, 0; the equivalent-1mask lowers successfully. Check whether the guard is currently active rather than whether any guard span exists.Useful? React with 👍 / 👎.
@tedin7 on GitHub · 2026-11-25 03:41 UTC · original
Fixed in d375bf32.
Verified on Windows Server 2025 (D3D12 WARP) at d375bf3279632bdc23e49dd83a5bc52df80165f1:
x2w_pipe.py win2025 2158 --force --targets offscreen_check --regex "^(compute_alu_lane_gaps_controls|compute_store_aot_alu_lane_gaps_warp)$"-> 2/2 passed, 0 skippedAI-assisted; commands listed were executed locally.
@legacy-code-archaeologist on GitHub · 2026-11-25 05:50 UTC · original
Ran head
dcec4727on three adapters. All pass. Windows 11 build 26100, debug layer unavailable.compute_alu_lane_gaps_controlscompute_store_aot_alu_lane_gaps_warpmismatches=0compute_store_aot_alu_lane_gaps_hardware(XBOX2WINDOWS_ADAPTER=Quadro)compute_store_aot_alu_lane_gaps_hardware(XBOX2WINDOWS_ADAPTER=Intel)AI-assisted.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 02:54 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
6576556957ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".