shader: lower compute s_bitset0_b32 and s_bitset1_b32 #1572
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1579"
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 Asimmimx on 2026-11-24T14:33:48Z.
Change
Refs #1546. This adds
s_bitset0_b32ands_bitset1_b32to the compute translator's scalar ALU on known words (tools/compute_store_aot.py).Semantics. The two SOP1 forms clear or set bit
src0[4:0]ofsD, keep its other bits, and do not write SCC. The RDNA ISA defines them asD.u32[S0.u32[4:0]] = 0or1. LLVM's SOP1 definitions tiesdstto ansdst_inoperand, so the instruction also readssD. The lowering uses the same expressions astools/pixel_aot.py's b32 bitset:s_bitset0_b32→(sD & ~(1u << (s & 31u)))s_bitset1_b32→(sD | (1u << (s & 31u)))Code. The change adds two
SALUentries and a newelifbranch before thes_movk_i32branch inlower(). The destination must already hold a known word. A destination or source that is not a known word, a pending destination, or a destination past s105 stops with "Unverified scalar ALU operand".The fixture and controls are in a new
tests/compute_salu_bitset_check.py. It imports the helpers oftests/compute_store_check.pyand leaves that file unchanged.Fixture. A single invocation reads root constants c0..c7 and stores eight results, run twice with different constants. The expected words come from a separate Python reference that edits one bit in a bit list. The same words are also written out by hand, and the controls check that the two agree. The cases cover:
32,0x3e,0x47,63,-1,0xffffffe1), so only bits [4:0] count;s_bitset0_b32 s23, s23).Negative checks. These must fail at the first differing word:
sDbits dropped, and the other run's words;2u <<, and the index taken from c1.Translator controls. These must be refused with the existing messages:
s_bitset0/1_b64;The new CTest is
compute_store_aot_salu_bitset_${adapter}, aftercompute_store_aot_mimg_msaa. A "Single-bit set and clear" subsection is added under "Scalar ALU on known words" indocs/experiments.md.Verification
Commit
6c0e5380(main) plus this change,devpreset, Windows 11 Pro build 26300.9974, DXC 1.8.2502.11.1002:73ff), driver 32.0.21045.29003, debug layer enabledThese also pass with the change:
compute_store_checktranslator controls, includingscalar_alu_controls;draw-guard-readon WARP;compile-mimg-atomic-integer;tests/docs_links_check.py,tests/bidi_controls_check.py,tests/form_coverage_check.pyandgit diff --check.Notes
& 31ucannot change the readback. The masking rule is covered by the indices above 31 and by the unmasked-reference control.llvm-mc19 (for examples_bitset0_b32 s22, 63), not with LLVM 15.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:39:33Z.
Review: COMMENTED
Peer review at
23fb9a9b(shader: lower compute s_bitset0_b32 and s_bitset1_b32): looks good, no blocking issues found.Code & Semantics Review
tools/compute_store_aot.py:s_bitset0_b32ands_bitset1_b32lower to({0} & ~(1u << ({1} & 31u)))and({0} | (1u << ({1} & 31u))), verifying bothsD(read-modify-write) andsrc0viaalu_word(...),dst <= 105, non-pending status, andALU_EXPRESSION_LIMIT, without touching SCC.tests/compute_salu_bitset_check.py: exercises runtime SGPRs, inline constants (4,63,-1), >31 indices,0xffffffe1literal,sD == src0, copy independence, hand-worked words, unverified/pending/group-ID/saved-exec-mask/64-bit/vector rejections, plus 4 wrong references and 5 DXC-compiled HLSL mutations indraw.CMakeLists.txt&docs/experiments.md: registerscompute_store_aot_salu_bitset_${adapter}and documents the lowering and controls.Local Verification
python3 tests/compute_salu_bitset_check.py controls— passedllvm-mc-19 -arch=amdgcn -mcpu=gfx1013 -show-encoding&-mcpu=gfx1030ons_bitset0_b32/s_bitset1_b32forms — passedpython3 tests/docs_links_check.py(16 Markdown files, 344 links) — passedpython3 tests/bidi_controls_check.py(1253 tracked files) — passed--preset devDebug &--preset release/O2):ctest --preset dev -R '^compute_store_aot_salu_bitset_warp$'(within 41/41 compute-store suite) — 41/41 passed (compute_store_aot_salu_bitset_warp3.57s)ctest --preset release -R '^compute_store_aot_salu_bitset_warp$'(within 41/41 compute-store suite) — 41/41 passed (compute_store_aot_salu_bitset_warp3.71s)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:08:20Z.
Review: COMMENTED
Re-review at
head_sha:e8e949088d0fa25e0b73fbbb1e69586d8b9be023(previously reviewed at23fb9a9b).Findings
No P1/P2. No defect found.
main. I compared the patch of the old commit with the patch of this one (git range-diff, and a diff of the added and removed lines): the PR's own content is unchanged. Even the changed lines are the same; only the surrounding context differs.git merge-treeof the head against currentmain(80f413a7at the time) reports no conflicts (treec5b431f0).Verified
Limits: Linux x86-64 only. I did not rerun the Windows WARP/hardware
ctestfor this head (no Windows runner in this pass), so thedrawmode is covered only by the unchanged patch content and the earlier Windows results on the previous head.python3 -B tests/compute_salu_bitset_check.py controls-> exit 0.llvm-mc-19 -triple=amdgcn-amd-amdhsa -mcpu=gfx1013 -show-encodingassembless_bitset0_b32 s1, s2ands_bitset1_b32 s1, 4.python3 -B tests/docs_links_check.py-> 16 files, 351 links OK.git diff --check HEAD^ HEADclean.s_bitset1_b32template mask from& 31uto& 30uintools/compute_store_aot.py;controlsfails with anAssertionError(exit 1). Restored withgit checkout -- .;git status --shortclean.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:58:29Z.
Review: COMMENTED
Verification review at exact
head_sha:e8e949088d0fa25e0b73fbbb1e69586d8b9be023(shader: lower compute s_bitset0_b32 and s_bitset1_b32).Verdict
CMakeLists.txttest-only,docs/experiments.md,tests/compute_salu_bitset_check.py,tools/compute_store_aot.py; zerosrc/,tools/startup/, or.github/changes).s_bitset0_b32/s_bitset1_b32:D.u32[S0.u32[4:0]] = 0/1, SCC untouched, read-modify-write onsD,dst <= 105, non-pending,ALU_EXPRESSION_LIMIT) match the lowering and test suite.Commands Executed Locally
git diff --check,python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,py_compile— PASSpython3 -B tests/compute_salu_bitset_check.py controls— PASSllvm-mc-19 -arch=amdgcn -mcpu=gfx1013 -show-encoding&-mcpu=gfx1030 -show-encodingons_bitset0_b32/s_bitset1_b32forms (s22, s23;s20, s21;s26, 63;s27, -1;s29, 0xffffffe1) — PASStools/compute_store_aot.py(restored viagit checkout -- .):s_bitset0_b32clear template mutated to set (|) -> caught bycontrols(AssertionError)s_bitset1_b32shift mask& 31umutated to& 15u-> caught bycontrols(AssertionError)--preset dev):ctest --preset dev -R '^...compute_store_aot_salu_bitset_warp...$' --parallel 4 --no-tests=error --output-on-failure— 47/47 passed (compute_store_aot_salu_bitset_warp4.40s)/O2(--preset release):ctest --preset release -R '^...compute_store_aot_salu_bitset_warp...$' --parallel 4 --no-tests=error --output-on-failure— 47/47 passed (compute_store_aot_salu_bitset_warp4.37s)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:34:54Z.
This PR currently has merge conflicts with
main. Could you please rebase it onto the latestmainso it can be checked for merge?AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:59:59Z.
Merged
origin/maininto this branch (plain merge, no rebase). It only conflicted, nothing else changed:CMakeLists.txt: kept both test blocks; thesalu_bitsettest now also setsFORM_COVERAGE_RECORDlike its siblings.docs/experiments.md: kept both sections (single-bit set/clear and scalar bit-field extract).tools/compute_store_aot.py: kept thes_bitset0/1_b32branch and main'ss_cmp/s_cselectbranches. The bitset branch now passessizestoalu_word, matching main's new signature.Commands executed:
python3 -B tests/compute_salu_bitset_check.py controls: self-test passedpython3 tests/docs_links_check.pyandpython3 tests/bidi_controls_check.py: cleangit diff --check origin/main...HEAD: cleanctestforsalu_bitset|compute_store_aot_(salu|gfx1013_image_store|mimg_store)passed 18/18 in--preset devand 18/18 in--preset release.AI-assisted; commands listed were executed locally.